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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Fix OpenAI connector compatibility #5338

Merged
merged 5 commits into from
Mar 11, 2024

Conversation

JadynWong
Copy link
Contributor

@JadynWong JadynWong commented Mar 6, 2024

Motivation and Context

Fix #5337

Description

Improved openai connector compatibility.
When the user message has only one TextContent, serialize the user message as a string. Otherwise, serialize the user message as an array.

Contribution Checklist

@JadynWong JadynWong requested a review from a team as a code owner March 6, 2024 11:11
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Mar 6, 2024
@RogerBarreto
Copy link
Member

@SergeyMenshykh I believe this change is not what we intent, right? Our Content should map to the first Text item of a ChatMessage,

@JadynWong, can you provide the scenario on what is the current problem and what this solves that the actual impl doesnt?

@JadynWong
Copy link
Contributor Author

@RogerBarreto, I wrote it in #5337. The main reason for this is that we use openai connectors through third party openai compatible endpoints. They currently do not support arrays of content. PR #5088 changes prevented the use of these compatibility endpoints.

@xuzeyu91
Copy link

xuzeyu91 commented Mar 6, 2024

@SergeyMenshykh I believe this change is not what we intent, right? Our Content should map to the first Text item of a ChatMessage,

@JadynWong, can you provide the scenario on what is the current problem and what this solves that the actual impl doesnt?

Because Semantickernel currently mainly supports OpenAI and Azure OpenAI,
there are many other LLMs, and in order to enable them to also use the semantic kernel, we usually package a model connector to convert other LLMs to the same format as OpenAI,for example https://localai.io/ . However, this change may not be very friendly to other models.

@markwallace-microsoft markwallace-microsoft added this pull request to the merge queue Mar 11, 2024
Merged via the queue into microsoft:main with commit e585440 Mar 11, 2024
18 checks passed
@JadynWong JadynWong deleted the jadyn/openai-content branch March 11, 2024 15:01
justindhillon pushed a commit to justindhillon/semantic-kernel that referenced this pull request Mar 11, 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.
-->
Fix microsoft#5337

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Improved openai connector compatibility. 
When the user message has only one TextContent, serialize the user
message as a string. Otherwise, serialize the user message as an array.
### 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: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

.Net: OpenAI connector is not compatible with third-party openai compatible endpoints
6 participants