-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Python: Introduce the chat history reducer #10190
Conversation
Python Test Coverage Report •
Python Unit Test Overview
|
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.
Couple of questions raised, most importantly why this isn't part of the whole thing instead of part of agents!
python/semantic_kernel/agents/history/chat_history_truncation_reducer.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/agents/history/chat_history_summarization_reducer.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/agents/history/chat_history_reducer_extensions.py
Outdated
Show resolved
Hide resolved
python/samples/concepts/agents/chat_completion_history_reducer.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/agents/history/chat_history_summarization_reducer.py
Outdated
Show resolved
Hide resolved
…ndencies present in code.
python/samples/concepts/chat_completion/simple_chatbot_with_truncation_history_reducer.py
Show resolved
Hide resolved
python/semantic_kernel/agents/strategies/selection/selection_strategy.py
Show resolved
Hide resolved
python/semantic_kernel/agents/strategies/selection/sequential_selection_strategy.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_summarization_reducer.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_summarization_reducer.py
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_reducer_utils.py
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_summarization_reducer.py
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_truncation_reducer.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_summarization_reducer.py
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_reducer_utils.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_reducer_utils.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_reducer_utils.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_summarization_reducer.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_summarization_reducer.py
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_summarization_reducer.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_summarization_reducer.py
Show resolved
Hide resolved
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.
couple of small comments!
python/semantic_kernel/contents/history_reducer/chat_history_reducer.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_summarization_reducer.py
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/open_ai/services/open_ai_handler.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/open_ai/services/open_ai_chat_completion_base.py
Outdated
Show resolved
Hide resolved
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.
Only further improvement would be to test with the function call settings, but that can come later
What do you mean? |
python/samples/concepts/agents/chat_completion_history_reducer.py
Outdated
Show resolved
Hide resolved
python/samples/concepts/agents/chat_completion_history_reducer.py
Outdated
Show resolved
Hide resolved
python/samples/concepts/chat_completion/simple_chatbot_kernel_function.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/contents/history_reducer/chat_history_reducer.py
Outdated
Show resolved
Hide resolved
…-kernel into py-chat-history-reduce
Motivation and Context
The SK Python framework has been missing the ability to configure a chat history reducer of type
ChatHistoryTruncationReducer
andChatHistorySummarizationReducer
which have existed in the .Net SK Agent framework for some time.The goal of this PR is to introduce the chat history reducers and allow them for use for not only the agent framework, but also anything else that uses a chat history (chat completion, for example). The ChatHistoryReducer extends the ChatHistory class, and so it's simple to include a reducer and logic to reduce messages as one manages the chat history either in an agent framework setting or in a chat completion setting.
Description
This PR:
ChatHistoryTruncationReducer
andChatHistorySummarizationReducer
.Chat Completion History Reducer
to show how to configure both reducers and what each parameter does.select_agent
abstract method so that one can define an initial agent to run in a particular scenario.FunctionCallBehavior
class, and removes some nasty circular dependencies that we had lurking in the code base for some time. ThisFunctionCallBehavior
has been marked with a deprecation warning for 6+ months now. All samples and docs have moved over to useFunctionChoiceBehavior
- developers usingFunctionCallBehavior
should have had enough time to switch.Contribution Checklist