Skip to content

feat: handle message docs correctly - #975

Merged
jakelorocco merged 5 commits into
mainfrom
jal/handle-message-docs
Apr 30, 2026
Merged

jakelorocco merged 5 commits into
mainfrom
jal/handle-message-docs

Conversation

@jakelorocco

@jakelorocco jakelorocco commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Misc PR

Type of PR

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Description

Adds support for printing Messages with documents attached. Adds support for attaching documents to Messages and chat interfaces. Modifies document format_for_llm to print something more in line with how intrinsics print the document.

Will need to create new issues to clean up message serialization post this change.

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code as added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Attribution

  • AI coding assistants used

@jakelorocco jakelorocco changed the title Jal/handle message docs feat: handle message docs correctly Apr 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The PR description has been updated. Please fill out the template for your PR to be reviewed.

@github-actions github-actions Bot added the enhancement New feature or request label Apr 30, 2026
Signed-off-by: Jake LoRocco <[email protected]>
Assisted-by: CLAUDE:OPUS
Signed-off-by: Jake LoRocco <[email protected]>
Assisted-by: CLAUDE:OPUS
@jakelorocco
jakelorocco force-pushed the jal/handle-message-docs branch 2 times, most recently from 9368e97 to b544de2 Compare April 30, 2026 16:34
Signed-off-by: Jake LoRocco <[email protected]>
Assisted-by: CLAUDE:OPUS
@jakelorocco
jakelorocco force-pushed the jal/handle-message-docs branch from b544de2 to 23c3833 Compare April 30, 2026 16:55
@nrfulton
nrfulton self-requested a review April 30, 2026 17:11
Comment thread mellea/formatters/template_formatter.py Resolved
Comment thread mellea/backends/ollama.py
conversation.extend(
[
{"role": m.role, "content": m.content, "images": m.images}
{"role": m.role, "content": self.formatter.print(m), "images": m.images}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at some point we should allow components to specify roles and then remove this special case handling. Create an issue for this and reference this commend in that issue. Then go ahead with this PR.

… _coerce_documents

Signed-off-by: Jake LoRocco <[email protected]>
Assisted-by: CLAUDE:OPUS
@nrfulton
nrfulton self-requested a review April 30, 2026 20:52
@jakelorocco
jakelorocco marked this pull request as ready for review April 30, 2026 20:53
@jakelorocco
jakelorocco requested a review from a team as a code owner April 30, 2026 20:53
@jakelorocco
jakelorocco enabled auto-merge April 30, 2026 20:53
@jakelorocco
jakelorocco added this pull request to the merge queue Apr 30, 2026
Merged via the queue into main with commit d6fe698 Apr 30, 2026
8 checks passed
@jakelorocco
jakelorocco deleted the jal/handle-message-docs branch April 30, 2026 21:48
araujof pushed a commit to araujof/mellea that referenced this pull request May 6, 2026
…ing#1010)

role, images, and name were included in Message/ToolMessage.format_for_llm()
args but are never consumed by any template — backends read them directly
from the Message object. Their presence caused a false-positive warning
from the unused-keys check added in generative-computing#975.

Since name was the only thing ToolMessage.format_for_llm() added, the
override is now redundant and has been removed.

Assisted-by: Claude Code

Signed-off-by: Alex Bozarth <[email protected]>
akihikokuroda pushed a commit to akihikokuroda/mellea that referenced this pull request May 27, 2026
* feat: add document support for non-intrinsic code paths

Signed-off-by: Jake LoRocco <[email protected]>
Assisted-by: CLAUDE:OPUS

* feat: add doc support to top-level chat functions

Signed-off-by: Jake LoRocco <[email protected]>
Assisted-by: CLAUDE:OPUS

* feat: add handling for message documents in regular generation paths

Signed-off-by: Jake LoRocco <[email protected]>
Assisted-by: CLAUDE:OPUS

* fix: add warning for key in args not in jinja template

Signed-off-by: Jake LoRocco <[email protected]>
Assisted-by: CLAUDE:OPUS

* fix: pr comments: info -> warn; documents use jinja templates; rename _coerce_documents

Signed-off-by: Jake LoRocco <[email protected]>
Assisted-by: CLAUDE:OPUS

---------

Signed-off-by: Jake LoRocco <[email protected]>
akihikokuroda pushed a commit to akihikokuroda/mellea that referenced this pull request May 27, 2026
…ing#1010)

role, images, and name were included in Message/ToolMessage.format_for_llm()
args but are never consumed by any template — backends read them directly
from the Message object. Their presence caused a false-positive warning
from the unused-keys check added in generative-computing#975.

Since name was the only thing ToolMessage.format_for_llm() added, the
override is now redundant and has been removed.

Assisted-by: Claude Code

Signed-off-by: Alex Bozarth <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up Context and Component Formatting Documents dropped in standard chat context path (generate_from_chat_context)

2 participants