Оно живое

This commit is contained in:
Mikhail Shahovalov
2025-05-09 15:16:06 +03:00
parent b6e05f8705
commit 0aa0e59710
5 changed files with 62 additions and 2 deletions

View File

@@ -1,3 +1,23 @@
// See https://aka.ms/new-console-template for more information
using OpenAI.Chat;
using OpenAI.RealtimeConversation;
using YandexGPT.CLI.Services;
Console.WriteLine("Let's start!");
var service = new YandexGptService();
var client = service.CreateClient();
var chat = client.GetChatClient("gpt://b1gg9b7e74q248tvan7f/yandexgpt/latest");
var query = Console.ReadLine();;
while (query is not ("exit" and "quit"))
{
var message = ChatMessage.CreateUserMessage(query);
var response = chat.CompleteChat(message);
foreach (var row in response.Value.Content)
{
Console.WriteLine(row.Text);
}
query = Console.ReadLine();
}
Console.WriteLine("Hello, World!");

View File

@@ -0,0 +1,21 @@
using System.ClientModel;
using OpenAI;
namespace YandexGPT.CLI.Services;
public class YandexGptService
{
public OpenAIClient CreateClient()
{
var options = new OpenAI.OpenAIClientOptions()
{
Endpoint = new Uri("https://llm.api.cloud.yandex.net/v1")
};
var credential = new ApiKeyCredential("AQVN1a58GEuuJPE4-cQptps_j35i0DRAvx8d8VJN");
var client = new OpenAI.OpenAIClient(credential, options);
return client;
}
}

View File

@@ -7,4 +7,9 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="OpenAI" Version="2.2.0-beta.4" />
</ItemGroup>
</Project>