mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-14 00:26:21 +00:00
Fix ollama, fix RAG
[ci skip]
This commit is contained in:
@@ -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
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user