Skip to content

Commit d30ead8

Browse files
authored
Merge pull request #104 from babrekel/interfaces
Use interface instead of implementation in Endpoint properties. Fixes #68
2 parents e585eb2 + 4395043 commit d30ead8

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

OpenAI_API/IOpenAIAPI.cs

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
using OpenAI_API.Chat;
12
using OpenAI_API.Completions;
23
using OpenAI_API.Embedding;
34
using OpenAI_API.Files;
5+
using OpenAI_API.Images;
46
using OpenAI_API.Models;
7+
using OpenAI_API.Moderation;
58

69
namespace OpenAI_API
710
{
@@ -27,24 +30,39 @@ public interface IOpenAIAPI
2730
/// </summary>
2831
APIAuthentication Auth { get; set; }
2932

33+
/// <summary>
34+
/// Text generation in the form of chat messages. This interacts with the ChatGPT API.
35+
/// </summary>
36+
IChatEndpoint Chat { get; }
37+
38+
/// <summary>
39+
/// Classify text against the OpenAI Content Policy.
40+
/// </summary>
41+
IModerationEndpoint Moderation { get; }
42+
3043
/// <summary>
3144
/// 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).
3245
/// </summary>
33-
CompletionEndpoint Completions { get; }
46+
ICompletionEndpoint Completions { get; }
3447

3548
/// <summary>
3649
/// 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.
3750
/// </summary>
38-
EmbeddingEndpoint Embeddings { get; }
51+
IEmbeddingEndpoint Embeddings { get; }
3952

4053
/// <summary>
4154
/// The API endpoint for querying available Engines/models
4255
/// </summary>
43-
ModelsEndpoint Models { get; }
56+
IModelsEndpoint Models { get; }
4457

4558
/// <summary>
4659
/// The API lets you do operations with files. You can upload, delete or retrieve files. Files can be used for fine-tuning, search, etc.
4760
/// </summary>
48-
FilesEndpoint Files { get; }
61+
IFilesEndpoint Files { get; }
62+
63+
/// <summary>
64+
/// The API lets you do operations with images. You can Given a prompt and/or an input image, the model will generate a new image.
65+
/// </summary>
66+
IImageGenerationEndpoint ImageGenerations { get; }
4967
}
5068
}

OpenAI_API/OpenAIAPI.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -70,36 +70,36 @@ public static OpenAIAPI ForAzure(string YourResourceName, string deploymentId, A
7070
/// <summary>
7171
/// 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).
7272
/// </summary>
73-
public CompletionEndpoint Completions { get; }
73+
public ICompletionEndpoint Completions { get; }
7474

7575
/// <summary>
7676
/// 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.
7777
/// </summary>
78-
public EmbeddingEndpoint Embeddings { get; }
78+
public IEmbeddingEndpoint Embeddings { get; }
7979

8080
/// <summary>
8181
/// Text generation in the form of chat messages. This interacts with the ChatGPT API.
8282
/// </summary>
83-
public ChatEndpoint Chat { get; }
83+
public IChatEndpoint Chat { get; }
8484

8585
/// <summary>
8686
/// Classify text against the OpenAI Content Policy.
8787
/// </summary>
88-
public ModerationEndpoint Moderation { get; }
88+
public IModerationEndpoint Moderation { get; }
8989

9090
/// <summary>
9191
/// The API endpoint for querying available Engines/models
9292
/// </summary>
93-
public ModelsEndpoint Models { get; }
93+
public IModelsEndpoint Models { get; }
9494

9595
/// <summary>
9696
/// The API lets you do operations with files. You can upload, delete or retrieve files. Files can be used for fine-tuning, search, etc.
9797
/// </summary>
98-
public FilesEndpoint Files { get; }
98+
public IFilesEndpoint Files { get; }
9999

100100
/// <summary>
101-
/// The API lets you do operations with images. You can Given a prompt and/or an input image, the model will generate a new image.
101+
/// The API lets you do operations with images. Given a prompt and/or an input image, the model will generate a new image.
102102
/// </summary>
103-
public ImageGenerationEndpoint ImageGenerations { get; }
103+
public IImageGenerationEndpoint ImageGenerations { get; }
104104
}
105105
}

0 commit comments

Comments
 (0)