Оно живое
This commit is contained in:
8
.idea/.idea.YandexGPT/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.YandexGPT/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/.idea.YandexGPT/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.YandexGPT/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -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!");
|
||||
21
YandexGPT.CLI/Services/YandexGptService.cs
Normal file
21
YandexGPT.CLI/Services/YandexGptService.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user