forensic-ai #4

Merged
mstoeck3 merged 20 commits from forensic-ai into main 2025-08-05 20:56:02 +00:00
Showing only changes of commit 3a5e8e88b2 - Show all commits

View File

@ -119,16 +119,22 @@ class EmbeddingsService {
const apiKey = process.env.AI_EMBEDDINGS_API_KEY;
const model = process.env.AI_EMBEDDINGS_MODEL;
if (!endpoint || !apiKey || !model) {
if (!endpoint || !model) {
throw new Error('Missing embeddings API configuration');
}
const headers: Record<string, string> = {
'Content-Type': 'application/json'
};
// API key is optional for Ollama but required for Mistral/OpenAI
if (apiKey) {
headers['Authorization'] = `Bearer ${apiKey}`;
}
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
},
headers,
body: JSON.stringify({
model,
input: contents
@ -141,9 +147,20 @@ class EmbeddingsService {
}
const data = await response.json();
// Detect Ollama format
if (Array.isArray(data.embeddings)) {
return data.embeddings;
}
// Detect OpenAI/Mistral format
if (Array.isArray(data.data)) {
return data.data.map((item: any) => item.embedding);
}
throw new Error('Unknown embeddings API response format');
}
private async generateEmbeddings(toolsData: any, version: string): Promise<void> {
const allItems = [
...toolsData.tools.map((tool: any) => ({ ...tool, type: 'tool' })),