You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documents dropped in standard chat context path (generate_from_chat_context) #949
Documents attached to Message objects via the documents parameter are not included in the API request when using the standard chat context generation path (_generate_from_chat_context_standard in OpenAIBackend).
Details
The intrinsics path (_generate_from_intrinsic_context) correctly calls messages_to_docs() and passes the result as extra_body: {"documents": docs} to the OpenAI-compatible API call.
The standard path (_generate_from_chat_context_standard) never calls messages_to_docs(). The documents are present on the Message objects, but message_to_openai_message() only serializes role and content (and images), so documents are silently lost.
This means that passing documents= on a Message used with generate_from_chat_context (or act with strategy=None) has no effect — the documents never reach the model.
Expected behavior
Documents attached to messages should be extracted and passed to the API in the standard path, the same way they are in the intrinsics path.
Reproduction
Create Document objects and attach them to a Message via documents=
Use mfuncs.act() or backend.generate_from_chat_context() with strategy=None
The model response will not reflect the document content, because the documents were never sent
Ollama's OpenAI-compatible API - documents need to be formatted in a user message to be passed through to the chat template - the chat template is different (but functionally the same) to vLLM and Transformers
Use the function above with how="roles".
I don't know how documents are passed in LiteLLM, but it seems like extra_body is supported in a similar way.
Document passing through documents in extra_body is a Granite thing. No other model does it through a special token in the chat template afaik. All other LLMs just put the documents as context in a user message in some way, so something similar to move_documents_to_message(..., how="string").
Activity
kndtran commentedon Apr 28, 2026
@psschwei We have a similar function for this here: https://github.com/generative-computing/mellea/blob/main/mellea/formatters/granite/intrinsics/input.py#L80
Some important notes for the Granite models:
extra_bodyto pass documents through to the chat templateextra_body.documentspassed through inchat_template_kwargshttps://docs.vllm.ai/en/latest/serving/openai_compatible_server/how="roles".I don't know how documents are passed in LiteLLM, but it seems like
extra_bodyis supported in a similar way.kndtran commentedon Apr 28, 2026
Document passing through
documentsinextra_bodyis a Granite thing. No other model does it through a special token in the chat template afaik. All other LLMs just put the documents as context in a user message in some way, so something similar tomove_documents_to_message(..., how="string").