Replies: 2 comments 7 replies
-
Based on the information provided, it seems like you're trying to use the The In your case, it seems like you're trying to use the If you want to structure the output of the Here's a rough example of how you might do this: class StructuredRunnable(Runnable):
def __init__(self, runnable, schema):
self.runnable = runnable
self.schema = schema
def run(self, *args, **kwargs):
result = self.runnable.run(*args, **kwargs)
return self.schema(**result)
llm = StructuredRunnable(
ChatOpenAI().configurable_alternatives(
ConfigurableField(id="llm"),
default_key="oai",
azure=AzureChatOpenAI(
openai_api_version="...",
azure_endpoint="..."
)
),
JustForTesting
) In this example, Please note that this is just a rough example and might need to be adjusted based on your specific use case and the exact behavior of the I hope this helps! If you have any further questions or if something is unclear, please let me know. Sources
|
Beta Was this translation helpful? Give feedback.
-
@hschmied this currently does not work. We need to fix up our handling with RunnableBinding to re-surface the methods of the underlying wrapped entity. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I am using configurable_alternatives for my chains & graphs, which works quite well.
Now I'd also like to use '.with_structured_output(...)' which is a method on the llm-object, but by using configurable_alternatives, I have a 'RunnableConfigurableAlternatives'-object, which doesn't know about '.with_structured_output'
I guess I could make it work, if could extract the llm out of the runnable first and then add the '.with_structured_output', but I am stuck on how to do that. Or does anyone have a better/different idea?
Thanks!
System Info
System Information
Package Information
Beta Was this translation helpful? Give feedback.
All reactions