Save FunctionResult to ContextVariables and not to ChatHistory #11027
HuskyDanny
started this conversation in
General
Replies: 3 comments 11 replies
-
We'd recommend writing a chat history reducer for this. https://learn.microsoft.com/en-us/semantic-kernel/concepts/ai-services/chat-completion/chat-history?pivots=programming-language-csharp#chat-history-reduction |
Beta Was this translation helpful? Give feedback.
5 replies
-
Also @sophialagerkranspandey It seems we cannot get ChatHistory from FunctionInvocationContext in the filter hook
|
Beta Was this translation helpful? Give feedback.
4 replies
-
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Can we configure such case so that the function result invoked by an agent will be saved in contextvariables and not to the chat history which is by default.
This is important for my scenario, since the agent will run multiple retrieval, and the response is large, putting in chat history will slow down the downstream tasks, in addition, I also need downstream tasks to use the data directly, having the llm to infer the parameters to put from chat history is simply inaccurate and slow.
So, the core intentions are to:
After some explorations, I found
https://github.com/microsoft/semantic-kernel/blob/main/python/samples/concepts/caching/semantic_caching.py
I am thinking to use the filter to save the function result, and use the in memory store to save and retrieve, but not found an elegant way to remove the unneeded messages for FunctionResult, unless I loop through the ChatHistory from the FunctionContext passed from the filter parameter and remove the FunctionalCall message.
Any ideas or examples? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions