fix: force JSON output for Ollama intent classification; fix attachment detection
- ollama_backend: add format='json' for 'master' and receipt_parser callers so llama3.1:8b returns valid JSON instead of plain English - ab_ai_mail: add debug logging to trace attachment_ids from Discuss; handle file-only messages and clarification look-back flow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -84,6 +84,20 @@ class DiscussChannel(models.Model):
|
||||
return result
|
||||
|
||||
text = _strip_html(body)
|
||||
|
||||
# Odoo 18 Discuss uploads attachments before posting the message and
|
||||
# passes their IDs in kwargs as attachment_ids (list of ints or ORM
|
||||
# commands). result.attachment_ids resolves those after super() runs.
|
||||
# Log both so we can see exactly what arrives.
|
||||
_logger.info(
|
||||
'AB AI mail hook: body=%r kwargs_keys=%s '
|
||||
'attachment_ids_kwarg=%r result.attachment_ids=%s',
|
||||
(body or '')[:80],
|
||||
list(kwargs.keys()),
|
||||
kwargs.get('attachment_ids'),
|
||||
result.attachment_ids.ids,
|
||||
)
|
||||
|
||||
attachments = result.attachment_ids
|
||||
|
||||
# Nothing to work with
|
||||
|
||||
@@ -24,6 +24,11 @@ class OllamaBackend:
|
||||
kwargs = {'model': self._model, 'messages': messages}
|
||||
if tools:
|
||||
kwargs['tools'] = tools
|
||||
# Force structured JSON output for callers that parse JSON responses.
|
||||
# Without this llama3.1:8b returns plain English instead of JSON.
|
||||
_JSON_CALLERS = {'master', 'expenses_agent_receipt_parser'}
|
||||
if caller in _JSON_CALLERS and not tools:
|
||||
kwargs['format'] = 'json'
|
||||
client = ollama.AsyncClient(host=self._url)
|
||||
try:
|
||||
response = await asyncio.wait_for(client.chat(**kwargs), timeout=self._timeout)
|
||||
|
||||
Reference in New Issue
Block a user