mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-03-31 10:28:21 +00:00
a
This commit is contained in:
@@ -1,19 +1,27 @@
|
|||||||
// The endpoint for LM Studio's local server
|
// The endpoint for LM Studio's local server
|
||||||
using OpenAI;
|
using OpenAI;
|
||||||
using OpenAI.Chat;
|
using OpenAI.Chat;
|
||||||
|
using System.ClientModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
|
||||||
var endpoint = "http://localhost:1234/v1";
|
var endpoint = "http://localhost:1234/v1";
|
||||||
var client = new OpenAIClient(new OpenAIClientOptions()
|
var credential = new ApiKeyCredential("lm-studio");
|
||||||
{
|
|
||||||
Endpoint = new Uri("http://localhost:1234/v1")
|
|
||||||
});
|
|
||||||
|
|
||||||
var chat = client.GetChatClient("local-model");
|
var client = new OpenAIClient(credential, new OpenAIClientOptions() { Endpoint = new Uri(endpoint) });
|
||||||
|
|
||||||
var response = await chat.CompleteAsync(
|
var chat = client.GetChatClient("microsoft/phi-4");
|
||||||
"Explain what this function does"
|
|
||||||
|
//List<ChatMessage> messages = new List<ChatMessage>
|
||||||
|
//{
|
||||||
|
// new SystemChatMessage("You are a helpful assistant that only speaks in rhymes."),
|
||||||
|
// new UserChatMessage("What is the capital of France?")
|
||||||
|
//};
|
||||||
|
|
||||||
|
//// Send the entire conversation history
|
||||||
|
//ChatCompletion completion = chat.CompleteChat(messages);
|
||||||
|
|
||||||
|
var response = await chat.CompleteChatAsync(
|
||||||
|
"Explain what Pi means"
|
||||||
);
|
);
|
||||||
|
|
||||||
Console.WriteLine(response.Value.Content[0].Text);
|
Console.WriteLine(response.Value.Content[0].Text);
|
||||||
Reference in New Issue
Block a user