Initial Checkin of the AI-projects
This commit is contained in:
32
simpleOpenAiAzureChatBot/Program.cs
Normal file
32
simpleOpenAiAzureChatBot/Program.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Azure;
|
||||
using Azure.AI.OpenAI;
|
||||
using System.Text;
|
||||
|
||||
var client=new OpenAIClient(new Uri("https://espopenaitest1.openai.azure.com/"), new AzureKeyCredential("simpleChatBot.Keys.OpenAIKey"));
|
||||
//var options=new ChatCompletionsOptions { MaxTokens = 4096, Temperature = 0.7f, ChoicesPerPrompt = 1 };
|
||||
var options=new ChatCompletionsOptions { MaxTokens = 4096, Temperature = 0.7f };
|
||||
|
||||
options.Messages.Add(new ChatMessage(ChatRole.System, """
|
||||
You are a friendly and funny chap, used to amuse an online audience.
|
||||
You respond as if you were John Cleese from Monty Python but with an old-English, medieval way of talking.
|
||||
"""));
|
||||
|
||||
while (true){
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.Write(">> ");
|
||||
var prompt = Console.ReadLine();
|
||||
if (prompt?.ToLower() == "exit") break;
|
||||
|
||||
options.Messages.Add(new ChatMessage(ChatRole.User, prompt));
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine();
|
||||
var currentResponse = String.Empty;
|
||||
//var response = await client.GetChatCompletionsAsync("ESPChatTest",options);
|
||||
var response = await client.GetChatCompletionsAsync(options);
|
||||
|
||||
Console.WriteLine(response.Value.Choices[0].Message.Content);
|
||||
Console.WriteLine();
|
||||
|
||||
options.Messages.Add(new ChatMessage(ChatRole.Assistant, currentResponse));
|
||||
}
|
||||
14
simpleOpenAiAzureChatBot/simpleChatBot.csproj
Normal file
14
simpleOpenAiAzureChatBot/simpleChatBot.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Azure.AI.OpenAI" Version="1.0.0-beta.9" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
25
simpleOpenAiAzureChatBot/simpleChatBot.sln
Normal file
25
simpleOpenAiAzureChatBot/simpleChatBot.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.002.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "simpleChatBot", "simpleChatBot.csproj", "{225DB841-135B-4D4C-B66F-462516705837}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{225DB841-135B-4D4C-B66F-462516705837}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{225DB841-135B-4D4C-B66F-462516705837}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{225DB841-135B-4D4C-B66F-462516705837}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{225DB841-135B-4D4C-B66F-462516705837}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F32F20DA-CA42-422F-B5FF-3166D6149D35}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Reference in New Issue
Block a user