mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 11:19:56 +00:00
4eb44930e975f508bc0a0680bb2ad3a03745dec6
555
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
4eb44930e9 |
Python: improved chat history samples (#10737)
### Motivation and Context <!-- 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. --> Improve the serialization sample Added a more complex sample for using ChatHistory with a VectorStore to store in a backend. Also improves the typing of the vectorstoremodel decorator ### Description <!-- 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 😄 --------- Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
8fd6da2bd8 |
Python: Improve Bedrock service setup docs (#10772)
### Motivation and Context <!-- 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. --> Closing: https://github.com/microsoft/semantic-kernel/issues/9910 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Add detailed instructions on how to setup one's environment to use Bedrock services, including models and agents. 2. Re-enable bedrock integration tests. 3. Some other cleanups. ### 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 😄 |
||
|
|
75453a1219 |
Python: Move to a thinner wrap for Bedrock Agent in Python (#10740)
### Motivation and Context <!-- 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. --> Though the current Bedrock agent implementation uses a "thin wrap" approach, it still has some abstractions that we don't want to maintain. Just like what we have done for the other agents, we remove those abstractions. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Update the Bedrock agent abstraction to be thinner. 2. Update samples and tests. Note: The .Net implementation doesn't need to be updated as it was already using a thinner wrap. Note: This breaks the current usage pattern for Bedrock agents in Python. ### 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 - [ ] I didn't break anyone 😄 |
||
|
|
0153073aa3 |
Python: Bump Python version to 1.22.1 for a release (#10751)
### Motivation and Context Bump Python version to 1.22.1 for a release <!-- 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 Bump Python version to 1.22.1 for a release <!-- 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 😄 |
||
|
|
3a799c8061 |
Python: Allow OpenAIAssistant model id to pass into setup resources (#10748)
### Motivation and Context With the updated OpenAIAssistantAgent.setup_resources method, we weren't allowing one to pass in the `ai_model_id` as part of the method. This PR fixes that. <!-- 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 PR fixes the setup_resources method to be able to override the `chat_deployment_name` as part of the OpenAISettings `ai_model_id` config. <!-- 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 😄 |
||
|
|
c140db327e |
Python: Don't store AzureAIInferenceChatCompletion response inner_content inside of item's text content (#10747)
### Motivation and Context
The `AzureAIInferenceChatCompletion` class, during
`_create_chat_message_content` creation, is storing the `response` which
is a non-hashable object. In other connectors, like the
`AzureChatCompletion` we do not store the `response` in the CMC's
TextContent item. The `response` is available as part of the main
`ChatMessageContent` that is returned, so we don't need to store this
twice, especially since as part of agent group chat, we need to be able
to get the inner item's hash for message comparison.
<!-- 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
Remove the call to store the response as the item's inner_content here:
```python
items.append(
TextContent(
text=choice.message.content,
# inner_content=response, <--- removed
metadata=metadata,
)
)
```
- Closes #10722
<!-- 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 😄
|
||
|
|
fd27470c86 |
Python: Allow plugins via agent constructors. Update samples. (#10707)
### Motivation and Context
In Semantic Kernel, our goal is to simplify working with agents. When an
agent is created without a specified kernel, one is automatically
created on the user’s behalf. This enables developers to pass in a list
of plugins that are then added to the underlying kernel. If both the
agent constructor and the provided kernel include plugins, those
specified via the agent constructor take precedence—since plugins are
stored in a dictionary, any duplicate names result in the agent’s plugin
overwriting the existing one.
For the `ChatCompletionAgent`, usage is further simplified by allowing a
`ChatCompletionClientBase` service to be passed via the constructor. If
a kernel is supplied and already contains a chat completion service, the
new service is added to the kernel. Moreover, if no execution settings
are provided via KernelArguments, the first service registered on the
kernel is used.
New usage to create a ChatCompletionAgent
```python
agent = ChatCompletionAgent(
service=AzureChatCompletion(),
name="<name>",
instructions="<instructions>",
)
```
New usage to create a ChatCompletionAgent with plugins:
```python
agent = ChatCompletionAgent(
service=AzureChatCompletion(),
name="<name>",
instructions="<instructions>",
plugins=[SamplePlugin()],
)
```
Previously, the `service_id` constructor argument was retained after
introducing KernelArguments. However, with our transition to using the
kernel’s AI service selector, the `service_id` parameter has become
redundant. As we move from the experimental phase toward a release
candidate, removing `service_id` is a necessary, albeit breaking,
change.
The `getting_started_with_agents/chat_completion` samples now begin by
demonstrating the simplest way to configure the agent. The subsequent
step illustrates the original method for setting up the chat completion
service on the kernel. Similarly, for plugins, the initial approach is
the easiest to follow, while the following step shows the traditional
method of managing the kernel.
Updated documentation will follow, once these changes are released in a
new package.
!-- 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
Simplifying interactions with agents.
- Updated the `ChatCompletionAgent`, `AzureAssistantAgent`, and
`OpenAIAssistantAgent` classes with the `release_candidate` decorator in
place of the `experimental` decorator.
- Add a chat completion agent structured outputs sample
- Closes #10604
<!-- 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
- [ ] I didn't break anyone 😄
|
||
|
|
5e8fc1e83b |
Python: Bump Python version to 1.22.0 for a release. (#10718)
### Motivation and Context Bump Python version to 1.22.0 for a release. <!-- 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 Bump Python version to 1.22.0 for a release. <!-- 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 😄 |
||
|
|
15ca7a7192 |
Python: Agent get_response API (#10701)
### Motivation and Context <!-- 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. --> With the recent push for improving developer's quality of life, we have decided to make it easier for developers to get started with agents by introducing a new `get_response` API, that hides the complexity of interacting with agents when developers are ramping up with the Agent concept. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Add the `get_response` API on all agent types. This API skips hides the intermediate steps of the agent execution and only returns the final results as a single message. 2. Add tests and samples. 3. Updates the `Agent` class to be an `ABC`, and adds `get_response`, `invoke`, and `invoke_stream` methods as overridable. ### 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 😄 --------- Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
536edaa585 |
Python: Introducing the Chroma Connector with the new vector store design (#10678)
### Motivation and Context <!-- 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. --> Adds ChromaStore and ChromaConnector Closes: #9926 ### Description <!-- 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 😄 --------- Co-authored-by: Tao Chen <[email protected]> |
||
|
|
caef2f32a6 |
Python: improve feature decorator return type so it doesn't affect Pylance (#10704)
### Motivation and Context The new feature decorator was impacting Pylance and child classes weren't properly resolving methods due to the decorator's return type handling. <!-- 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 Update the decorator so it handles the return types properly. <!-- 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 😄 |
||
|
|
174bdabf38 |
Python: Introduce feature decorator to allow for experimental and release candidate decorator usage (#10691)
### Motivation and Context
<!-- 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.
-->
This change is required to improve the flexibility and maintainability
of our feature annotation system. Previously, separate decorators (e.g.,
`experimental_function` and `experimental_class`) were used to mark
experimental features, resulting in code duplication and limiting our
ability to handle additional feature stages. As our SDK evolves, we need
a unified approach that can support multiple stages—such as
experimental, release candidate, and future states—while also allowing
version information for release candidate features to be centrally
managed.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
This PR refactors our feature decorators by introducing a unified
`stage` decorator that updates the docstring and attaches metadata for
both functions and classes. Two convenience decorators, `experimental`
and `release_candidate`, are built on top of `stage`:
- The `experimental` decorator marks features as experimental and sets
an `is_experimental` attribute.
- The `release_candidate` decorator supports multiple usage patterns
(with or without parentheses and with an optional version parameter) to
mark features as release candidate and sets an `is_release_candidate`
attribute.
This unified approach reduces duplication, simplifies the codebase, and
lays the groundwork for easily extending feature stages in the future.
This decorator supports the following usage patterns:
- `@experimental` (for both classes and functions)
- `@release_candidate` (no parentheses)
- `@release_candidate()` (empty parentheses)
- `@release_candidate("1.21.3-rc1")` (positional version)
- `@release_candidate(version="1.21.3-rc1")` (keyword version)
### 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 😄
|
||
|
|
60df17d37d |
Python: Improve agent getting started samples (#10667)
### Motivation and Context <!-- 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. --> We are improving developer experience by updating the agent getting started samples. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Simplify the agent getting started samples by removing unnecessary code and add excessive comments to make sure we are only doing what we need to get started. ### 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 😄 |
||
|
|
9e979f8463 |
Python: Improve/Simplify the Assistant Agents (#10666)
### Motivation and Context
The current abstractions we have around the Semantic Kernel Assistant
Agents are considered to be "fully-wrapped." This is beneficial in that
SK provides a tight/complete abstraction over the agent; however, it
doesn't scale well when new features are added to the underlying APIs
(OpenAI) - it requires updates from SK to make each and every update. It
also adds a lot more complexity in terms of needing to handle everything
in SK, requires more code coverage, and chances for bugs to surface due
to these complexities.
> **NOTE:** this update is _breaking_. We're moving to simplify the
abstractions/APIs before we move Assistant Agents from **experimental**
to GA.
Similar to how the `AzureAIAgent` was created, we're moving to a
"less-wrapped" abstraction around the OpenAI Assistant v2 APIs. We do
have some "convenience methods" on the Agents, via class methods, to
configure things like the code interpreter tool and resource, file
search tool and resource, the clients required to interact with the
Assistants, as well as being able to easily configure structured
outputs, similar to how it is done with a ChatCompletion (either provide
the Pydantic model or the Python class).
To work with Assistant Agents now, it's as simple as:
```python
from semantic_kernel.agents.open_ai import AzureAssistantAgent
from semantic_kernel.functions import kernel_function
class MenuPlugin:
# Plugin code here using the @kernel_function decorator
# Create the client using Azure OpenAI resources and configuration
client, model = AzureAssistantAgent.setup_resources()
# Create the assistant definition
definition = await client.beta.assistants.create(
model=model,
instructions="Answer questions about the menu.",
name="Host",
)
agent = AzureAssistantAgent(
client=client,
definition=definition,
plugins=[MenuPlugin()], # The plugins can be passed in as a list to the constructor
)
# Note: plugins can also be configured on the Kernel and passed in as a parameter to the OpenAIAssistantAgent
# Define a thread and invoke the agent with the user input
thread = await agent.client.beta.threads.create()
```
**I will create a migration guide (issue) showing what needs to be
updated from the previous usage to this new pattern.**
<!-- 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
This PR provides the new abstractions for the
`AzureAssistantAgent`/`OpenAIAssistantAgent` classes.
- Updates underlying code
- Updates samples showing new patterns
- Updates unit tests
- Updates READMEs.
- Closes #10605
Samples will be updated accordingly to show new patterns.
<!-- 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
- [ ] I didn't break anyone 😄
|
||
|
|
d91c96d4e1 |
Python: resolving #10642 - public events fail to propagate (#10643)
### Motivation and Context Resolves #10642 -- failure of `KernelProcessEventVisibility.Public` events to propagate. ### Description First, `KernelProcessEvent` was configured to use enum values -- though throughout the code, `KernelProcessEvent.visibility` is compared as an enum. Second, when handling events emitted by a KernelProcessStep, any `Public` visibility events are/were passed through `LocalStep.scoped_event` (which modifies the event's namespace) *before* queueing up any matching edges on the source step. This change to the event namespace effectively prevents the event from propagating (since I don't know how we'd 'listen' for events on the local process handle from within the function that builds that very process...) Allowing `visibility` on `KernelProcessEvent` to be an enum, combined with an exchange in the order of processing event messages (matching event to edge _before_ re-emitting any events marked as 'Public') causes public events to propagate as expected. ### Contribution Checklist - [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 😄 |
||
|
|
534d8609e3 |
Python: Introducing AzureCosmosDBforMongoDB store and collection (#10609)
### Motivation and Context <!-- 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. --> Adds Azure Cosmos DB for MongoDB support using the new vector store model. Builds on the MongoDB Atlas integration, replaced the index creation and settings to make it work. Closes #6836 ### Description <!-- 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 😄 |
||
|
|
2984423aa0 |
Python: Add support for AutoGen's 0.2 ConversableAgent (#10607)
### Motivation and Context For those who use AutoGen's 0.2 `ConversableAgent`, we're providing support in Semantic Kernel to run this agent type. This assumes one will port their existing AG 0.2.X `ConversableAgent` code and run in Semantic Kernel. Note: as we move towards GA for our agent chat patterns, we are analyzing how to support AutoGen agents with a shared time. This PR does not provide support for the AG `ConversibleAgent` group chat patterns that exist in the 0.2.X package. <!-- 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 Add support and samples for the AG 0.2.X ConversableAgent. - Add unit test coverage. - Add samples and READMEs. - Closes #10407 <!-- 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 😄 --------- Co-authored-by: Chris <[email protected]> |
||
|
|
e36c08a32e |
Python: Bump Python version to 1.21.3 for a release. (#10617)
### Motivation and Context Bump Python version to 1.21.3 for a release. <!-- 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 Bump Python version to 1.21.3 for a release. <!-- 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 😄 |
||
|
|
68448b1427 |
Python: Fix kernel parameter metadata input type arg to call type_ (#10603)
### Motivation and Context To address a typing issue, we updated the kernel parameter metadata so that the input type argument now calls `type` (configured as an alias) rather than the model’s parameter `type_`. Previously, setting the alias did not update the underlying `type_` attribute, leaving it as `None`. As a result, when generating the JSON schema, the `parameter_type` was omitted, causing some customers who sent `KernelFunctionMetadata` to the OpenAI model to receive a 400 error due to a malformed schema. <!-- 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 Revert the change and add a unit test to make sure we check for the expected schema. <!-- 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 😄 |
||
|
|
374d8f91ce |
Python: filter improvements (#10588)
### Motivation and Context <!-- 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. --> Fixes some inconsistency in the filter setup between dotnet and python Adds a sample for how to use a filter to retry a prompt with a different model. Adds a sample for semantic caching Closes: #10572 #5924 #10595 ### Description <!-- 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 😄 --------- Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
2f8157f484 |
Python: Bump Python version to 1.21.2 for a release. (#10599)
### Motivation and Context Bump Python version to 1.21.2 for a release. <!-- 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 Bump Python version to 1.21.2 for a release. <!-- 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 😄 |
||
|
|
971a742384 |
Python: update GoogleConnector settings arg to search_api_key from api_key (#10560)
### Motivation and Context The `GoogleSearchSettings` used for the `GoogleConnector` class use `search_api_key` instead of `api_key`. <!-- 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 Fix the input argument, `search_api_key`, for the `GoogleConnector` class. <!-- 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 😄 |
||
|
|
5cad2864df |
Python: Fix Infinite Recursion in Hashing Logic by Tracking Visited Objects (#10598)
### Motivation and Context We encountered an issue where our hashing utility (`make_hashable(...)`) could enter an infinite recursion loop whenever it encountered cyclical references. This was particularly evident with Pydantic models that reference each other (or themselves), or with dictionaries/lists that recursively include a reference to an already-seen object. In such scenarios, the function continued to expand and re-expand the same objects indefinitely, triggering a RecursionError. <!-- 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 We introduced a visited dictionary in `make_hashable`. Before diving deeper into any object -- whether it’s a dict, a list, a set, a tuple, or a Pydantic model -- we record its id() in visited. The very next time we see that same object ID, we immediately return its already-computed placeholder or final representation, short-circuiting the cycle. - Fixes #10592 <!-- 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 😄 |
||
|
|
cd84e87798 |
Python: Bump Python version to 1.21.1 for a release. (#10539)
### Motivation and Context Bump Python version to 1.21.1 for a release. <!-- 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 Bump Python version to 1.21.1 for a release. <!-- 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 😄 |
||
|
|
76d101eafd |
Python: add AzureAIAgent client creation method. Handle user_agent. (#10538)
### Motivation and Context We weren't sending the user_agent as part of client creation for the AzureAIAgent. Create a convenience class method to create the AIProjectClient, which handles creating the user_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 This PR: - adds a class method to create the AIProjectClient as part of AzureAIAgent. - handles configuring the user_agent. - fixes a check where annotation content indices might not be present - adds `/.default` to default entra scope - adds unit tests - closes #10527 - closes #10520 <!-- 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 😄 |
||
|
|
a03c5d6fdc |
Python: removes AWS "us." region prefix from model id (#10329)
### Motivation and Context relates to this [issue](https://github.com/microsoft/semantic-kernel/issues/10238). <!-- 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 The current implementation of `bedrock_model_provider.py` is hard coded to return the zeroth element when splitting `model_id` on (`.`) periods. However this will return an incorrect name for the provider when working with an [inference profile](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles.html) since the `model_id` will contain the AWS region in the ID. For example, a `model_id` can be `us.meta.llama3-XXX:0` and the call `to_model_provider` will incorrectly try to look for a `us` model. This error is thrown when we are selecting an LLM model using an AWS inference profile. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> I have made a change to the `to_model_provider` class method in the `bedrock_model_provider.py` script that checks for a region prefix and then strips it. I have not tested this against all AWS regions. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] 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 - [ ] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 --------- Co-authored-by: Tao Chen <[email protected]> Co-authored-by: Chris <[email protected]> |
||
|
|
784f13e400 |
Python: Fix Chat History Agent format instructions regression. (#10512)
### Motivation and Context The chat history agent templating was inadvertently broken. This PR restores the functionality to be able to use templating with a Chat Completion 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 Fix the templating for a Chat Completion Agent. Add unit tests for more coverage. - Fix a unit test fixture that was annotated to return an AsyncMock, but it's actually returning an async generator function. <!-- 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 😄 |
||
|
|
892c2066da |
Python: Adding Crew.AI as a plugin. (#10474)
### Motivation and Context Adding Crew.AI as a plugin to the Semantic Kernel will allow users to leverage the capabilities of Crew.AI in app. This plugin works with Crews that have been deployed to the Crew.AI Enterprise service. ### Description Adding Crew.AI as a plugin to the Semantic Kernel will allow users to leverage the capabilities of Crew.AI in app. This plugin works with Crews that have been deployed to the Crew.AI Enterprise service. The plugin functionality has been manually verified with the concept samples. Other tests will come in the next update. ### 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 😄 --------- Co-authored-by: Ben Thomas <[email protected]> Co-authored-by: Eduard van Valkenburg <[email protected]> |
||
|
|
9c9b03b35f |
Python: Bump Python version to 1.21.0 for a release. (#10500)
### Motivation and Context Bump Python version to 1.21.0 for a release. <!-- 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 Bump Python version to 1.21.0 for a release. <!-- 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 😄 |
||
|
|
56bd3945c4 |
Python: Add Azure AI Agent AI Search Sample. Update memory sample with README. (#10497)
### Motivation and Context To showcase other ways to interact with Azure AI Agents, we're adding a sample that leverages the Azure AI Search tool. <!-- 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 Adds the Azure AI Agent with AI Search sample. - Includes README and hopefully enough information to get started. Assumes the user is able to set up the hotels-sample-index with the proper data model fields (outlined in SK). - Updates the memory samples with a README to help make the usage more clear - Update the default termination strategy max iterations from 1 to 5. <!-- 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 😄 |
||
|
|
cbfd7e9330 |
Python: improved content inits, added ndarray support for binary content and small fixes to defaults (#10469)
### Motivation and Context
<!-- 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.
-->
This PR adds support for ndarray's as the content carrier for all binary
content types (binary, image, audio) as that is more optimized for
larger content.
It also does some fixes to the initialization of those content types and
the underlying data uri type.
Also some fixes for unspecified default param in pydantic Field,
language servers do not recognize `Field("default value")` as having a
default, so changed those occurances to `Field(default="default value")`
### Description
<!-- 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 😄
|
||
|
|
7bdf55028c |
Python: experimental py3.13 support (#10276)
### Motivation and Context <!-- 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. --> Some small fixes in uv setup within actions Added experimental unit tests runs for py3.13 First typing improvement from pyright and pyright config. ### Description <!-- 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 😄 |
||
|
|
9d5ad78fb2 |
Python: set openai package to newer version and removed default value of parallel tool calls (#10502)
### Motivation and Context <!-- 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. --> We noticed that the openai package dependency spec was off and did not update that when present to the newest version, fixed now. Also we mistakenly had a default value for parallel_tool_calls in our prompt executions settings, as with other settings we do not maintain a default value if the API has a default and in this case having that parameter when calling a reasoning model threw an error, fixed here. ### Description <!-- 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 😄 |
||
|
|
8f4efa5d10 |
Python: Allow for factory callbacks in the process framework (#10451)
### Motivation and Context
In the current Python process framework, in runtimes like Dapr, there is
no easy way to pass complex (unserializable) dependencies to a step --
this includes things like a ChatCompletion service or an agent of type
ChatCompletionAgent.
Similar to how the kernel dependency was propagated to the step_actor or
process_actor, we're introducing the ability to specify a factory
callback that will be called as the step is instantiated. The factory is
created, if specified via the optional kwarg when adding a step to the
process builder like:
```python
myBStep = process.add_step(step_type=BStep, factory_function=bstep_factory)
```
The `bstep_factory` looks like (along with its corresponding step)
```python
async def bstep_factory():
"""Creates a BStep instance with ephemeral references like ChatCompletionAgent."""
kernel = Kernel()
kernel.add_service(AzureChatCompletion())
agent = ChatCompletionAgent(kernel=kernel, name="echo", instructions="repeat the input back")
step_instance = BStep()
step_instance.agent = agent
return step_instance
class BStep(KernelProcessStep):
"""A sample BStep that optionally holds a ChatCompletionAgent.
By design, the agent is ephemeral (not stored in state).
"""
# Ephemeral references won't be persisted to Dapr
# because we do not place them in a step state model.
# We'll set this in the factory function:
agent: ChatCompletionAgent | None = None
@kernel_function(name="do_it")
async def do_it(self, context: KernelProcessStepContext):
print("##### BStep ran (do_it).")
await asyncio.sleep(2)
if self.agent:
history = ChatHistory()
history.add_user_message("Hello from BStep!")
async for msg in self.agent.invoke(history):
print(f"BStep got agent response: {msg.content}")
await context.emit_event(process_event="BStepDone", data="I did B")
```
Although this isn't explicitly necessary with the local runtime, the
factory callback will also work, if desired.
<!-- 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
Adds the ability to specify a factory callback for a step in the process
framework.
- Adjusts the Dapr FastAPI demo sample to show how one can include a
dependency like a `ChatCompletionAgent` and use the factory callback for
`BStep`. Although the output from the agent isn't needed, it
demonstrates the capability to handle these types of dependencies while
running Dapr.
- Adds unit tests
- Closes #10409
<!-- 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 😄
|
||
|
|
c3ab713322 |
Python: Add support for Azure AI Agent Service (#10414)
### Motivation and Context Azure AI Agents are a managed offering, and are built on top of the OpenAI assistant v2 APIs. Until now we have not had support for them in SK Python. This PR adds support for Azure AI Agents in SK Python. The current abstractions allow one to run managed Azure AI Agents using SK constructs as is demonstrated via the getting started samples and/or the `azure_ai_agent` concept code samples. The developer must first follow the required Azure AI Agent deployment steps, and bring their connection string as well as their model deployment name. <!-- 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 Add support for Azure AI Agent Service in SK - Add sample code - Add unit tests - Restructures the `getting_started_with_agents` samples to move the respective agent code into folders like `chat_completion`, `azure_ai_agent`, etc. Updates the README as well. - Closes #10187 **TODO**: add more test coverage either in this PR, or a subsequent one. <!-- 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 😄 |
||
|
|
3461ed6d4d |
Python: Fixes to Cosmos DB NoSQL query syntax generation. (#10373)
### Motivation and Context Review information: 1. Why is this change required? There were several SQL query syntax generation issue for both text_search() and vectorized_search() methods 2. What problem does it solve? a) In `_build_where_clauses_from_filter()` the WHERE clause creation did not quote string values and did not properly handle list[] data model attribures, b) for `_build_vector_query()` method the WHERE clause was placed after the ORDER BY clause causing query syntax errors, c) for `_build_search_text_query()` method the data_model_definition items were not being interrogated, thus added `CONTAINS()` in the WHERE clause. 3. What scenario does it contribute to? The ability to use Azure Cosmos DB NoSQL for `text_search()` and `vectorized_search()`. 4. Issue resolution: #10368 ### Description The errors noted in the Issue and the bug fixes noted above correct the SQL query syntax generation for the `text_search()` and `vectorized_search()` methods and now produce accurate results for performing both types of queries with and without filters (aka WHERE clause). ### Contribution Checklist - ✅ The code builds clean without any errors or warnings - ✅ 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 - ✅ All unit tests pass, and I have added new tests where possible - 🙏 I didn't break anyone 😄 --------- Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
c445f5ce51 |
Python: Implement MongoDB Atlas store (#10177)
Implement a new version of the MongoDB Atlas Memory Connector with MongoDBAtlasStore and MongoDBAtlasCollection classes. * **MongoDBAtlasStore**: - Add `python/semantic_kernel/connectors/memory/mongodb_atlas/mongodb_atlas_store.py` to implement the MongoDBAtlasStore class. - Add unit tests in `python/tests/unit/connectors/memory/mongodb_atlas/test_mongodb_atlas_store.py` to test the MongoDBAtlasStore class. * **MongoDBAtlasCollection**: - Add `python/semantic_kernel/connectors/memory/mongodb_atlas/mongodb_atlas_collection.py` to implement the MongoDBAtlasCollection class. - Add unit tests in `python/tests/unit/connectors/memory/mongodb_atlas/test_mongodb_atlas_collection.py` to test the MongoDBAtlasCollection class. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/microsoft/semantic-kernel/pull/10177?shareId=e9e73180-0fff-4e60-bbb5-5c3493b27e61). closes #6764 --------- Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
35641b7213 |
Python: Allow AI Inference connector to use Azure AI Services resource (#10427)
### Motivation and Context <!-- 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. --> Addresses: https://github.com/microsoft/semantic-kernel/issues/10339 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Users can now use the Azure AI Services resource with the AI Inference connector. ### 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 😄 Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
4d2b2be2d0 |
Python: Bug: Type Definition Error ImageContent (#10395)
### Motivation and Context
1. This change is required because IDE type-checking throws an error
when manually passing values (e.g., Base64 strings) to ImageContent’s
constructor.
2. It fixes the missing argument definitions (data, data_uri,
data_format, mime_type), which caused the type error in IDEs like VS
Code.
3. It resolves the issue reported where users observed IDE-type errors
despite code functioning at runtime.
### Description
• Added explicit type definitions (data, data_uri, data_format,
mime_type) in the ImageContent class constructor and fields.
• Updated the docstring and __init__ to reflect the new arguments.
• Ensured the code maintains backward compatibility by preserving
existing methods like from_image_file.
• Verified that type-checking in major Python IDEs now passes without
warnings.
### Example
```
import asyncio
import base64
from semantic_kernel.connectors.ai.open_ai.services.azure_chat_completion import AzureChatCompletion,
from semantic_kernel.contents import AuthorRole, ChatHistory, ImageContent
from semantic_kernel.contents.chat_message_content import ChatMessageContent
from semantic_kernel.contents.text_content import TextContent
async def main():
service = AzureChatCompletion(
api_key="************************",
deployment_name="gpt-4o-mini",
endpoint="https://************************.openai.azure.com",
api_version="2024-12-01-preview",
)
chat_history = ChatHistory()
# example of base64 image
# or `ImageContent.from_image_file`
with open("weather_icon.png", "rb") as image_file:
b64_string = base64.b64encode(image_file.read()).decode("utf-8")
chat_history.add_message(
ChatMessageContent(
role=AuthorRole.USER,
items=[
ImageContent(
data_uri=f"data:image/png;base64,{b64_string}",
data_format="base64",
mime_type="image/png",
),
TextContent(text="what is the weather"),
],
)
)
response = await service.get_chat_message_contents(
chat_history=chat_history,
settings=service.get_prompt_execution_settings_class()(),
)
print(response[0].content)
# >> The icon you provided typically represents sunny or clear weather.
# >> If you need specific weather information for a location,
# >> please provide the location or check a reliable weather service for the latest updates.
asyncio.run(main())
```
### Contribution Checklist
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the SK Contribution Guidelines and the
pre-submission formatting script raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn’t break anyone ☺
---------
Co-authored-by: Tao Chen <[email protected]>
Co-authored-by: Evan Mattson <[email protected]>
|
||
|
|
0a8c4d8afa |
Python: Update agent tracing span name and attributes (#10398)
### Motivation and Context <!-- 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. --> Python parity with this PR: https://github.com/microsoft/semantic-kernel/pull/10387 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Update agent invoke span name and add attributes. This is a breaking change: users who are currently relying on the span name in their queries will need to update their queries to use the new name or match new patterns. This is an experimental feature so breaking changes are expected. ### 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 - [ ] I didn't break anyone 😄 |
||
|
|
2a6cdd81a7 |
Python: Add unit tests for Bedrock agent integration (#10362)
### Motivation and Context Add unit tests for Bedrock agent integration in Semantic Kernel Python. <!-- 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? 3. What problem does it solve? 5. What scenario does it contribute to? 7. If it fixes an open issue, please link to the issue here. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Code coverage for Bedrock agent related implementations reached 100% except for the `bedrock_agent.py` file and `bedrock_agent_base.py` file, which are at 82% and 95% respectively. ### 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 😄 For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/microsoft/semantic-kernel/pull/10362?shareId=f83b0466-6d2b-4639-88c8-23229aa2694c). --------- Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
7c10d5f7f5 |
Python: Fixed Python bug when enable_json_response=True (#10376)
### Description Fixed Python bug when enable_json_response=True - Closes #10375 ### Contribution Checklist - [Y] The code builds clean without any errors or warnings - [Y] 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 - [Y] All unit tests pass, and I have added new tests where possible - [Y] I didn't break anyone 😄 Fixes #10375 --------- Co-authored-by: Adit Sheth <[email protected]> Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
1b85aa902c |
Python: Fix OpenAI assistant metadata type (#10383)
### Motivation and Context <!-- 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. --> OpenAI Python SDK released 1.61.0 that contained a change which broke code. Changes in the release: https://github.com/openai/openai-python/commit/12b87a4a1e6cb071a6b063d089585dec56a5d534 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> This pull request includes several changes to the `metadata` type and the handling of `metadata` in various files, as well as updates to test files to reflect these changes. The most important changes include modifying the `metadata` type from `dict[str, Any]` to `dict[str, str]` and updating the tests to use `json.dumps` for `metadata` values. Note: this is a breaking change because if users are not passing in the expected type before, they will need to update their code to pass in the correct type now. ### 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 - [ ] I didn't break anyone 😄 |
||
|
|
7789c5fe55 |
Python: Bedrock agent (#10307)
### Motivation and Context <!-- 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. --> Address https://github.com/microsoft/semantic-kernel/issues/10284 Integration of AWS Bedrock agent to SK Python ### Description 1. Implementation of Bedrock agent in SK (essentially an agent connector to the Bedrock agent service). 2. A dedicated channel that works with Bedrock agents. 3. Samples on how to use Bedrock agents. Unit and integration tests will be included in another PR to prevent this PR from becoming too big. <!-- 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 😄 |
||
|
|
10c1dfecb7 |
Python: [python] Bug fix 10340 (#10341)
### Motivation and Context See #10340 ### Description Implement a similar approach as is done in `process_step_edge_builder.py`, which supports function_name when building the target function. ### Contribution Checklist - [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 😄 (well, we're still passing/xpass/xfail the same as main is) --------- Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
605db09bce |
Python: intro allowed content types in chat history channel receive. Add mixed chat image sample. (#10347)
### Motivation and Context During a group chat, any file reference content created by an assistant agent, doesn't need to be communicated to a chat completion agent. Filter these types out and only include other types, like text, if available. <!-- 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 This PR: - Adds a mixed chat image sample to have an assistant agent generate an image, along with text, and call the chat completion agent successfully with only the allowed types (like text). - Adds a unit test to exercise the same behavior. - Closes #10317 <!-- 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 😄 |
||
|
|
3724e245be |
Python: Add vector search to Postgres connector (#10213)
### Motivation and Context Following up on #8951, this PR adds an implementation of `VectorSearchBase` to `PostgresCollection`. This implementation provides vectorized search and does not implement text search or vectorizable text search. Unit and integration tests are added, and the `python/samples/getting_started/third_party/postgres-memory.ipynb` notebook was expanded to include vector search in the example. ### Contribution Checklist - [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 😄 |
||
|
|
d0157424b4 |
Python: Bump Python version to 1.20.0 for a release. (#10331)
### Motivation and Context Bump Python version to 1.20.0 for a release. <!-- 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 Bump Python version to 1.20.0 for a release. <!-- 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 😄 |
||
|
|
44034ebd23 |
Python: Improve hashing of cmc and scmc items. Add tests. (#10332)
### Motivation and Context We have some content types that can't be hashed as-is. This PR makes sure that if there are unhashable types, that we turn them into hashable types. Add unit tests to exercise the scenarios. <!-- 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 <!-- 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 😄 |
||
|
|
ec9b980e30 |
Python: improve agent samples and chat history handling (#10301)
### Motivation and Context <!-- 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. --> When passing the same object to `agent.reduce_history` as is present in the `history_reducer` attribute of the agent that the function doesn't accurately behave. This fixes that. Also updates the sample to be a bit more concise. Also fixes the way the single_dispatch is setup in ChatHistory. Also ensures system/developer messages are not reduced away as that might impact performance. The `reduce_history` method was removed from the agent base class, in favor of having the caller manage the change history and reduction as needed. The `reduce_history` was added to the agent group chat, as the chat history is managed internally as agents are invoked. ### Description <!-- 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 😄 --------- Co-authored-by: Evan Mattson <[email protected]> Co-authored-by: Evan Mattson <[email protected]> |