Spaces:
Paused
Paused
Savestate: Route intent classification to currently selected model if it is a Gemini model
Browse files- index.html +1 -1
- src/ai/router.js +6 -5
index.html
CHANGED
|
@@ -65,7 +65,7 @@
|
|
| 65 |
</head>
|
| 66 |
<body class="dark-theme in-chat-view">
|
| 67 |
|
| 68 |
-
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.8.
|
| 69 |
|
| 70 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 71 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
|
|
|
| 65 |
</head>
|
| 66 |
<body class="dark-theme in-chat-view">
|
| 67 |
|
| 68 |
+
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.8.212</div>
|
| 69 |
|
| 70 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 71 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
src/ai/router.js
CHANGED
|
@@ -6,7 +6,7 @@ import { db } from '../db/database.js';
|
|
| 6 |
import { researchAgent } from './research-agent.js';
|
| 7 |
|
| 8 |
export class AIRouter {
|
| 9 |
-
async _getLLMIntent(intentPrompt) {
|
| 10 |
const dsKey = db.getSetting('deepseek_api_key');
|
| 11 |
if (dsKey) {
|
| 12 |
try {
|
|
@@ -20,7 +20,8 @@ export class AIRouter {
|
|
| 20 |
const geminiKey = db.getSetting('gemini_api_key');
|
| 21 |
if (geminiKey) {
|
| 22 |
try {
|
| 23 |
-
const
|
|
|
|
| 24 |
if (response) return response;
|
| 25 |
} catch (e) {
|
| 26 |
console.warn("Gemini intent failed:", e.message);
|
|
@@ -62,7 +63,7 @@ export class AIRouter {
|
|
| 62 |
const intentPrompt = `Der Nutzer fragt: "${prompt}".\nBenötigt diese Frage ZWINGEND topaktuelle Live-Daten aus dem Internet (z.B. tagesaktuelles Wetter, Börsenkurse, heutige News, aktuelle Sportergebnisse)?\nACHTUNG: Für allgemeines Wissen, Erklärungen (z.B. Physik, Geschichte) oder Code-Fragen antworte zwingend mit NEIN.\nAntworte NUR mit JA oder NEIN.`;
|
| 63 |
let intent = "";
|
| 64 |
try {
|
| 65 |
-
intent = await this._getLLMIntent(intentPrompt);
|
| 66 |
} catch(fallbackErr) {
|
| 67 |
console.warn("Intent LLM failed, using fallback:", fallbackErr.message);
|
| 68 |
}
|
|
@@ -93,7 +94,7 @@ export class AIRouter {
|
|
| 93 |
let intentResult = '';
|
| 94 |
try {
|
| 95 |
const worksheetIntentPrompt = `Der Nutzer hat ein Bild hochgeladen und fragt: "${prompt.substring(0, 1000)}".\nMöchte der Nutzer, dass du dieses Bild (z.B. ein Arbeitsblatt) direkt "ausfüllst", "visuell löst" oder etwas "einzeichnest"?\nAntworte NUR mit JA oder NEIN.`;
|
| 96 |
-
intentResult = await this._getLLMIntent(worksheetIntentPrompt);
|
| 97 |
} catch(e) {
|
| 98 |
console.warn("Worksheet intent LLM failed, using regex fallback:", e.message);
|
| 99 |
if (prompt.match(/ausfüllen|lösen|lücken|trage.*ein|zeichnen|beschriften/i)) {
|
|
@@ -125,7 +126,7 @@ export class AIRouter {
|
|
| 125 |
let imageIntent = "";
|
| 126 |
try {
|
| 127 |
const imageIntentPrompt = `Der Nutzer fragt: "${prompt}".\nMöchte der Nutzer hier ein generiertes Bild sehen? (Signale: "Skizze", "Bild", "Zeichnung", "Foto", "Diagramm", "visualisieren").\nWenn ein Bild sinnvoll ist, antworte NUR mit dem passenden englischen Bild-Prompt (max 30 Wörter, z.B. "A technical sketch of...").\nWenn KEIN Bild benötigt wird (reiner Text reicht völlig), antworte NUR mit NEIN.`;
|
| 128 |
-
imageIntent = await this._getLLMIntent(imageIntentPrompt);
|
| 129 |
} catch(fallbackErr) {
|
| 130 |
console.warn("Image Intent LLM failed, using regex fallback:", fallbackErr.message);
|
| 131 |
if (prompt.match(/zeichne|skizziere|generiere.*bild|zeig.*bild/i)) {
|
|
|
|
| 6 |
import { researchAgent } from './research-agent.js';
|
| 7 |
|
| 8 |
export class AIRouter {
|
| 9 |
+
async _getLLMIntent(intentPrompt, currentModel = null) {
|
| 10 |
const dsKey = db.getSetting('deepseek_api_key');
|
| 11 |
if (dsKey) {
|
| 12 |
try {
|
|
|
|
| 20 |
const geminiKey = db.getSetting('gemini_api_key');
|
| 21 |
if (geminiKey) {
|
| 22 |
try {
|
| 23 |
+
const geminiModel = (currentModel && currentModel.startsWith('gemini')) ? currentModel : 'gemini-3.5-flash-lite';
|
| 24 |
+
const response = await gemini.generateContent(intentPrompt, geminiModel, geminiKey);
|
| 25 |
if (response) return response;
|
| 26 |
} catch (e) {
|
| 27 |
console.warn("Gemini intent failed:", e.message);
|
|
|
|
| 63 |
const intentPrompt = `Der Nutzer fragt: "${prompt}".\nBenötigt diese Frage ZWINGEND topaktuelle Live-Daten aus dem Internet (z.B. tagesaktuelles Wetter, Börsenkurse, heutige News, aktuelle Sportergebnisse)?\nACHTUNG: Für allgemeines Wissen, Erklärungen (z.B. Physik, Geschichte) oder Code-Fragen antworte zwingend mit NEIN.\nAntworte NUR mit JA oder NEIN.`;
|
| 64 |
let intent = "";
|
| 65 |
try {
|
| 66 |
+
intent = await this._getLLMIntent(intentPrompt, modelStr);
|
| 67 |
} catch(fallbackErr) {
|
| 68 |
console.warn("Intent LLM failed, using fallback:", fallbackErr.message);
|
| 69 |
}
|
|
|
|
| 94 |
let intentResult = '';
|
| 95 |
try {
|
| 96 |
const worksheetIntentPrompt = `Der Nutzer hat ein Bild hochgeladen und fragt: "${prompt.substring(0, 1000)}".\nMöchte der Nutzer, dass du dieses Bild (z.B. ein Arbeitsblatt) direkt "ausfüllst", "visuell löst" oder etwas "einzeichnest"?\nAntworte NUR mit JA oder NEIN.`;
|
| 97 |
+
intentResult = await this._getLLMIntent(worksheetIntentPrompt, modelStr);
|
| 98 |
} catch(e) {
|
| 99 |
console.warn("Worksheet intent LLM failed, using regex fallback:", e.message);
|
| 100 |
if (prompt.match(/ausfüllen|lösen|lücken|trage.*ein|zeichnen|beschriften/i)) {
|
|
|
|
| 126 |
let imageIntent = "";
|
| 127 |
try {
|
| 128 |
const imageIntentPrompt = `Der Nutzer fragt: "${prompt}".\nMöchte der Nutzer hier ein generiertes Bild sehen? (Signale: "Skizze", "Bild", "Zeichnung", "Foto", "Diagramm", "visualisieren").\nWenn ein Bild sinnvoll ist, antworte NUR mit dem passenden englischen Bild-Prompt (max 30 Wörter, z.B. "A technical sketch of...").\nWenn KEIN Bild benötigt wird (reiner Text reicht völlig), antworte NUR mit NEIN.`;
|
| 129 |
+
imageIntent = await this._getLLMIntent(imageIntentPrompt, modelStr);
|
| 130 |
} catch(fallbackErr) {
|
| 131 |
console.warn("Image Intent LLM failed, using regex fallback:", fallbackErr.message);
|
| 132 |
if (prompt.match(/zeichne|skizziere|generiere.*bild|zeig.*bild/i)) {
|