Add LlmModelSetting.Version to fix GPT-4 incompatible for different version.

This commit is contained in:
Haiping Chen 2024-02-22 06:22:26 -06:00
parent d96542f562
commit a7401296ed
6 changed files with 25 additions and 10 deletions

View file

@ -10,7 +10,7 @@ public interface IChatCompletion
/// <summary>
/// Set model name, one provider can consume different model or version(s)
/// </summary>
/// <param name="model"></param>
/// <param name="model">deployment name</param>
void SetModelName(string model);
Task<RoleDialogModel> GetChatCompletions(Agent agent,

View file

@ -12,6 +12,11 @@ public class LlmModelSetting
/// </summary>
public string Name { get; set; }
/// <summary>
/// Model version
/// </summary>
public string Version { get; set; } = "1106-Preview";
/// <summary>
/// Deployment same functional model in a group.
/// It can be used to deploy same model in different regions.

View file

@ -22,7 +22,7 @@ public class ChatCompletionProvider : IChatCompletion
private readonly IServiceProvider _services;
private readonly ILogger _logger;
private string _model;
private string _model, _version;
public string Provider => "azure-openai";
@ -231,10 +231,14 @@ public class ChatCompletionProvider : IChatCompletion
{
if (message.Role == ChatRole.Function)
{
chatCompletionsOptions.Messages.Add(new ChatRequestAssistantMessage(string.Empty)
if (_version == "0125-Preview")
{
FunctionCall = new FunctionCall(message.FunctionName, message.FunctionArgs),
});
chatCompletionsOptions.Messages.Add(new ChatRequestAssistantMessage(string.Empty)
{
FunctionCall = new FunctionCall(message.FunctionName, message.FunctionArgs),
});
}
chatCompletionsOptions.Messages.Add(new ChatRequestFunctionMessage(message.FunctionName, message.Content));
}
else if (message.Role == ChatRole.User)
@ -330,5 +334,9 @@ public class ChatCompletionProvider : IChatCompletion
public void SetModelName(string model)
{
_model = model;
var settingsService = _services.GetRequiredService<ILlmProviderService>();
var settings = settingsService.GetSetting(Provider, model);
_version = settings.Version;
}
}

View file

@ -11,8 +11,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.2.0" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.2.0-alpha" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.4.0" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.4.0-alpha" />
<PackageReference Include="Microsoft.VisualStudio.Validation" Version="17.8.8" />
</ItemGroup>

View file

@ -22,7 +22,7 @@ namespace BotSharp.Plugin.SemanticKernel
private Microsoft.SemanticKernel.ChatCompletion.IChatCompletionService _kernelChatCompletion;
private IServiceProvider _services;
private ITokenStatistics _tokenStatistics;
private string? _model = null;
private string _model;
/// <inheritdoc/>
public string Provider => "semantic-kernel";
@ -100,8 +100,7 @@ namespace BotSharp.Plugin.SemanticKernel
/// <inheritdoc/>
public void SetModelName(string model)
{
if (!string.IsNullOrWhiteSpace(model))
this._model = model;
_model = model;
}
}
}

View file

@ -41,7 +41,9 @@
"Provider": "azure-openai",
"Models": [
{
"Id": "gpt-3.5-turbo",
"Name": "gpt-35-turbo",
"Version": "1106",
"ApiKey": "",
"Endpoint": "https://gpt-35-turbo.openai.azure.com/",
"Type": "chat",
@ -50,6 +52,7 @@
},
{
"Name": "gpt-35-turbo-instruct",
"Version": "0914",
"ApiKey": "",
"Endpoint": "https://gpt-35-turbo-instruct.openai.azure.com/",
"Type": "text",