Make Groq happier
| @@ -97,8 +97,6 @@ router.post('/caption-image', jsonParser, async (request, response) => { | |||
| 97 | excludeKeysByYaml(body, request.body.custom_exclude_body); | 97 | excludeKeysByYaml(body, request.body.custom_exclude_body); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | console.debug('Multimodal captioning request', body); | ||
| 101 | |||
| 102 | let apiUrl = ''; | 100 | let apiUrl = ''; |
| 103 | 101 | ||
| 104 | if (request.body.api === 'openrouter') { | 102 | if (request.body.api === 'openrouter') { |
| @@ -124,6 +122,9 @@ router.post('/caption-image', jsonParser, async (request, response) => { | |||
| 124 | 122 | ||
| 125 | if (request.body.api === 'groq') { | 123 | if (request.body.api === 'groq') { |
| 126 | apiUrl = 'https://api.groq.com/openai/v1/chat/completions'; | 124 | apiUrl = 'https://api.groq.com/openai/v1/chat/completions'; |
| 125 | if (body.messages?.[0]?.role === 'system') { | ||
| 126 | body.messages[0].role = 'user'; | ||
| 127 | } | ||
| 127 | } | 128 | } |
| 128 | 129 | ||
| 129 | if (request.body.api === 'mistral') { | 130 | if (request.body.api === 'mistral') { |
| @@ -153,6 +154,7 @@ router.post('/caption-image', jsonParser, async (request, response) => { | |||
| 153 | } | 154 | } |
| 154 | 155 | ||
| 155 | setAdditionalHeaders(request, { headers }, apiUrl); | 156 | setAdditionalHeaders(request, { headers }, apiUrl); |
| 157 | console.debug('Multimodal captioning request', body); | ||
| 156 | 158 | ||
| 157 | const result = await fetch(apiUrl, { | 159 | const result = await fetch(apiUrl, { |
| 158 | method: 'POST', | 160 | method: 'POST', |