-
Notifications
You must be signed in to change notification settings - Fork 817
feat(llm): pass session user_id to Anthropic via metadata #1336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,6 +169,7 @@ def create_llm( | |
| base_url=provider.base_url, | ||
| api_key=resolved_api_key, | ||
| default_max_tokens=50000, | ||
| metadata={"user_id": session_id} if session_id else None, | ||
| ) | ||
|
Comment on lines
169
to
173
|
||
| case "google_genai" | "gemini": | ||
| from kosong.contrib.chat_provider.google_genai import GoogleGenAI | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New behavior: when
metadatais set it will be forwarded into the Anthropicmessages.createrequest, but the snapshot tests for the Anthropic provider don’t currently assert that metadata is included/omitted correctly. Add a test case that constructsAnthropic(metadata={"user_id": "..."}), callsgenerate(), and asserts the request body includes the expectedmetadata(and optionally another case wheremetadatais omitted when None).