-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added DeepSeek and Together.ai Providers (#194)
* fix: fixed open router model pricings, added doc, fixed naming conventions * fix: open router provider unit test case * feat: added open router code generator * fix: some code fixes * refactor: Rearranged and documented the codes of open router code generator * fix: some fixes * feat: added command line parameters into Open Router Code Generator and some code rearrangements and refactoring. * fix: formatting issue * fix: fixed some formatting issue in the open router code generator * fix: code formatting * fix: parameter doc of GenerateCodesAsync * feat: updated anthropic sdk * feat: added function calling support for Anthropic Claude 3 models * fix: removed unused codes * fix: Anthropic dependency injection * fix: added anthropic into meta * fix: anthropic generator path * fix: anthropic generator path * feat: added Claude v2.1 and Claude instant 1.2 in the Anthropic provider. * fix: Anthropic model docs * feat: Added DeepSeek AI Provider * feat: Added proper implementation for Together.ai * fix: together.ai docs * fix: code cleanups * fix: code cleanups
- Loading branch information
Showing
21 changed files
with
1,721 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using LangChain.Providers.OpenAI; | ||
|
||
namespace LangChain.Providers.DeepSeek; | ||
|
||
/// <summary> | ||
/// </summary> | ||
public class DeepSeekConfiguration : OpenAiConfiguration | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public new const string SectionName = "DeepSeek"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using LangChain.Providers.OpenAI; | ||
|
||
namespace LangChain.Providers.DeepSeek; | ||
|
||
/// <summary> | ||
/// </summary> | ||
public class DeepSeekModel( | ||
DeepSeekProvider provider, | ||
string id) | ||
: OpenAiChatModel(provider, DeepSeekModels.GetModelById(id)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using OpenAI.Constants; | ||
|
||
namespace LangChain.Providers.DeepSeek; | ||
|
||
public static class DeepSeekModels | ||
{ | ||
/// <summary> | ||
/// Good at general tasks | ||
/// Context Length 16k | ||
/// </summary> | ||
public const string DeepSeekChat = "deepseek-chat"; | ||
|
||
/// <summary> | ||
/// Good at coding tasks | ||
/// Context Length 16k | ||
/// </summary> | ||
public const string DeepSeekCoder = "deepseek-coder"; | ||
|
||
public static ChatModels GetModelById(string id) | ||
{ | ||
switch (id) | ||
{ | ||
case DeepSeekChat: | ||
return new ChatModels(DeepSeekChat, 16 * 1000, 0, 0); | ||
case DeepSeekCoder: | ||
return new ChatModels(DeepSeekCoder, 16 * 1000, 0, 0); | ||
default: | ||
throw new NotImplementedException("Not a valid DeepSeek model."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using LangChain.Providers.OpenAI; | ||
|
||
namespace LangChain.Providers.DeepSeek; | ||
|
||
public class DeepSeekProvider : OpenAiProvider | ||
{ | ||
public DeepSeekProvider(DeepSeekConfiguration configuration) : base(configuration) | ||
{ | ||
} | ||
|
||
public DeepSeekProvider(string apiKey) : base(apiKey, "api.deepseek.com") | ||
{ | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Providers/DeepSeek/src/LangChain.Providers.DeepSeek.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net4.6.2;netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Label="Usings"> | ||
<Using Include="System.Net.Http" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup Label="NuGet"> | ||
<Description>DeepSeek Chat model provider.</Description> | ||
<PackageTags>$(PackageTags);deepseek;api</PackageTags> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Abstractions\src\LangChain.Providers.Abstractions.csproj" /> | ||
<ProjectReference Include="..\..\OpenAI\src\LangChain.Providers.OpenAI.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace LangChain.Providers.DeepSeek.Predefined; | ||
|
||
/// <inheritdoc cref="DeepSeekModels.DeepSeekChat" /> | ||
public class DeepSeekChatModel(DeepSeekProvider provider) | ||
: DeepSeekModel(provider, DeepSeekModels.DeepSeekChat); | ||
|
||
/// <inheritdoc cref="DeepSeekModels.DeepSeekChat" /> | ||
public class DeepSeekCoderModel(DeepSeekProvider provider) | ||
: DeepSeekModel(provider, DeepSeekModels.DeepSeekCoder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using LangChain.Providers.DeepSeek.Predefined; | ||
|
||
namespace LangChain.Providers.DeepSeek.Tests; | ||
|
||
[TestFixture] | ||
[Explicit] | ||
public class DeepSeekTests | ||
{ | ||
[Test] | ||
public async Task ShouldGenerateFine_WithChatModel() | ||
{ | ||
var apiKey = | ||
Environment.GetEnvironmentVariable("DeepSeek_API_Key", EnvironmentVariableTarget.User) ?? | ||
throw new InvalidOperationException("DeepSeek_API_Key is not set"); | ||
|
||
var model = new DeepSeekChatModel(new DeepSeekProvider(apiKey)); | ||
|
||
var result = await model.GenerateAsync("Write a Poem".AsHumanMessage()); | ||
|
||
result.Messages.Count.Should().BeGreaterThan(0); | ||
result.Messages.Last().Content.Should().NotBeNullOrEmpty(); | ||
Console.WriteLine(result.LastMessageContent); | ||
} | ||
|
||
[Test] | ||
public async Task ShouldGenerateFine_With_CoderModel() | ||
{ | ||
var apiKey = | ||
Environment.GetEnvironmentVariable("DeepSeek_API_Key", EnvironmentVariableTarget.User) ?? | ||
throw new InvalidOperationException("DeepSeek_API_Key is not set"); | ||
|
||
var model = new DeepSeekCoderModel(new DeepSeekProvider(apiKey)); | ||
|
||
var result = await model.GenerateAsync("Write a python script to count from 0 to 100".AsHumanMessage()); | ||
|
||
result.Messages.Count.Should().BeGreaterThan(0); | ||
result.Messages.Last().Content.Should().NotBeNullOrEmpty(); | ||
Console.WriteLine(result.LastMessageContent); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Providers/DeepSeek/tests/LangChain.Providers.DeepSeek.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\src\LangChain.Providers.DeepSeek.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Providers/TogetherAI/src/LangChain.Providers.TogetherAi.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net4.6.2;netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Label="Usings"> | ||
<Using Include="System.Net.Http" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup Label="NuGet"> | ||
<Description>Together.ai Chat model provider.</Description> | ||
<PackageTags>$(PackageTags);together;ai;together.ai;api</PackageTags> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Abstractions\src\LangChain.Providers.Abstractions.csproj" /> | ||
<ProjectReference Include="..\..\OpenAI\src\LangChain.Providers.OpenAI.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.