You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: OpenAI_API/OpenAIAPI.cs
+38-13Lines changed: 38 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -20,24 +20,49 @@ public class OpenAIAPI: IOpenAI
20
20
/// <summary>The HTTP client configured with the authentication headers.</summary>
21
21
internalHttpClientClient{get;}
22
22
23
+
privateOpenAIAPI()
24
+
{
25
+
this.Completions=newCompletionEndpoint(this);
26
+
this.Models=newModelsEndpoint(this);
27
+
this.Files=newFilesEndpoint(this);
28
+
this.Embeddings=newEmbeddingEndpoint(this);
29
+
}
30
+
23
31
/// <summary>
24
32
/// Creates a new entry point to the OpenAPI API, handling auth and allowing access to the various API endpoints
25
33
/// </summary>
26
34
/// <param name="httpClient">The HTTP client configured with the authentication headers.</param>
27
-
publicOpenAIAPI(
28
-
HttpClienthttpClient)
29
-
{
30
-
this.Client=httpClient;
31
-
this.Completions=newCompletionEndpoint(this);
32
-
this.Models=newModelsEndpoint(this);
33
-
this.Files=newFilesEndpoint(this);
34
-
this.Embeddings=newEmbeddingEndpoint(this);
35
-
}
35
+
publicOpenAIAPI(HttpClienthttpClient):this()=>
36
+
this.Client=httpClient;
36
37
37
-
/// <summary>
38
-
/// Text generation is the core function of the API. You give the API a prompt, and it generates a completion. The way you “program” the API to do a task is by simply describing the task in plain english or providing a few written examples. This simple approach works for a wide range of use cases, including summarization, translation, grammar correction, question answering, chatbots, composing emails, and much more (see the prompt library for inspiration).
39
-
/// </summary>
40
-
publicCompletionEndpointCompletions{get;}
38
+
/// <summary>
39
+
/// Creates a new entry point to the OpenAPI API, handling auth and allowing access to the various API endpoints
40
+
/// </summary>
41
+
/// <param name="auth">The authentication details for the API</param>
42
+
[Obsolete("""
43
+
This constructor will generate a new HTTP client every time it is called.
44
+
Do not use this in scenarios where multiple instances of the API are required.
45
+
This is provided for backwards compatibility, use .NET Dependency Injection instead.
/// Text generation is the core function of the API. You give the API a prompt, and it generates a completion. The way you “program” the API to do a task is by simply describing the task in plain english or providing a few written examples. This simple approach works for a wide range of use cases, including summarization, translation, grammar correction, question answering, chatbots, composing emails, and much more (see the prompt library for inspiration).
64
+
/// </summary>
65
+
publicCompletionEndpointCompletions{get;}
41
66
42
67
/// <summary>
43
68
/// The API lets you transform text into a vector (list) of floating point numbers. The distance between two vectors measures their relatedness. Small distances suggest high relatedness and large distances suggest low relatedness.
0 commit comments