feat: add worker queue fabric — classify, dnc, p1, review, digest, thread-resolve, outbox, AI modules
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
const OPENROUTER_BASE = 'https://openrouter.ai/api/v1';
|
||||
const DEFAULT_MODEL = 'google/gemini-3.5-flash';
|
||||
|
||||
export async function callLLM(
|
||||
prompt: string,
|
||||
apiKey: string,
|
||||
model = DEFAULT_MODEL,
|
||||
): Promise<string> {
|
||||
const res = await fetch(`${OPENROUTER_BASE}/chat/completions`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
'HTTP-Referer': 'https://tower.insignia.app',
|
||||
'X-Title': 'TOWER Community Platform',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model,
|
||||
messages: [{ role: 'user', content: prompt }],
|
||||
temperature: 0.1,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const body = await res.text().catch(() => '');
|
||||
throw new Error(`OpenRouter error ${res.status}: ${body}`);
|
||||
}
|
||||
|
||||
const data = (await res.json()) as { choices: Array<{ message: { content: string } }> };
|
||||
const content = data.choices?.[0]?.message?.content;
|
||||
if (!content) throw new Error('OpenRouter returned empty content');
|
||||
return content;
|
||||
}
|
||||
Reference in New Issue
Block a user