Skip to content

Commit a740129

Browse files
committed
Add LlmModelSetting.Version to fix GPT-4 incompatible for different version.
1 parent d96542f commit a740129

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

src/Infrastructure/BotSharp.Abstraction/MLTasks/IChatCompletion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public interface IChatCompletion
1010
/// <summary>
1111
/// Set model name, one provider can consume different model or version(s)
1212
/// </summary>
13-
/// <param name="model"></param>
13+
/// <param name="model">deployment name</param>
1414
void SetModelName(string model);
1515

1616
Task<RoleDialogModel> GetChatCompletions(Agent agent,

src/Infrastructure/BotSharp.Abstraction/MLTasks/Settings/LlmModelSetting.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ public class LlmModelSetting
1212
/// </summary>
1313
public string Name { get; set; }
1414

15+
/// <summary>
16+
/// Model version
17+
/// </summary>
18+
public string Version { get; set; } = "1106-Preview";
19+
1520
/// <summary>
1621
/// Deployment same functional model in a group.
1722
/// It can be used to deploy same model in different regions.

src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/ChatCompletionProvider.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ChatCompletionProvider : IChatCompletion
2222
private readonly IServiceProvider _services;
2323
private readonly ILogger _logger;
2424

25-
private string _model;
25+
private string _model, _version;
2626

2727
public string Provider => "azure-openai";
2828

@@ -231,10 +231,14 @@ public async Task<bool> GetChatCompletionsStreamingAsync(Agent agent, List<RoleD
231231
{
232232
if (message.Role == ChatRole.Function)
233233
{
234-
chatCompletionsOptions.Messages.Add(new ChatRequestAssistantMessage(string.Empty)
234+
if (_version == "0125-Preview")
235235
{
236-
FunctionCall = new FunctionCall(message.FunctionName, message.FunctionArgs),
237-
});
236+
chatCompletionsOptions.Messages.Add(new ChatRequestAssistantMessage(string.Empty)
237+
{
238+
FunctionCall = new FunctionCall(message.FunctionName, message.FunctionArgs),
239+
});
240+
}
241+
238242
chatCompletionsOptions.Messages.Add(new ChatRequestFunctionMessage(message.FunctionName, message.Content));
239243
}
240244
else if (message.Role == ChatRole.User)
@@ -330,5 +334,9 @@ private string GetPrompt(ChatCompletionsOptions chatCompletionsOptions)
330334
public void SetModelName(string model)
331335
{
332336
_model = model;
337+
338+
var settingsService = _services.GetRequiredService<ILlmProviderService>();
339+
var settings = settingsService.GetSetting(Provider, model);
340+
_version = settings.Version;
333341
}
334342
}

src/Plugins/BotSharp.Plugin.SemanticKernel/BotSharp.Plugin.SemanticKernel.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.2.0" />
15-
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.2.0-alpha" />
14+
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.4.0" />
15+
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.4.0-alpha" />
1616
<PackageReference Include="Microsoft.VisualStudio.Validation" Version="17.8.8" />
1717
</ItemGroup>
1818

src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelChatCompletionProvider.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class SemanticKernelChatCompletionProvider : IChatCompletion
2222
private Microsoft.SemanticKernel.ChatCompletion.IChatCompletionService _kernelChatCompletion;
2323
private IServiceProvider _services;
2424
private ITokenStatistics _tokenStatistics;
25-
private string? _model = null;
25+
private string _model;
2626

2727
/// <inheritdoc/>
2828
public string Provider => "semantic-kernel";
@@ -100,8 +100,7 @@ public Task<bool> GetChatCompletionsStreamingAsync(Agent agent, List<RoleDialogM
100100
/// <inheritdoc/>
101101
public void SetModelName(string model)
102102
{
103-
if (!string.IsNullOrWhiteSpace(model))
104-
this._model = model;
103+
_model = model;
105104
}
106105
}
107106
}

src/WebStarter/appsettings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
"Provider": "azure-openai",
4242
"Models": [
4343
{
44+
"Id": "gpt-3.5-turbo",
4445
"Name": "gpt-35-turbo",
46+
"Version": "1106",
4547
"ApiKey": "",
4648
"Endpoint": "https://gpt-35-turbo.openai.azure.com/",
4749
"Type": "chat",
@@ -50,6 +52,7 @@
5052
},
5153
{
5254
"Name": "gpt-35-turbo-instruct",
55+
"Version": "0914",
5356
"ApiKey": "",
5457
"Endpoint": "https://gpt-35-turbo-instruct.openai.azure.com/",
5558
"Type": "text",

0 commit comments

Comments
 (0)