-
We have additional information from our API in our runtime ModelAdapter that we need to pass to the Assistant. right now, we are appending it to the content text in the Runtime, but this causes us many issues. We are trying to figure out a way to pass this information and then be able to access it with useThread or one of the other hooks. Is this possible? Any "hacks" to get this to work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Is this information per-message or per-thread? For per-message metadata, your ChatModelAdapter can pass information by returning For per-thread metadata, you might want to simply add a new react context provider with your custom data: Next to AssistantRuntimeProvider you have: const MyDataContext = createContext();
const Providers = () => {
<AssistantRuntimeProvider>
<MyDataContext.Provider data={...} |
Beta Was this translation helpful? Give feedback.
Is this information per-message or per-thread?
For per-message metadata, your ChatModelAdapter can pass information by returning
{ metadata: { custom: { yourKey: yourValue } }
next to the content. This can be later retrieved viauseMessage(m => m.metadata.custom)
For per-thread metadata, you might want to simply add a new react context provider with your custom data:
https://react.dev/learn/passing-data-deeply-with-context
Next to AssistantRuntimeProvider you have:
https://react.dev/learn/passing-data-deeply-with-context