Skip to content
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

.Net: Add File Id Reference Handling to Experimental Agent Package so that User Messages can be related to file Ids in OpenAI Storage #5110

Merged
merged 18 commits into from
Mar 6, 2024

Conversation

Ryan-Britton
Copy link
Contributor

Motivation and Context

added the ability to reference file ids when creating a user message in the experimental agents package

image

Description

added a nullable array of file ids as a parameter on the AddUserMessageAsync and InvokeAsync methods so that it did not break existing tests/examples. Added the file_ids property to the POST payload to the OpenAI Assistants API.

Contribution Checklist

The `AddUserMessageAsync` and `InvokeAsync` methods in both `ChatThread.cs` and `IAgentThread.cs` have been modified to accept an array of file IDs. This update allows users to reference up to 10 files in their message. Additionally, an unused `AddUserMessageAsync` method without the file ID parameter has been removed from `ChatThread.cs` for cleaner code.
A new optional parameter, fileIds, has been added to the InvokeAsync method in IAgentExtensions and the corresponding private AskAsync method in Agent.cs. This array can handle up to 10 file ids to reference for the message. Changes were applied where these methods are called, incorporating the fileIds parameter.
@Ryan-Britton Ryan-Britton requested a review from a team as a code owner February 21, 2024 16:02
@markwallace-microsoft markwallace-microsoft added the .NET Issue or Pull requests regarding .NET code label Feb 21, 2024
@github-actions github-actions bot changed the title Add File Id Reference Handling to Experimental Agent Package so that User Messages can be related to file Ids in OpenAI Storage .Net: Add File Id Reference Handling to Experimental Agent Package so that User Messages can be related to file Ids in OpenAI Storage Feb 21, 2024
@Ryan-Britton
Copy link
Contributor Author

@Ryan-Britton please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@Ryan-Britton please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree [company="Wet Ink Corporation"]
@microsoft-github-policy-service agree
@microsoft-github-policy-service agree company="Microsoft"

@Ryan-Britton
Copy link
Contributor Author

@microsoft-github-policy-service agree [company="Wet Ink Corporation"]

@Ryan-Britton
Copy link
Contributor Author

@microsoft-github-policy-service agree

@crickman
Copy link
Contributor

crickman commented Feb 26, 2024

@Ryan-Britton - This looks good. Can you also look at this change I published last week: #5113? (I think these are related)

(Updated: Actually, I got approval and merged to main. Updated your change and reviewing shortly.)

@Ryan-Britton
Copy link
Contributor Author

they're definitely related - looking at your changes, I see that you're using the file_id paramter for file references on chat messages in #5113 - but in your use case it seems to be looking specifically at images (where I was using the file_ids parameter to refer to any file type in OpenAI storage as a context for the chat). My thought during the quick review was that the naming of some of your changes to align it "image types" specifically, may obfuscate the fact that file_ids can point at non-image types as well?

@crickman
Copy link
Contributor

crickman commented Mar 4, 2024

Made a couple small tweaks, including adding a mode to Example75_AgentTools that pass the fileId via the thread.

Can you take a look?

@crickman crickman self-requested a review March 4, 2024 21:49
@crickman crickman enabled auto-merge March 6, 2024 16:19
@crickman crickman added this pull request to the merge queue Mar 6, 2024
@crickman crickman removed this pull request from the merge queue due to a manual request Mar 6, 2024
@crickman crickman enabled auto-merge March 6, 2024 17:05
@crickman crickman self-requested a review March 6, 2024 18:23
@crickman crickman requested a review from glahaye March 6, 2024 20:29
@crickman crickman added this pull request to the merge queue Mar 6, 2024
Merged via the queue into microsoft:main with commit d46393d Mar 6, 2024
18 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Mar 14, 2024
### 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.
-->

Noticed that agent examples failing due to resourcing and configuration
delta. As part of this discovered agent as plugin regression from
community contribution.

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

- Include agent templates as embedded resources
- Switch from `TestConfiguration.AzureOpenAI.DeploymentName` to
`TestConfiguration.AzureOpenAI.ChatDeploymentName` in
`Example72_AgentCollaboration`
- Remove `fileIds` from `Agent.AskAsync` (not utilized and resulting in
failed run creation) -
#5110
- Eliminated user-message duplication
- Added comments to `ChatMessageType`


![image](https://github.com/microsoft/semantic-kernel/assets/66376200/0750a803-d567-448c-a650-144e009307cd)

### 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 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Issue or Pull requests regarding .NET code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants