Atualizar app/app.py
This commit is contained in:
+6
-2
@@ -1490,15 +1490,19 @@ def generate():
|
|||||||
# return jsonify({"error": "Invalid JSON response from Ollama."}), 502
|
# return jsonify({"error": "Invalid JSON response from Ollama."}), 502
|
||||||
#output_text = ollama_data.get("response") or ollama_data.get("output") or ""
|
#output_text = ollama_data.get("response") or ollama_data.get("output") or ""
|
||||||
#return jsonify({"model": model_name, "output": output_text})
|
#return jsonify({"model": model_name, "output": output_text})
|
||||||
|
email = session["user"]["email"] if app.config["AUTH_MODE"] == "oauth" else session["db_user"]["email"]
|
||||||
|
|
||||||
|
cached = get_cache(email, model, prompt)
|
||||||
|
|
||||||
|
|
||||||
cached = get_cache(model, prompt)
|
|
||||||
if cached:
|
if cached:
|
||||||
return jsonify({"model": model, "output": cached, "cached": True})
|
return jsonify({"model": model, "output": cached, "cached": True})
|
||||||
|
|
||||||
result, used_model = call_ollama_with_fallback({"prompt": prompt})
|
result, used_model = call_ollama_with_fallback({"prompt": prompt})
|
||||||
output = result.get("response")
|
output = result.get("response")
|
||||||
|
|
||||||
set_cache(used_model, prompt, output)
|
set_cache(email, used_model, prompt, output)
|
||||||
|
|
||||||
|
|
||||||
return jsonify({"model": used_model, "output": output, "cached": False})
|
return jsonify({"model": used_model, "output": output, "cached": False})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user