Fix ollama, fix RAG

[ci skip]
This commit is contained in:
shamoon
2025-04-24 22:03:21 -07:00
parent 2c4b8c9afe
commit b1b2d03644
4 changed files with 53 additions and 37 deletions

View File

@@ -62,7 +62,7 @@ def build_prompt_with_rag(document: Document) -> str:
Only output valid JSON in the format below. No additional explanations.
The JSON object must contain:
- title: A short, descriptive title
- title: A short, descriptive title based on the content
- tags: A list of relevant topics
- correspondents: People or organizations involved
- document_types: Type or category of the document
@@ -112,6 +112,6 @@ def get_ai_document_classification(document: Document) -> dict:
client = AIClient()
result = client.run_llm_query(prompt)
return parse_ai_response(result)
except Exception:
except Exception as e:
logger.exception("Failed AI classification")
return {}
raise e

View File

@@ -37,15 +37,15 @@ class AIClient:
url = self.settings.llm_url or "http://localhost:11434"
with httpx.Client(timeout=30.0) as client:
response = client.post(
f"{url}/api/chat",
f"{url}/api/generate",
json={
"model": self.settings.llm_model,
"messages": [{"role": "user", "content": prompt}],
"prompt": prompt,
"stream": False,
},
)
response.raise_for_status()
return response.json()["message"]["content"]
return response.json()["response"]
def _run_openai_query(self, prompt: str) -> str:
if not self.settings.llm_api_key: