feat(engine/ollama.ts): extract message from response data and clean content by removing unnecessary tags (#445)
Co-authored-by: Bastien Mottier <b.mottier@viously.com>
This commit is contained in:
@@ -33,9 +33,14 @@ export class OllamaEngine implements AiEngine {
|
||||
params
|
||||
);
|
||||
|
||||
const message = response.data.message;
|
||||
const { message } = response.data;
|
||||
let content = message?.content;
|
||||
|
||||
return message?.content;
|
||||
if (content && content.includes('<think>')) {
|
||||
return content.replace(/<think>[\s\S]*?<\/think>/g, '').trim();
|
||||
}
|
||||
|
||||
return content;
|
||||
} catch (err: any) {
|
||||
const message = err.response?.data?.error ?? err.message;
|
||||
throw new Error(`Ollama provider error: ${message}`);
|
||||
|
||||
Reference in New Issue
Block a user