Skip to content

Commit

Permalink
WIP it's building but not working
Browse files Browse the repository at this point in the history
  • Loading branch information
aHenryJard committed Jan 28, 2025
1 parent f635e48 commit e5389e2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion opencti-platform/opencti-graphql/src/database/ai-llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ if (AI_ENABLED && AI_TOKEN) {
client = new Mistral({
serverURL: isEmptyField(AI_ENDPOINT) ? undefined : AI_ENDPOINT,
apiKey: AI_TOKEN,
debugLogger: {
log: (message, args) => logApp.info(`[AI] log ${message}`, { message }),
group: (label) => logApp.info(`[AI] group ${label} start.`),
groupEnd: () => logApp.info('[AI] group end.'),
}
});
break;
case 'openai':
Expand All @@ -38,15 +43,17 @@ export const queryMistralAi = async (busId: string | null, question: string, use
throw UnsupportedError('Incorrect AI configuration', { enabled: AI_ENABLED, type: AI_TYPE, endpoint: AI_ENDPOINT, model: AI_MODEL });
}
try {
logApp.debug('[AI] Querying MistralAI with prompt', { questionStart: question.substring(0, 100) });
logApp.info('[AI] Querying MistralAI with prompt', { questionStart: question });
const response = await (client as Mistral)?.chat.stream({
model: AI_MODEL,
messages: [{ role: 'user', content: question }],
safePrompt: undefined,
});
let content = '';
if (response) {
// eslint-disable-next-line no-restricted-syntax
for await (const chunk of response) {
logApp.info('[AI] Querying MistralAI response chunk', { chunk });
if (chunk.data.choices[0].delta.content !== undefined) {
const streamText = chunk.data.choices[0].delta.content;
content += streamText;
Expand Down

0 comments on commit e5389e2

Please sign in to comment.