Bump Azure.AI.OpenAI to 1.0.0-beta.9

This commit is contained in:
Haiping Chen 2023-11-13 11:19:25 -06:00
parent 8378af8009
commit 57870ae63b
8 changed files with 27 additions and 37 deletions

View file

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<LangVersion>10.0</LangVersion> <LangVersion>10.0</LangVersion>
<OutputPath>..\..\..\packages</OutputPath> <OutputPath>..\..\..\packages</OutputPath>
<BotSharpVersion>0.18.0</BotSharpVersion> <BotSharpVersion>0.19.0</BotSharpVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View file

@ -1,5 +1,5 @@
# The Open Source LLM Application Framework # The Open Source AI Agent Application Framework
## Connect LLMs to your existing application ## Connect LLMs to your existing application focused on your business
[![Discord](https://img.shields.io/discord/1106946823282761851?label=Discord)](https://discord.gg/qRVm82fKTS) [![Discord](https://img.shields.io/discord/1106946823282761851?label=Discord)](https://discord.gg/qRVm82fKTS)
[![QQ群聊](https://img.shields.io/static/v1?label=QQ&message=群聊&color=brightgreen)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=sN9VVMwbWjs5L0ATpizKKxOcZdEPMrp8&authKey=RLDw41bLTrEyEgZZi%2FzT4pYk%2BwmEFgFcrhs8ZbkiVY7a4JFckzJefaYNW6Lk4yPX&noverify=0&group_code=985366726) [![QQ群聊](https://img.shields.io/static/v1?label=QQ&message=群聊&color=brightgreen)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=sN9VVMwbWjs5L0ATpizKKxOcZdEPMrp8&authKey=RLDw41bLTrEyEgZZi%2FzT4pYk%2BwmEFgFcrhs8ZbkiVY7a4JFckzJefaYNW6Lk4yPX&noverify=0&group_code=985366726)
@ -52,6 +52,7 @@ BotSharp uses component design, the kernel is kept to a minimum, and business fu
- BotSharp.Plugin.MetaAI - BotSharp.Plugin.MetaAI
- BotSharp.Plugin.HuggingFace - BotSharp.Plugin.HuggingFace
- BotSharp.Plugin.LLamaSharp - BotSharp.Plugin.LLamaSharp
- BotSharp.Plugin.SemanticKernel
#### Messaging / Channel #### Messaging / Channel
- BotSharp.OpenAPI - BotSharp.OpenAPI

View file

@ -64,9 +64,9 @@ author = 'Haiping Chen'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.18' version = '0.19'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.18.0' release = '0.19.0'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
@ -10,7 +10,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="1.0.0-beta.8" /> <PackageReference Include="Azure.AI.OpenAI" Version="1.0.0-beta.9" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -47,8 +47,8 @@ public class ChatCompletionProvider : IChatCompletion
var client = ProviderHelper.GetClient(_model, _settings); var client = ProviderHelper.GetClient(_model, _settings);
var (prompt, chatCompletionsOptions) = PrepareOptions(agent, conversations); var (prompt, chatCompletionsOptions) = PrepareOptions(agent, conversations);
chatCompletionsOptions.DeploymentName = _model;
var response = client.GetChatCompletions(_model, chatCompletionsOptions); var response = client.GetChatCompletions(chatCompletionsOptions);
var choice = response.Value.Choices[0]; var choice = response.Value.Choices[0];
var message = choice.Message; var message = choice.Message;
@ -110,7 +110,8 @@ public class ChatCompletionProvider : IChatCompletion
var client = ProviderHelper.GetClient(_model, _settings); var client = ProviderHelper.GetClient(_model, _settings);
var (prompt, chatCompletionsOptions) = PrepareOptions(agent, conversations); var (prompt, chatCompletionsOptions) = PrepareOptions(agent, conversations);
var response = await client.GetChatCompletionsAsync(_model, chatCompletionsOptions); chatCompletionsOptions.DeploymentName = _model;
var response = await client.GetChatCompletionsAsync(chatCompletionsOptions);
var choice = response.Value.Choices[0]; var choice = response.Value.Choices[0];
var message = choice.Message; var message = choice.Message;
@ -162,39 +163,27 @@ public class ChatCompletionProvider : IChatCompletion
{ {
var client = ProviderHelper.GetClient(_model, _settings); var client = ProviderHelper.GetClient(_model, _settings);
var (prompt, chatCompletionsOptions) = PrepareOptions(agent, conversations); var (prompt, chatCompletionsOptions) = PrepareOptions(agent, conversations);
chatCompletionsOptions.DeploymentName = _model;
var response = await client.GetChatCompletionsStreamingAsync(_model, chatCompletionsOptions); var response = await client.GetChatCompletionsStreamingAsync(chatCompletionsOptions);
using StreamingChatCompletions streaming = response.Value;
string output = ""; string output = "";
await foreach (var choice in streaming.GetChoicesStreaming()) await foreach (var choice in response)
{ {
if (choice.FinishReason == CompletionsFinishReason.FunctionCall) if (choice.FinishReason == CompletionsFinishReason.FunctionCall)
{ {
var args = ""; Console.Write(choice.FunctionArgumentsUpdate);
await foreach (var message in choice.GetMessageStreaming())
{
if (message.FunctionCall == null || message.FunctionCall.Arguments == null)
continue;
Console.Write(message.FunctionCall.Arguments);
args += message.FunctionCall.Arguments;
} await onMessageReceived(new RoleDialogModel(ChatRole.Assistant.ToString(), choice.FunctionArgumentsUpdate));
await onMessageReceived(new RoleDialogModel(ChatRole.Assistant.ToString(), args));
continue; continue;
} }
await foreach (var message in choice.GetMessageStreaming()) if (choice.ContentUpdate == null)
{ continue;
if (message.Content == null) Console.Write(choice.ContentUpdate);
continue;
Console.Write(message.Content);
output += message.Content;
_logger.LogInformation(message.Content); _logger.LogInformation(choice.ContentUpdate);
await onMessageReceived(new RoleDialogModel(message.Role.ToString(), message.Content)); await onMessageReceived(new RoleDialogModel(choice.Role.ToString(), choice.ContentUpdate));
}
output = ""; output = "";
} }

View file

@ -77,10 +77,8 @@ public class TextCompletionProvider : ITextCompletion
var samplingFactor = float.Parse(state.GetState("sampling_factor", "0.5")); var samplingFactor = float.Parse(state.GetState("sampling_factor", "0.5"));
completionsOptions.Temperature = temperature; completionsOptions.Temperature = temperature;
completionsOptions.NucleusSamplingFactor = samplingFactor; completionsOptions.NucleusSamplingFactor = samplingFactor;
completionsOptions.DeploymentName = _model;
var response = await client.GetCompletionsAsync( var response = await client.GetCompletionsAsync(completionsOptions);
deploymentOrModelName: _model,
completionsOptions);
// OpenAI // OpenAI
var completion = ""; var completion = "";

View file

@ -59,11 +59,12 @@
<ProjectReference Include="..\Plugins\BotSharp.Plugin.Qdrant\BotSharp.Plugin.Qdrant.csproj" /> <ProjectReference Include="..\Plugins\BotSharp.Plugin.Qdrant\BotSharp.Plugin.Qdrant.csproj" />
<ProjectReference Include="..\Plugins\BotSharp.Plugin.RoutingSpeeder\BotSharp.Plugin.RoutingSpeeder.csproj" /> <ProjectReference Include="..\Plugins\BotSharp.Plugin.RoutingSpeeder\BotSharp.Plugin.RoutingSpeeder.csproj" />
<ProjectReference Include="..\Plugins\BotSharp.Plugin.WeChat\BotSharp.Plugin.WeChat.csproj" /> <ProjectReference Include="..\Plugins\BotSharp.Plugin.WeChat\BotSharp.Plugin.WeChat.csproj" />
<ProjectReference Include="..\Plugins\BotSharp.Plugin.SemanticKernel\BotSharp.Plugin.SemanticKernel.csproj" />
<ProjectReference Include="..\Plugins\BotSharp.Plugin.Twilio\BotSharp.Plugin.Twilio.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\tests\BotSharp.Plugin.PizzaBot\BotSharp.Plugin.PizzaBot.csproj" /> <ProjectReference Include="..\..\tests\BotSharp.Plugin.PizzaBot\BotSharp.Plugin.PizzaBot.csproj" />
<ProjectReference Include="..\Plugins\BotSharp.Plugin.Twilio\BotSharp.Plugin.Twilio.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -142,6 +142,7 @@
// "BotSharp.Plugin.Twilio", // "BotSharp.Plugin.Twilio",
"BotSharp.Plugin.HuggingFace", "BotSharp.Plugin.HuggingFace",
"BotSharp.Plugin.LLamaSharp", "BotSharp.Plugin.LLamaSharp",
// "BotSharp.Plugin.SemanticKernel",
"BotSharp.Plugin.KnowledgeBase", "BotSharp.Plugin.KnowledgeBase",
"BotSharp.Plugin.Qdrant", "BotSharp.Plugin.Qdrant",
"BotSharp.Plugin.PaddleSharp", "BotSharp.Plugin.PaddleSharp",