Merge pull request 'Fixing Intent in Dev.py' (#4) from testing into main
Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
+21
-12
@@ -386,17 +386,6 @@ def dev_search():
|
||||
|
||||
scores.sort(key=lambda s: s['score'], reverse=True)
|
||||
|
||||
# Refresh latest intent from Valkey
|
||||
try:
|
||||
from ollama_answers import _get_valkey
|
||||
vk = _get_valkey()
|
||||
latest_intent = vk.get("ai:last_intent")
|
||||
|
||||
if latest_intent:
|
||||
detected_intent = latest_intent
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
_last_render['html'] = html_payload
|
||||
_last_render['query'] = query
|
||||
_last_render['intent'] = detected_intent
|
||||
@@ -527,6 +516,20 @@ def dev_stream_watch():
|
||||
'X-Accel-Buffering': 'no'
|
||||
})
|
||||
|
||||
@app.route('/dev/job-intent/<job_id>')
|
||||
def dev_job_intent(job_id):
|
||||
try:
|
||||
import valkey as _vk
|
||||
host = os.getenv('VALKEY_HOST', 'localhost')
|
||||
port = int(os.getenv('VALKEY_PORT', 6379))
|
||||
v = _vk.Valkey(host=host, port=port,
|
||||
socket_connect_timeout=2,
|
||||
decode_responses=True)
|
||||
intent = v.get(f"ai:job:{job_id}:intent")
|
||||
return jsonify({'intent': intent or '—', 'job_id': job_id})
|
||||
except Exception as e:
|
||||
return jsonify({'intent': '—', 'error': str(e)})
|
||||
|
||||
# ── dev config update ─────────────────────────────────────────────────────────
|
||||
@app.route('/dev/config', methods=['POST'])
|
||||
def dev_config():
|
||||
@@ -1055,7 +1058,6 @@ async function doSearch() {
|
||||
fetch('/dev/last-scores?t=' + Date.now())
|
||||
.then(r => r.json())
|
||||
.then(meta => {
|
||||
console.log('LAST SCORES:', meta);
|
||||
|
||||
const intentEl = document.getElementById('intent');
|
||||
if (intentEl) {
|
||||
@@ -1329,6 +1331,13 @@ async function attachStreamViewer() {
|
||||
document.getElementById('stream-status').textContent = '✓ Done';
|
||||
document.getElementById('stream-status').style.color = 'var(--green)';
|
||||
document.getElementById('sv-total-time').textContent = `Total: ${total}ms`;
|
||||
fetch(`/dev/job-intent/${jobId}`)
|
||||
.then(r => r.json())
|
||||
.then(d => {
|
||||
const svIntent = document.getElementById('sv-intent');
|
||||
if (svIntent) svIntent.textContent = d.intent || '—';
|
||||
})
|
||||
.catch(() => {});
|
||||
return;
|
||||
}
|
||||
if (e.data.startsWith('__ERROR__')) {
|
||||
|
||||
@@ -2,3 +2,4 @@ flask
|
||||
flask-babel
|
||||
certifi
|
||||
python-dotenv
|
||||
valkey
|
||||
Reference in New Issue
Block a user