Spaces:
Paused
Paused
Savestate: Fix overly sensitive intent classifiers and switch them to gemini-3.5-flash
Browse files- index.html +1 -1
- src/ai/router.js +5 -5
- test-intent.js +15 -0
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.194</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
|
@@ -35,9 +35,9 @@ export class AIRouter {
|
|
| 35 |
if (!apiKey) {
|
| 36 |
console.warn("Kein Gemini API Key konfiguriert für Intent Classification.");
|
| 37 |
} else {
|
| 38 |
-
const intentPrompt = `Der Nutzer fragt: "${prompt}".\
|
| 39 |
-
const intent = await gemini.generateContent(intentPrompt, 'gemini-
|
| 40 |
-
if (intent.trim().toUpperCase().includes('JA')) {
|
| 41 |
if (onStatus) onStatus('Lade aktuelle Daten...');
|
| 42 |
|
| 43 |
// Fetch real-time context
|
|
@@ -61,8 +61,8 @@ export class AIRouter {
|
|
| 61 |
try {
|
| 62 |
const apiKey = db.getSetting('gemini_api_key');
|
| 63 |
if (apiKey) {
|
| 64 |
-
const imageIntentPrompt = `Der Nutzer fragt: "${prompt}".\
|
| 65 |
-
const intentModel =
|
| 66 |
const imageIntent = await gemini.generateContent(imageIntentPrompt, intentModel, apiKey);
|
| 67 |
if (imageIntent && !imageIntent.trim().toUpperCase().startsWith('NEIN')) {
|
| 68 |
const imagePromptText = imageIntent.trim();
|
|
|
|
| 35 |
if (!apiKey) {
|
| 36 |
console.warn("Kein Gemini API Key konfiguriert für Intent Classification.");
|
| 37 |
} else {
|
| 38 |
+
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.`;
|
| 39 |
+
const intent = await gemini.generateContent(intentPrompt, 'gemini-3.5-flash', apiKey);
|
| 40 |
+
if (intent && intent.trim().toUpperCase().includes('JA')) {
|
| 41 |
if (onStatus) onStatus('Lade aktuelle Daten...');
|
| 42 |
|
| 43 |
// Fetch real-time context
|
|
|
|
| 61 |
try {
|
| 62 |
const apiKey = db.getSetting('gemini_api_key');
|
| 63 |
if (apiKey) {
|
| 64 |
+
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.`;
|
| 65 |
+
const intentModel = 'gemini-3.5-flash';
|
| 66 |
const imageIntent = await gemini.generateContent(imageIntentPrompt, intentModel, apiKey);
|
| 67 |
if (imageIntent && !imageIntent.trim().toUpperCase().startsWith('NEIN')) {
|
| 68 |
const imagePromptText = imageIntent.trim();
|
test-intent.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { gemini } from './src/ai/gemini.js';
|
| 2 |
+
import { db } from './src/db/database.js';
|
| 3 |
+
|
| 4 |
+
async function test() {
|
| 5 |
+
const apiKey = db.getSetting('gemini_api_key');
|
| 6 |
+
const prompt = 'Erkläre mir das physikalische Prinzip des Flaschenzugs. Bitte zeige mir anhand einer Skizze, wie sich die Zugkraft halbiert.';
|
| 7 |
+
const imageIntentPrompt = `Der Nutzer fragt: "${prompt}".\nErfordert diese Frage zwingend ein generiertes Bild zur visuellen Erklärung oder wurde explizit ein Bild angefragt (z.B. Arbeitsblätter, Diagramme, Szenen, Skizzen)?\nWenn ja, antworte NUR mit dem passenden englischen Midjourney/Flux Bild-Prompt (max 30 Wörter). Wenn nein, antworte NUR mit NEIN.`;
|
| 8 |
+
|
| 9 |
+
try {
|
| 10 |
+
const res = await gemini.generateContent(imageIntentPrompt, 'gemini-3.5-flash', apiKey);
|
| 11 |
+
console.log('Result:', res);
|
| 12 |
+
} catch(e) { console.error('Error:', e); }
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
test();
|