Initial release — Crucix Intelligence Engine v2.0.0
26-source OSINT intelligence engine with live Jarvis dashboard, auto-refresh via SSE, optional LLM layer (4 providers), delta/memory system, and Telegram breaking news alerts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
48
lib/llm/gemini.mjs
Normal file
48
lib/llm/gemini.mjs
Normal file
@@ -0,0 +1,48 @@
|
||||
// Google Gemini Provider — raw fetch, no SDK
|
||||
|
||||
import { LLMProvider } from './provider.mjs';
|
||||
|
||||
export class GeminiProvider extends LLMProvider {
|
||||
constructor(config) {
|
||||
super(config);
|
||||
this.name = 'gemini';
|
||||
this.apiKey = config.apiKey;
|
||||
this.model = config.model || 'gemini-2.0-flash';
|
||||
}
|
||||
|
||||
get isConfigured() { return !!this.apiKey; }
|
||||
|
||||
async complete(systemPrompt, userMessage, opts = {}) {
|
||||
const url = `https://generativelanguage.googleapis.com/v1beta/models/${this.model}:generateContent?key=${this.apiKey}`;
|
||||
|
||||
const res = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
systemInstruction: { parts: [{ text: systemPrompt }] },
|
||||
contents: [{ parts: [{ text: userMessage }] }],
|
||||
generationConfig: {
|
||||
maxOutputTokens: opts.maxTokens || 4096,
|
||||
},
|
||||
}),
|
||||
signal: AbortSignal.timeout(opts.timeout || 60000),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const err = await res.text().catch(() => '');
|
||||
throw new Error(`Gemini API ${res.status}: ${err.substring(0, 200)}`);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
const text = data.candidates?.[0]?.content?.parts?.[0]?.text || '';
|
||||
|
||||
return {
|
||||
text,
|
||||
usage: {
|
||||
inputTokens: data.usageMetadata?.promptTokenCount || 0,
|
||||
outputTokens: data.usageMetadata?.candidatesTokenCount || 0,
|
||||
},
|
||||
model: this.model,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user