Skip to content
Draft
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
2 changes: 1 addition & 1 deletion dotnet/samples/Demos/TelemetryWithAppInsights/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private static Kernel GetKernel(ILoggerFactory loggerFactory)
{
builder.AddHuggingFaceChatCompletion(
model: TestConfiguration.HuggingFace.ModelId,
endpoint: new Uri("https://api-inference.huggingface.co"),
endpoint: new Uri("https://router.huggingface.co/hf-inference"),
apiKey: TestConfiguration.HuggingFace.ApiKey,
serviceId: HuggingFaceServiceKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public async Task DefaultAddressShouldBeUsedAsync()
await sut.GetChatMessageContentAsync(chatHistory);

//Assert
Assert.StartsWith("https://api-inference.huggingface.co/", this._messageHandlerStub.RequestUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
Assert.StartsWith("https://router.huggingface.co/hf-inference/", this._messageHandlerStub.RequestUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task SpecifiedModelShouldBeUsedAsync()
await sut.GenerateEmbeddingsAsync([]);

//Assert
Assert.EndsWith("/fake-model", this._messageHandlerStub.RequestUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
Assert.Contains("/fake-model/", this._messageHandlerStub.RequestUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
}

[Fact]
Expand Down Expand Up @@ -98,7 +98,7 @@ public async Task ModelUrlShouldBeBuiltSuccessfullyAsync()
await sut.GenerateEmbeddingsAsync([]);

//Assert
Assert.Equal("https://fake-random-test-host/fake-path/pipeline/feature-extraction/fake-model", this._messageHandlerStub.RequestUri?.AbsoluteUri);
Assert.Equal("https://fake-random-test-host/fake-path/models/fake-model/pipeline/feature-extraction", this._messageHandlerStub.RequestUri?.AbsoluteUri);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task SpecifiedModelShouldBeUsedAsync()
await sut.GenerateAsync([]);

//Assert
Assert.EndsWith("/fake-model", this._messageHandlerStub.RequestUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
Assert.Contains("/fake-model/", this._messageHandlerStub.RequestUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
}

[Fact]
Expand Down Expand Up @@ -98,7 +98,7 @@ public async Task ModelUrlShouldBeBuiltSuccessfullyAsync()
await sut.GenerateAsync([]);

//Assert
Assert.Equal("https://fake-random-test-host/fake-path/pipeline/feature-extraction/fake-model", this._messageHandlerStub.RequestUri?.AbsoluteUri);
Assert.Equal("https://fake-random-test-host/fake-path/models/fake-model/pipeline/feature-extraction", this._messageHandlerStub.RequestUri?.AbsoluteUri);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public async Task DefaultAddressShouldBeUsedAsync()
await sut.GetTextContentsAsync(this._imageContentInput);

//Assert
Assert.StartsWith("https://api-inference.huggingface.co/models", this._messageHandlerStub.RequestUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
Assert.StartsWith("https://router.huggingface.co/hf-inference/models", this._messageHandlerStub.RequestUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public async Task DefaultAddressShouldBeUsedAsync()
await sut.GetTextContentsAsync("fake-text");

//Assert
Assert.StartsWith("https://api-inference.huggingface.co/models", this._messageHandlerStub.RequestUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
Assert.StartsWith("https://router.huggingface.co/hf-inference/models", this._messageHandlerStub.RequestUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal HuggingFaceClient(
throw new InvalidOperationException("A valid model id or endpoint must be provided.");
}

endpoint ??= new Uri("https://api-inference.huggingface.co");
endpoint ??= new Uri("https://router.huggingface.co/hf-inference");
this.Separator = endpoint.AbsolutePath.EndsWith("/", StringComparison.InvariantCulture) ? string.Empty : "/";
this.Endpoint = endpoint;
this.ModelId = modelId;
Expand Down Expand Up @@ -300,7 +300,7 @@ public async Task<IList<ReadOnlyMemory<float>>> GenerateEmbeddingsAsync(
}

private Uri GetEmbeddingGenerationEndpoint(string? modelId)
=> string.IsNullOrWhiteSpace(modelId) ? this.Endpoint : new($"{this.Endpoint}{this.Separator}pipeline/feature-extraction/{modelId}");
=> string.IsNullOrWhiteSpace(modelId) ? this.Endpoint : new($"{this.Endpoint}{this.Separator}models/{modelId}/pipeline/feature-extraction");

#endregion

Expand Down