-
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
#68 OpenApi Endpoint Properties & Missing ChatEndpoint #69
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace OpenAI_API | ||
{ | ||
/// <summary> | ||
/// Represents authentication to the OpenAPI API endpoint | ||
/// </summary> | ||
public interface IAPIAuthentication | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion POCO's (Plain old C# objects) shouldn't have an Interface. However this isn't a poco as it's having a method within it to validate the key. Personally i'd extract the Validate logic to a service which can validate stuff (for now the api-key). |
||
{ | ||
/// <summary> | ||
/// The API key, required to access the API endpoint. | ||
/// </summary> | ||
string ApiKey { get; set; } | ||
|
||
/// <summary> | ||
/// The Organization ID to count API requests against. This can be found at https://beta.openai.com/account/org-settings. | ||
/// </summary> | ||
string OpenAIOrganization { get; set; } | ||
|
||
/// <summary> | ||
/// Tests the api key against the OpenAI API, to ensure it is valid. This hits the models endpoint so should not be charged for usage. | ||
/// </summary> | ||
/// <returns><see langword="true"/> if the api key is valid, or <see langword="false"/> if empty or not accepted by the OpenAI API.</returns> | ||
Task<bool> ValidateAPIKey(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementation of this method does a couple of things. Maybe extract that logic to definitive classes which each do their own thing? Also this method should end in |
||
} | ||
} |
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
APIAuthentication
is not meant to be inherited please add the keywordsealed
so it's explicitly defined. This comes with some performance benefits: see this PR from the dotnet runtime: dotnet/runtime#49944