Skip to content

Commit f6d4323

Browse files
committed
fix: Fixed.
1 parent 2a41863 commit f6d4323

File tree

9 files changed

+38
-59
lines changed

9 files changed

+38
-59
lines changed

LangChain.Providers.sln

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LangChain.Providers.Azure",
7979
EndProject
8080
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LangChain.Providers.Google", "src\Google\src\LangChain.Providers.Google.csproj", "{D692E628-1072-4465-9D1E-4840DC24DE97}"
8181
EndProject
82-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LangChain.Providers.HuggingFace", "src\HuggingFace\src\LangChain.Providers.HuggingFace.csproj", "{F9F8E323-5B23-43F1-ABBD-05CD0D5CAC35}"
83-
EndProject
84-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LangChain.Providers.Leonardo", "src\LeonardoAI\src\LangChain.Providers.Leonardo.csproj", "{786BD899-CB12-4A3F-9107-FF28A8C90B42}"
85-
EndProject
8682
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LangChain.Providers.LLamaSharp", "src\LLamaSharp\src\LangChain.Providers.LLamaSharp.csproj", "{72C0A9D6-D59C-4217-813C-11469761E9F8}"
8783
EndProject
8884
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LangChain.Providers.LLamaSharp.Tests", "src\LLamaSharp\test\LangChain.Providers.LLamaSharp.Tests.csproj", "{4B5250D7-DF03-4DE7-81CC-B9EBBAAC4274}"
@@ -158,8 +154,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{20D58A8D-D
158154
EndProject
159155
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenerateDocs", "src\Helpers\GenerateDocs\GenerateDocs.csproj", "{EFFC19CE-9519-492D-A5CC-E1C90EB410E0}"
160156
EndProject
161-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LangChain.Providers.Anthropic", "src\Anthropic\src\LangChain.Providers.Anthropic.csproj", "{BD9AF0B6-15C5-4365-9B78-6EF0C9CC3E2F}"
162-
EndProject
163157
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LangChain.IntegrationTests", "src\IntegrationTests\LangChain.IntegrationTests.csproj", "{12C853A4-0669-4FB2-934F-37E8171D1300}"
164158
EndProject
165159
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{D843DAF5-9B48-4F05-9A5C-C2AD1209BF24}"
@@ -178,6 +172,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenRouter", "OpenRouter",
178172
EndProject
179173
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples.OpenRouter", "Examples\Examples.OpenRouter\src\Examples.OpenRouter\Examples.OpenRouter.csproj", "{9622C708-4848-460B-A4F6-9E05EFA9EB18}"
180174
EndProject
175+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LangChain.Providers.HuggingFace", "src\HuggingFace\src\LangChain.Providers.HuggingFace.csproj", "{557FE99B-E1B1-4F43-BC8A-BBB9CDD88C5A}"
176+
EndProject
181177
Global
182178
GlobalSection(SolutionConfigurationPlatforms) = preSolution
183179
Debug|Any CPU = Debug|Any CPU
@@ -228,14 +224,6 @@ Global
228224
{D692E628-1072-4465-9D1E-4840DC24DE97}.Debug|Any CPU.Build.0 = Debug|Any CPU
229225
{D692E628-1072-4465-9D1E-4840DC24DE97}.Release|Any CPU.ActiveCfg = Release|Any CPU
230226
{D692E628-1072-4465-9D1E-4840DC24DE97}.Release|Any CPU.Build.0 = Release|Any CPU
231-
{F9F8E323-5B23-43F1-ABBD-05CD0D5CAC35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
232-
{F9F8E323-5B23-43F1-ABBD-05CD0D5CAC35}.Debug|Any CPU.Build.0 = Debug|Any CPU
233-
{F9F8E323-5B23-43F1-ABBD-05CD0D5CAC35}.Release|Any CPU.ActiveCfg = Release|Any CPU
234-
{F9F8E323-5B23-43F1-ABBD-05CD0D5CAC35}.Release|Any CPU.Build.0 = Release|Any CPU
235-
{786BD899-CB12-4A3F-9107-FF28A8C90B42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
236-
{786BD899-CB12-4A3F-9107-FF28A8C90B42}.Debug|Any CPU.Build.0 = Debug|Any CPU
237-
{786BD899-CB12-4A3F-9107-FF28A8C90B42}.Release|Any CPU.ActiveCfg = Release|Any CPU
238-
{786BD899-CB12-4A3F-9107-FF28A8C90B42}.Release|Any CPU.Build.0 = Release|Any CPU
239227
{72C0A9D6-D59C-4217-813C-11469761E9F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
240228
{72C0A9D6-D59C-4217-813C-11469761E9F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
241229
{72C0A9D6-D59C-4217-813C-11469761E9F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -312,10 +300,6 @@ Global
312300
{EFFC19CE-9519-492D-A5CC-E1C90EB410E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
313301
{EFFC19CE-9519-492D-A5CC-E1C90EB410E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
314302
{EFFC19CE-9519-492D-A5CC-E1C90EB410E0}.Release|Any CPU.Build.0 = Release|Any CPU
315-
{BD9AF0B6-15C5-4365-9B78-6EF0C9CC3E2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
316-
{BD9AF0B6-15C5-4365-9B78-6EF0C9CC3E2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
317-
{BD9AF0B6-15C5-4365-9B78-6EF0C9CC3E2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
318-
{BD9AF0B6-15C5-4365-9B78-6EF0C9CC3E2F}.Release|Any CPU.Build.0 = Release|Any CPU
319303
{12C853A4-0669-4FB2-934F-37E8171D1300}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
320304
{12C853A4-0669-4FB2-934F-37E8171D1300}.Debug|Any CPU.Build.0 = Debug|Any CPU
321305
{12C853A4-0669-4FB2-934F-37E8171D1300}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -336,6 +320,10 @@ Global
336320
{9622C708-4848-460B-A4F6-9E05EFA9EB18}.Debug|Any CPU.Build.0 = Debug|Any CPU
337321
{9622C708-4848-460B-A4F6-9E05EFA9EB18}.Release|Any CPU.ActiveCfg = Release|Any CPU
338322
{9622C708-4848-460B-A4F6-9E05EFA9EB18}.Release|Any CPU.Build.0 = Release|Any CPU
323+
{557FE99B-E1B1-4F43-BC8A-BBB9CDD88C5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
324+
{557FE99B-E1B1-4F43-BC8A-BBB9CDD88C5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
325+
{557FE99B-E1B1-4F43-BC8A-BBB9CDD88C5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
326+
{557FE99B-E1B1-4F43-BC8A-BBB9CDD88C5A}.Release|Any CPU.Build.0 = Release|Any CPU
339327
EndGlobalSection
340328
GlobalSection(SolutionProperties) = preSolution
341329
HideSolutionNode = FALSE
@@ -365,8 +353,6 @@ Global
365353
{4724E9F2-A344-4B64-9492-AD6A6964AF43} = {0ACB8140-8198-4FA4-94DF-95A159E38E5C}
366354
{D0FC7D59-9535-4860-BF5B-D163AA06ECCF} = {964429FD-A7CB-4607-9188-0B128C6CEDCD}
367355
{D692E628-1072-4465-9D1E-4840DC24DE97} = {A23BD019-BE70-42D5-9DD4-A79DEDDE54F4}
368-
{F9F8E323-5B23-43F1-ABBD-05CD0D5CAC35} = {91B13316-6565-4CB6-9876-945FFE2DD20C}
369-
{786BD899-CB12-4A3F-9107-FF28A8C90B42} = {DE00D366-5CA9-4EB9-98CC-18793B8229AB}
370356
{72C0A9D6-D59C-4217-813C-11469761E9F8} = {8266C51A-BE2E-458C-9434-DDAFF788181A}
371357
{4B5250D7-DF03-4DE7-81CC-B9EBBAAC4274} = {8266C51A-BE2E-458C-9434-DDAFF788181A}
372358
{E5D97C97-708B-4C33-A5DA-ED6CF16E5A85} = {E8880C1D-8C06-46B0-8C0D-345FE94FC2A3}
@@ -399,14 +385,14 @@ Global
399385
{90BC5243-139D-4CB2-8B68-3794070C1955} = {2DFDBF23-50E2-41DB-B2D5-CB2CC46D8C3B}
400386
{20D58A8D-DB93-47AC-956B-9EB89EA75928} = {23506EB8-1B27-4FD0-B570-2F5EF2C33034}
401387
{EFFC19CE-9519-492D-A5CC-E1C90EB410E0} = {1325D29E-D42F-423F-A6AC-5E880BE2AB68}
402-
{BD9AF0B6-15C5-4365-9B78-6EF0C9CC3E2F} = {7A2A589D-F8EF-4744-9BEE-B06A5F109851}
403388
{B1DBD358-85BE-46B5-8FAD-008A4E410236} = {D843DAF5-9B48-4F05-9A5C-C2AD1209BF24}
404389
{B4619680-6585-45D6-AB3F-D6F743FC2AAE} = {E2B9833C-0397-4FAF-A3A8-116E58749750}
405390
{028F13BA-D8C3-4758-B5D5-E86E763E5145} = {B4619680-6585-45D6-AB3F-D6F743FC2AAE}
406391
{C020886A-5658-4CB8-863B-D695F8DEE8E5} = {D843DAF5-9B48-4F05-9A5C-C2AD1209BF24}
407392
{DA2371B0-E3B0-4445-924E-571CB441000C} = {C020886A-5658-4CB8-863B-D695F8DEE8E5}
408393
{A22FAE09-1EF8-46B7-A319-0BA5A9791DBF} = {D843DAF5-9B48-4F05-9A5C-C2AD1209BF24}
409394
{9622C708-4848-460B-A4F6-9E05EFA9EB18} = {A22FAE09-1EF8-46B7-A319-0BA5A9791DBF}
395+
{557FE99B-E1B1-4F43-BC8A-BBB9CDD88C5A} = {91B13316-6565-4CB6-9876-945FFE2DD20C}
410396
EndGlobalSection
411397
GlobalSection(ExtensibilityGlobals) = postSolution
412398
SolutionGuid = {5C00D0F1-6138-4ED9-846B-97E43D6DFF1C}

src/HuggingFace/src/HuggingFaceChatModel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class HuggingFaceChatModel(
1414
#region Properties
1515

1616
/// <inheritdoc/>
17-
public override int ContextLength => ApiHelpers.CalculateContextLength(Id);
17+
public override int ContextLength => 0;// ApiHelpers.CalculateContextLength(Id);
1818

1919
#endregion
2020

@@ -36,27 +36,27 @@ private static string ToRequestMessage(Message message)
3636
private static Message ToMessage(ICollection<GenerateTextResponseValue> message)
3737
{
3838
return new Message(
39-
Content: message.First().Generated_text,
39+
Content: message.First().GeneratedText,
4040
Role: MessageRole.Ai);
4141
}
4242

4343
private async Task<ICollection<GenerateTextResponseValue>> CreateChatCompletionAsync(
4444
IReadOnlyCollection<Message> messages,
4545
CancellationToken cancellationToken = default)
4646
{
47-
return await provider.Api.GenerateTextAsync(modelId: Id, body: new GenerateTextRequest
47+
return await provider.Api.GenerateTextAsync(modelId: Id, new GenerateTextRequest
4848
{
4949
Inputs = messages
5050
.Select(ToRequestMessage)
5151
.ToArray().AsPrompt(),
5252
Parameters = new GenerateTextRequestParameters
5353
{
54-
Max_new_tokens = 250,
54+
MaxNewTokens = 250,
5555
},
5656
Options = new GenerateTextRequestOptions
5757
{
58-
Use_cache = true,
59-
Wait_for_model = false,
58+
UseCache = true,
59+
WaitForModel = false,
6060
},
6161
}, cancellationToken).ConfigureAwait(false);
6262
}

src/HuggingFace/src/HuggingFaceImageToTextModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override async Task<ImageToTextResponse> GenerateTextFromImageAsync(
3737
httpRequest.Content = imageContent;
3838

3939
var response = await provider.HttpClient.SendAsync(httpRequest, HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false);
40-
var json = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
40+
var json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
4141
var generation = JsonSerializer.Deserialize(json, SourceGenerationContext.Default.ImageToTextGenerationResponse) ??
4242
throw new InvalidOperationException("Response is null");
4343

src/HuggingFace/src/HuggingFaceProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class HuggingFaceProvider : Provider
2121
///
2222
/// </summary>
2323
[CLSCompliant(false)]
24-
public HuggingFaceApi Api { get; set; }
24+
public HuggingFaceClient Api { get; set; }
2525

2626
#endregion
2727

@@ -39,7 +39,7 @@ public HuggingFaceProvider(HuggingFaceConfiguration configuration, HttpClient ht
3939
configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
4040
ApiKey = configuration.ApiKey ?? throw new ArgumentException("ApiKey is not defined", nameof(configuration));
4141
HttpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
42-
Api = new HuggingFaceApi(apiKey: ApiKey, HttpClient);
42+
Api = new HuggingFaceClient(apiKey: ApiKey, HttpClient);
4343
}
4444

4545
/// <summary>
@@ -53,7 +53,7 @@ public HuggingFaceProvider(string apiKey, HttpClient httpClient)
5353
{
5454
ApiKey = apiKey ?? throw new ArgumentNullException(nameof(apiKey));
5555
HttpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
56-
Api = new HuggingFaceApi(apiKey: ApiKey, HttpClient);
56+
Api = new HuggingFaceClient(apiKey: ApiKey, HttpClient);
5757
}
5858

5959
#endregion

src/HuggingFace/src/Predefined/Gpt2Model.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/IntegrationTests/BaseTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class BaseTests
1414
[TestCase(ProviderType.OpenRouter)]
1515
[TestCase(ProviderType.Fireworks)]
1616
//[TestCase(ProviderType.Google)]
17-
[TestCase(ProviderType.Anthropic)]
17+
//[TestCase(ProviderType.Anthropic)]
1818
[TestCase(ProviderType.DeepInfra)]
1919
[TestCase(ProviderType.DeepSeek)]
2020
//[TestCase(ProviderType.Ollama)]
@@ -89,7 +89,7 @@ public async Task FiveRandomWords(ProviderType providerType)
8989
//[TestCase(ProviderType.OpenRouter)]
9090
//[TestCase(ProviderType.Fireworks)]
9191
//[TestCase(ProviderType.Google)]
92-
[TestCase(ProviderType.Anthropic)]
92+
//[TestCase(ProviderType.Anthropic)]
9393
[TestCase(ProviderType.DeepInfra)]
9494
[TestCase(ProviderType.DeepSeek)]
9595
//[TestCase(ProviderType.Ollama)]

src/IntegrationTests/Helpers.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using LangChain.Providers;
2-
using LangChain.Providers.Anthropic;
3-
using LangChain.Providers.Anthropic.Predefined;
42
using LangChain.Providers.Anyscale;
53
using LangChain.Providers.Anyscale.Predefined;
64
using LangChain.Providers.Azure;
@@ -127,20 +125,20 @@ public static (IChatModel ChatModel, IEmbeddingModel EmbeddingModel, IProvider P
127125

128126
return (llm, embeddings, provider);
129127
}
130-
case ProviderType.Anthropic:
131-
{
132-
var provider = new AnthropicProvider(
133-
apiKey: Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY") ??
134-
throw new InconclusiveException("ANTHROPIC_API_KEY is not set"));
135-
var llm = new Claude35Sonnet(provider);
136-
137-
// Use OpenAI embeddings for now because Anthropic doesn't have embeddings yet
138-
var embeddings = new TextEmbeddingV3SmallModel(
139-
Environment.GetEnvironmentVariable("OPENAI_API_KEY") ??
140-
throw new InconclusiveException("OPENAI_API_KEY is not set"));
141-
142-
return (llm, embeddings, provider);
143-
}
128+
// case ProviderType.Anthropic:
129+
// {
130+
// var provider = new AnthropicProvider(
131+
// apiKey: Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY") ??
132+
// throw new InconclusiveException("ANTHROPIC_API_KEY is not set"));
133+
// var llm = new Claude35Sonnet(provider);
134+
//
135+
// // Use OpenAI embeddings for now because Anthropic doesn't have embeddings yet
136+
// var embeddings = new TextEmbeddingV3SmallModel(
137+
// Environment.GetEnvironmentVariable("OPENAI_API_KEY") ??
138+
// throw new InconclusiveException("OPENAI_API_KEY is not set"));
139+
//
140+
// return (llm, embeddings, provider);
141+
// }
144142
case ProviderType.Groq:
145143
{
146144
var config = new GroqConfiguration()

src/IntegrationTests/LangChain.IntegrationTests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
<ItemGroup>
99
<ProjectReference Include="..\Amazon.Bedrock\src\LangChain.Providers.Amazon.Bedrock.csproj" />
10-
<ProjectReference Include="..\Anthropic\src\LangChain.Providers.Anthropic.csproj" />
1110
<ProjectReference Include="..\Anyscale\src\LangChain.Providers.Anyscale.csproj" />
1211
<ProjectReference Include="..\Automatic1111\src\LangChain.Providers.Automatic1111.csproj" />
1312
<ProjectReference Include="..\Azure\src\LangChain.Providers.Azure.csproj" />

src/WhisperNet/src/WhisperNetModelDownloader.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Net.Http;
12
using Whisper.net.Ggml;
23

34
namespace LangChain.Providers.WhisperNet;
@@ -21,14 +22,16 @@ public sealed class WhisperNetModelDownloader
2122
Directory.CreateDirectory(storagePath);
2223
}
2324

25+
using var httpClient = new HttpClient();
26+
var downloader = new WhisperGgmlDownloader(httpClient);
2427
if (usingCoreMl)
2528
{
26-
await WhisperGgmlDownloader.GetEncoderCoreMLModelAsync(type, cancellationToken)
29+
await downloader.GetEncoderCoreMLModelAsync(type, cancellationToken)
2730
.ExtractToPath(storagePath)
2831
.ConfigureAwait(false);
2932
}
3033

31-
using var modelStream = await WhisperGgmlDownloader.GetGgmlModelAsync(type, quantizationType, cancellationToken).ConfigureAwait(false);
34+
using var modelStream = await downloader.GetGgmlModelAsync(type, quantizationType, cancellationToken).ConfigureAwait(false);
3235

3336
#pragma warning disable CA1308
3437
var fileName = $"gglm-{type.ToString().ToLowerInvariant()}";

0 commit comments

Comments
 (0)