Skip to content

fix: enable weave tracing on chat widget#8078

Merged
dmadisetti merged 1 commit intomainfrom
dm/weave-fix
Jan 31, 2026
Merged

fix: enable weave tracing on chat widget#8078
dmadisetti merged 1 commit intomainfrom
dm/weave-fix

Conversation

@dmadisetti
Copy link
Collaborator

📝 Summary

Currently weave tracing fails on the following code:

chat_client = OpenAI()

@weave.op()
def handle_chat(messages, config):
    """Wrapper that ensures string return for marimo."""
    user_msg = messages[-1].content
    chat_messages = [{"role": "user", "content": user_msg}]

    response = chat_client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[get_system_prompt()] + chat_messages,
        tools=get_robot_tools(),
    )

    msg = response.choices[0].message
    return msg.content

chat = mo.ui.chat(
    handle_chat
)
chat

This is because weave.op returns a BoxedStr(str) which the causes pydantic to fail. As such, we force a conversion to string even if isinstance(chunk, str).

@dmadisetti dmadisetti requested a review from akshayka as a code owner January 31, 2026 22:09
@vercel
Copy link

vercel bot commented Jan 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jan 31, 2026 10:09pm

Request Review

@dmadisetti dmadisetti requested review from Light2Dark and removed request for akshayka January 31, 2026 22:09
@dmadisetti dmadisetti added the bug Something isn't working label Jan 31, 2026
@dmadisetti
Copy link
Collaborator Author

Optional deps look like they'll be fixed with #8077
Going to merge for pixi lock

@dmadisetti dmadisetti merged commit d4f8e5a into main Jan 31, 2026
42 of 56 checks passed
@dmadisetti dmadisetti deleted the dm/weave-fix branch January 31, 2026 23:28
@github-actions
Copy link

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.19.8-dev5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants