This commit is contained in:
bjohnso2 committed 2026-11-20 16:35:19 +00:00
commit 66729f7d08
24 files changed
+907

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
# core/llm_client.py
import requests
import json
from django.conf import settings
from core.registry import TaskRegistry
SYSTEM_PROMPT = f"""{TaskRegistry.build_system_prompt()}
Rules:
- ALWAYS use tools when appropriate. Never respond with text unless explicitly asked for a summary.
- If unsure which module handles a request, choose the most relevant one.
- Include a "final_response" field in every tool_call result for user display."""
def process_user_input(user_text: str):
tools = TaskRegistry.get_all_tools()
payload = {
"model": "llama3.1",
"messages": [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_text}
],
"tools": tools,
"tool_choice": "auto",
"temperature": 0.2
}
try:
resp = requests.post(settings.LLAMA_CPP_URL, json=payload, timeout=15)
data = resp.json()
tool_calls = data["choices"][0]["message"].get("tool_calls", [])
if not tool_calls:
return {"status": "text", "message": data["choices"][0]["message"]["content"]}
result = TaskRegistry.execute(tool_calls[0]["function"]["name"],
json.loads(tool_calls[0]["function"]["arguments"]))
return result
except Exception as e:
return {"error": f"LLM processing failed: {str(e)}"}