Skip to content

Commit

Permalink
fix: Fixed Ollama issue #338.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jun 11, 2024
1 parent 323b34c commit 0d497ca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<PackageVersion Include="MSTest.TestFramework" Version="3.1.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Npgsql" Version="8.0.3" />
<PackageVersion Include="Ollama" Version="1.1.1" />
<PackageVersion Include="Ollama" Version="1.3.2" />
<PackageVersion Include="OpenSearch.Client" Version="1.7.1" />
<PackageVersion Include="Pgvector" Version="0.2.0" />
<PackageVersion Include="NUnit" Version="4.1.0" />
Expand Down
6 changes: 3 additions & 3 deletions src/Providers/Ollama/src/OllamaChatModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ public override async Task<ChatResponse> GenerateAsync(
{
request = request ?? throw new ArgumentNullException(nameof(request));

await Provider.Api.PullModelAndEnsureSuccessAsync(Id, cancellationToken: cancellationToken).ConfigureAwait(false);
await Provider.Api.Models.PullModelAndEnsureSuccessAsync(Id, cancellationToken: cancellationToken).ConfigureAwait(false);

var prompt = ToPrompt(request.Messages);
var watch = Stopwatch.StartNew();
var response = Provider.Api.GenerateCompletionAsync(new GenerateCompletionRequest
var response = Provider.Api.Completions.GenerateCompletionAsync(new GenerateCompletionRequest
{
Prompt = prompt,
Model = Id,
Options = Provider.Options,
Stream = true,
Raw = true,
Format = UseJson ? "json" : string.Empty,
Format = UseJson ? GenerateCompletionRequestFormat.Json : null,
}, cancellationToken);

OnPromptSent(prompt);
Expand Down
4 changes: 2 additions & 2 deletions src/Providers/Ollama/src/OllamaEmbeddingModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public async Task<EmbeddingResponse> CreateEmbeddingsAsync(
{
request = request ?? throw new ArgumentNullException(nameof(request));

await Provider.Api.PullModelAndEnsureSuccessAsync(Id, cancellationToken: cancellationToken).ConfigureAwait(false);
await Provider.Api.Models.PullModelAndEnsureSuccessAsync(Id, cancellationToken: cancellationToken).ConfigureAwait(false);

var results = new List<IList<double>>(capacity: request.Strings.Count);
foreach (var prompt in request.Strings)
{
var response = await Provider.Api.GenerateEmbeddingAsync(new GenerateEmbeddingRequest
var response = await Provider.Api.Embeddings.GenerateEmbeddingAsync(new GenerateEmbeddingRequest
{
Prompt = prompt,
Model = Id,
Expand Down

0 comments on commit 0d497ca

Please sign in to comment.