-
Notifications
You must be signed in to change notification settings - Fork 430
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
Add OpenAI component #5621
Add OpenAI component #5621
Conversation
# Conflicts: # Aspire.sln # src/Components/Aspire.Azure.AI.OpenAI/ConfigurationSchema.json
Is there also work to enable |
} | ||
``` | ||
|
||
To learn how to use the `OpenAIClient` class refer to [Using the OpenAIClient class](https://github.com/openai/openai-dotnet?tab=readme-ov-file#using-the-openaiclient-class). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How permanent is this link? Is there an official doc site we can link to instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just found a new page in docs, updating. Nope, couldn't find anything more official.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe @AngelosP would be the best person to share what are considered official docs for this library.
/// <summary> | ||
/// The settings relevant to accessing OpenAI. | ||
/// </summary> | ||
public sealed class OpenAISettings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KrzysztofCwalina, any concerns about adding this as a public type in this namespace? I know you and I had discussed potentially putting such types in the SCM-based client namespaces themselves.
Or, @eerhardt, could you help us understand established precedents around these settings types for Aspire more broadly? If we e.g. wanted to enable injection of an OpenAI client in a DI container outside the context of Aspire, would we want this type to live in a non-Aspire namespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These settings types are used in Aspire to drive what and how services are registered in DI. This is standard in Aspire, even components have it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we wanted to also add a type called OpenAISettings
in the OpenAI
client namespace, would that be frowned upon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't be great, but it would be possible. The namespace can disambiguate.
For Aspire, the pattern is {NameOfLibrary}Settings
in the Aspire.{NameOfLibrary}
namespace.
See
/// <summary> | |
/// Provides the client configuration settings for connecting to a RabbitMQ message broker. | |
/// </summary> | |
public sealed class RabbitMQClientSettings |
aspire/src/Components/Aspire.StackExchange.Redis/StackExchangeRedisSettings.cs
Lines 6 to 9 in 0490bcb
/// <summary> | |
/// Provides the client configuration settings for connecting to a Redis server. | |
/// </summary> | |
public sealed class StackExchangeRedisSettings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, as long as we can keep that an an option in our back pocket, I have no concerns.
|
||
## AppHost extensions | ||
|
||
There is no specific AppHost extension corresponding to the OpenAI integration. Instead a connection string resource can be registered: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my learning -- what is an AppHost extension and is this something we would want to have a story for in the .NET ecosystem to support better ease of use for OpenAI? Mostly just curious on this piece.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An AppHost extension is a package that helps provision or describe the server part of the integration. For instance with Azure.AI.OpenAI there is a server resource that can be registered, will AI models too, such that we can provision the resource when the app is deployed. With OpenAI there is no such thing we can deploy, so we only declare a connection string, like a logical representation of this resource. Ultimately we could have a component that provides Ollama services for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! My comment here doesn't block this PR in any way, but I'm interested in understanding why we have one for Azure.AI.OpenAI and not OpenAI? If there are pieces needed uniquely for SCM-based clients I'd be interested to understand the gaps there and if pieces are needed from SCM to address those gaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we have one for Azure.AI.OpenAI and not OpenAI?
Because you can provision an Azure OpenAI service (using bicep). That's what the "AppHost" extension will do.
You can't provision an OpenAI service. You need to sign up on their website.
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
# Conflicts: # src/Components/Aspire.OpenAI/README.md
/// <summary> | ||
/// The settings relevant to accessing OpenAI. | ||
/// </summary> | ||
public sealed class OpenAISettings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't be great, but it would be possible. The namespace can disambiguate.
For Aspire, the pattern is {NameOfLibrary}Settings
in the Aspire.{NameOfLibrary}
namespace.
See
/// <summary> | |
/// Provides the client configuration settings for connecting to a RabbitMQ message broker. | |
/// </summary> | |
public sealed class RabbitMQClientSettings |
aspire/src/Components/Aspire.StackExchange.Redis/StackExchangeRedisSettings.cs
Lines 6 to 9 in 0490bcb
/// <summary> | |
/// Provides the client configuration settings for connecting to a Redis server. | |
/// </summary> | |
public sealed class StackExchangeRedisSettings |
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion> | ||
<PackageTags>ai openai</PackageTags> | ||
<Description>A client for OpenAI that integrates with Aspire, including metrics, logging and telemetry.</Description> | ||
<PackageIconFullPath>$(SharedDir)OpenAI_256x.png</PackageIconFullPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DamianEdwards - you've handled this for other integrations. Can you help here?
Failing on unrelated cosmos tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
host.Services.GetRequiredKeyedService<OpenAIClient>("openai") : | ||
host.Services.GetRequiredService<OpenAIClient>(); | ||
|
||
Assert.NotNull(client); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assert on something more than "not null"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant, can we assert something like the connection string or URI is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my initial thought too but I couldn't find it in the model, do you know if it's somewhere? I didn't dig super deep, maybe I missed it. Will check again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you fine with private reflection in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, let's just live with what we have. If we mis-configured it, we will know because things won't work.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Contributes to #4567
Microsoft Reviewers: Open in CodeFlow