-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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: using agents as KernelFunctions #10828
Conversation
bfc9e91
to
954fb5b
Compare
While I think it's ok to have agents as tools/plugins, I don't think that is a pattern we should encourage. We have the CrewAI as a plugin since it couldn't fit with our abstraction very well. I am mainly concern about the following:
|
) -> Annotated[str, "The response from the agent."]: | ||
history = ChatHistory() | ||
history.add_user_message(task) | ||
return (await self.get_response(history=history)).content |
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.
This is not going to work with other types of agents except the chat completion agent.
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.
For my info, why not? I saw get_response is a abstract method so should be available on every agent, or are the args different?
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.
The args are different.
Superseded by #11184. |
### Motivation and Context We're moving towards a pattern where Agents can be called as tools. We currently don't have this in Semantic Kernel Python. This work builds off of the previous PR (#10828) but extends it to work with any SK Agent now that we have a bit more of a common invocation pattern (all agents take in `messages` kwarg). This also works now because each agent creates its own thread internally, if one isn't provided - so we don't need to worry about handling chat history for an OpenAI Assistant or an Azure AI Agent. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Allow agents to be configured as Kernel Functions, which can then be used during Function Calling. We will advertise the Agent's name and either its description or instructions (if description is blank). - Provide a sample where we show a triage agent (ChatCompletionAgent) calling either a billing agent (ChatCompletionAgent) or a refund agent (ChatCompletionAgent ) as part of a tool call to satisfy the user's query. - Provide a sample where we show a triage agent (ChatCompletionAgent) calling either a billing agent (AzureAIAgent) or a refund agent (ChatCompletionAgent) to satisfy the user's query. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄
Motivation and Context
This adds a convenience method to allow a agent to be called by other agents or regular function calling.
Also includes some improvement in parsing of classes into KernelPlugins
Description
get_response
and a single string 'Task' to run.Contribution Checklist