Skip to content

Commit

Permalink
fix(Ollama): Fixed #349.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jun 19, 2024
1 parent ab445a9 commit ca20d77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/Providers/Ollama/src/OllamaChatModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ public override async Task<ChatResponse> GenerateAsync(
{
request = request ?? throw new ArgumentNullException(nameof(request));

await Provider.Api.Models.PullModelAndEnsureSuccessAsync(Id, cancellationToken: cancellationToken).ConfigureAwait(false);
try
{
await Provider.Api.Models.PullModelAndEnsureSuccessAsync(Id, cancellationToken: cancellationToken).ConfigureAwait(false);
}
catch (HttpRequestException)
{
// Ignore
}

var prompt = ToPrompt(request.Messages);
var watch = Stopwatch.StartNew();
Expand Down
11 changes: 9 additions & 2 deletions src/Providers/Ollama/src/OllamaEmbeddingModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ public async Task<EmbeddingResponse> CreateEmbeddingsAsync(
{
request = request ?? throw new ArgumentNullException(nameof(request));

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

try
{
await Provider.Api.Models.PullModelAndEnsureSuccessAsync(Id, cancellationToken: cancellationToken).ConfigureAwait(false);
}
catch (HttpRequestException)
{
// Ignore
}

var results = new List<IList<double>>(capacity: request.Strings.Count);
foreach (var prompt in request.Strings)
{
Expand Down

0 comments on commit ca20d77

Please sign in to comment.