-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLocalOpenAiClient.cs
More file actions
40 lines (29 loc) · 893 Bytes
/
Copy pathLocalOpenAiClient.cs
File metadata and controls
40 lines (29 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.ClientModel;
using System.Text;
using Microsoft.AI.Foundry.Local;
using OpenAI;
using OpenAI.Chat;
using OpenAI.VectorStores;
public abstract class LocalOpenAiClient
{
protected OpenAIClient? client;
protected string? modelId;
protected static FoundryLocalManager manager;
protected static ModelInfo currentlyActiveModel;
protected List<ChatMessage> messages;
public LocalOpenAiClient(string modelId, Uri endpoint)
{
ApiKeyCredential key = new ApiKeyCredential("No key required!");
this.modelId = modelId;
client = new OpenAIClient(key, new OpenAIClientOptions
{
Endpoint = endpoint
});
messages = new List<ChatMessage>();
}
public LocalOpenAiClient()
{
messages = new List<ChatMessage>();
}
public abstract string GetResponse(string userMessage);
}