Skip to content

Commit

Permalink
fix: Fixed 400 error when use RequestOptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed May 12, 2024
1 parent d2fc864 commit a916951
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<PropertyGroup Label="Nuget">
<Version>0.9.4</Version>
<Version>0.9.5</Version>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Authors>tryAGI and contributors</Authors>
Expand Down
1 change: 1 addition & 0 deletions src/libs/Ollama/OllamaApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ private async IAsyncEnumerable<TResponse> StreamPostAsync<TRequest, TResponse>(
}
}

[JsonSourceGenerationOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
[JsonSerializable(typeof(DeleteModelRequest))]
[JsonSerializable(typeof(GenerateCompletionRequest))]
[JsonSerializable(typeof(GenerateCompletionResponse))]
Expand Down
22 changes: 22 additions & 0 deletions src/tests/Ollama.IntegrationTests/Tests.Integration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,28 @@ public async Task PullModel()
await container.ApiClient.PullModelAsync("nomic-embed-text").WaitAsync();
}

[TestMethod]
public async Task GetCompletionWithOptions()
{
#if DEBUG
await using var container = await PrepareEnvironmentAsync(EnvironmentType.Local, "llama3");
#else
await using var container = await PrepareEnvironmentAsync(EnvironmentType.Container, "llama3");
#endif

var response = await container.ApiClient.GetCompletionAsync(new GenerateCompletionRequest
{
Model = "llama3",
Prompt = "answer me just \"123\"",
Stream = true,
Options = new RequestOptions
{
Temperature = 0,
},
}).WaitAsync();
Console.WriteLine(response.Response);
}

[TestMethod]
public async Task GetCompletion()
{
Expand Down

0 comments on commit a916951

Please sign in to comment.