Skip to content

Commit

Permalink
+ update OpenAI Version=2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NicklausBrain committed Dec 8, 2024
1 parent 31105df commit 13ffd61
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion My1kWordsEe/Components/Pages/FavoritesPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<div class="col-1"></div>
<div class="col-10">@word.EeWord</div>
<div class="col-1">
<a href="@($"/word/{word.EeWord}")">
<a href="@($"/word/{word.EeWord}")" target="_blank">
<i role="link" class="bi bi-box-arrow-up-right float-end"></i>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion My1kWordsEe/My1kWordsEe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="CSharpFunctionalExtensions" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Cosmos" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.9.1" />
<PackageReference Include="OpenAI" Version="2.0.0-beta.1" />
<PackageReference Include="OpenAI" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 3 additions & 5 deletions My1kWordsEe/Services/Ai/OpenAiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public async Task<Result<T>> CompleteJsonAsync<T>(string instructions, string in
{
var response = await this.CompleteAsync(instructions, input, new ChatCompletionOptions
{
ResponseFormat = ChatResponseFormat.JsonObject,
Temperature = temperature
ResponseFormat = ChatResponseFormat.CreateJsonObjectFormat(),
Temperature = temperature,
});

if (response.IsFailure)
Expand Down Expand Up @@ -102,10 +102,8 @@ public static async Task<Result<string>> GetDallEPrompt(this OpenAiClient openAi

return await openAiClient.CompleteAsync(prompt, sentence, new ChatCompletionOptions
{
ResponseFormat = ChatResponseFormat.Text,
ResponseFormat = ChatResponseFormat.CreateTextFormat(),
Temperature = (float)Math.PI / 2,
// limit the number of tokens to avoid long prompts that crush stability ai
MaxTokens = 400,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion My1kWordsEe/Services/Cqs/AddSampleWordCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private async Task<Result<SampleWord>> GetWordMetadata(
input,
new ChatCompletionOptions
{
ResponseFormat = ChatResponseFormat.JsonObject,
ResponseFormat = ChatResponseFormat.CreateJsonObjectFormat(),
Temperature = 0.333f
});

Expand Down

0 comments on commit 13ffd61

Please sign in to comment.