Open mjkilian1992 opened 1 month ago
metadata should be passed in directly, not via model_kwargs
import os
from langchain_anthropic import ChatAnthropic
from langchain_core.runnables import ConfigurableField, RunnableConfig
client = ChatAnthropic(
model_name='claude-3-opus-20240229',
).configurable_fields(
metadata=ConfigurableField(
id="metadata",
name="Metadata",
description="metadata ",
),
)
configurable = {
"metadata": {"user_id": "testuserid"}
}
response = client.invoke("Write me a short story", config=RunnableConfig(configurable=configurable))
print(response)
I tried your suggestion @baskaryan and it no longer errors, but unfortunately it doesn't send the user ID either. Here's the request params that are sent on:
{
"model": "claude-3-opus-20240229",
"messages": [
{
"role": "user",
"content": "Write me a short story"
}
],
"max_tokens": 1024
}
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Exception:
ValidatorError
Description
metadata
object on themessages.create(...)
call, as described herecreate()
call, I believe I should be able to pass it viamodel_kwargs
metadata
field ofBaseLanguageModel
)Is there a way around this so that I can pass the
metadata
kwarg to thecreate()
call as expected? At a glance since it's nested undermodel_kwargs
it shouldn't clash with other params. Are they being flattened and if so, why?System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found: