Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Liquid.GenAi.OpenAi/Liquid.GenAi.OpenAi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Copyright>Avanade 2019</Copyright>
<PackageProjectUrl>https://github.com/Avanade/Liquid-Application-Framework</PackageProjectUrl>
<PackageIcon>logo.png</PackageIcon>
<Version>8.1.0</Version>
<Version>8.1.1</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
<DebugType>Full</DebugType>
Expand All @@ -31,7 +31,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0-beta.2" />
<PackageReference Include="Liquid.Core" Version="8.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
</ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions src/Liquid.GenAi.OpenAi/OpenAiAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
}

///<inheritdoc/>
public async Task<ChatCompletionResult> CompleteChatAsync(string content, string prompt, CompletionsOptions settings, LiquidChatMessages chatHistory = null)

Check warning on line 56 in src/Liquid.GenAi.OpenAi/OpenAiAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 56 in src/Liquid.GenAi.OpenAi/OpenAiAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

Cannot convert null literal to non-nullable reference type.
{
var client = _factory.GetOpenAIClient(settings.ClientId);

Expand All @@ -77,7 +77,7 @@
}

///<inheritdoc/>
public async Task<ChatCompletionResult> CompleteChatAsync(LiquidChatMessages messages, CompletionsOptions settings, List<FunctionBody> functions = null, LiquidChatMessages chatHistory = null)

Check warning on line 80 in src/Liquid.GenAi.OpenAi/OpenAiAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 80 in src/Liquid.GenAi.OpenAi/OpenAiAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 80 in src/Liquid.GenAi.OpenAi/OpenAiAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 80 in src/Liquid.GenAi.OpenAi/OpenAiAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

Cannot convert null literal to non-nullable reference type.
{
var client = _factory.GetOpenAIClient(settings.ClientId);

Expand All @@ -85,9 +85,7 @@

messages.Messages.ForEach(m => requestMessages.Add(MapChatRequestMessage(m)));

var option = MapChatCompletionOptions(settings);

var responseWithoutStream = await client.CompleteChatAsync(requestMessages, option);
var option = MapChatCompletionOptions(settings);

if (functions != null)
{
Expand All @@ -102,7 +100,12 @@
}
}

var response = responseWithoutStream.Value.Content[0].Text;
var responseWithoutStream = await client.CompleteChatAsync(requestMessages, option);


var response = responseWithoutStream.Value.FinishReason != ChatFinishReason.ToolCalls ?
responseWithoutStream.Value.Content[0].Text :
responseWithoutStream.Value.ToolCalls[0].FunctionArguments.ToString();

var result = new ChatCompletionResult()
{
Expand Down Expand Up @@ -167,7 +170,7 @@

if (chatRequestMessage == null)
{
throw new ApplicationException($"The folowing message is invalid: {message}");

Check warning on line 173 in src/Liquid.GenAi.OpenAi/OpenAiAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

'System.ApplicationException' should not be thrown by user code. (https://rules.sonarsource.com/csharp/RSPEC-112)

Check warning on line 173 in src/Liquid.GenAi.OpenAi/OpenAiAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

'System.ApplicationException' should not be thrown by user code. (https://rules.sonarsource.com/csharp/RSPEC-112)
}

return chatRequestMessage;
Expand Down
Loading