Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added open router code generator #191

Merged
merged 13 commits into from
Apr 4, 2024
Merged
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
15 changes: 11 additions & 4 deletions LangChain.sln
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LangChain.Providers.OpenRou
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LangChain.Providers.OpenRouter.Tests", "src\Providers\OpenRouter\tests\LangChain.Providers.OpenRouter.Tests.csproj", "{4C3A06A7-5603-426C-B57C-D34336679002}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LangChain.Providers.OpenRouter.CodeGenerator", "src\Providers\OpenRouter\tools\LangChain.Providers.OpenRouter.CodeGenerator\LangChain.Providers.OpenRouter.CodeGenerator.csproj", "{1BC041D3-F70D-4906-BA8F-49DB4FB7AEF0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -362,6 +364,10 @@ Global
{D0FC7D59-9535-4860-BF5B-D163AA06ECCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0FC7D59-9535-4860-BF5B-D163AA06ECCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0FC7D59-9535-4860-BF5B-D163AA06ECCF}.Release|Any CPU.Build.0 = Release|Any CPU
{679F628D-3F67-4445-A4E6-0DB66A49CB32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{679F628D-3F67-4445-A4E6-0DB66A49CB32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{679F628D-3F67-4445-A4E6-0DB66A49CB32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{679F628D-3F67-4445-A4E6-0DB66A49CB32}.Release|Any CPU.Build.0 = Release|Any CPU
{D692E628-1072-4465-9D1E-4840DC24DE97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D692E628-1072-4465-9D1E-4840DC24DE97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D692E628-1072-4465-9D1E-4840DC24DE97}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -370,10 +376,6 @@ Global
{A0851500-344B-45E3-990A-4C406E0F4006}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0851500-344B-45E3-990A-4C406E0F4006}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0851500-344B-45E3-990A-4C406E0F4006}.Release|Any CPU.Build.0 = Release|Any CPU
{679F628D-3F67-4445-A4E6-0DB66A49CB32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{679F628D-3F67-4445-A4E6-0DB66A49CB32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{679F628D-3F67-4445-A4E6-0DB66A49CB32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{679F628D-3F67-4445-A4E6-0DB66A49CB32}.Release|Any CPU.Build.0 = Release|Any CPU
{F9F8E323-5B23-43F1-ABBD-05CD0D5CAC35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9F8E323-5B23-43F1-ABBD-05CD0D5CAC35}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9F8E323-5B23-43F1-ABBD-05CD0D5CAC35}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -578,6 +580,10 @@ Global
{4C3A06A7-5603-426C-B57C-D34336679002}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C3A06A7-5603-426C-B57C-D34336679002}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C3A06A7-5603-426C-B57C-D34336679002}.Release|Any CPU.Build.0 = Release|Any CPU
{1BC041D3-F70D-4906-BA8F-49DB4FB7AEF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BC041D3-F70D-4906-BA8F-49DB4FB7AEF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BC041D3-F70D-4906-BA8F-49DB4FB7AEF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BC041D3-F70D-4906-BA8F-49DB4FB7AEF0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -692,6 +698,7 @@ Global
{7FE91F38-E133-4F58-9852-BCB6A15A82D1} = {E2B9833C-0397-4FAF-A3A8-116E58749750}
{A9442EA6-7567-4F1A-86E8-289DF51C9695} = {7FE91F38-E133-4F58-9852-BCB6A15A82D1}
{4C3A06A7-5603-426C-B57C-D34336679002} = {7FE91F38-E133-4F58-9852-BCB6A15A82D1}
{1BC041D3-F70D-4906-BA8F-49DB4FB7AEF0} = {7FE91F38-E133-4F58-9852-BCB6A15A82D1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5C00D0F1-6138-4ED9-846B-97E43D6DFF1C}
Expand Down
3 changes: 3 additions & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="HtmlAgilityPack" Version="1.11.60" />
<PackageVersion Include="HuggingFace" Version="0.2.4" />
<PackageVersion Include="LeonardoAi" Version="0.1.0" />
<PackageVersion Include="LLamaSharp" Version="0.10.0" />
Expand Down Expand Up @@ -58,6 +59,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="StackExchange.Redis" Version="2.7.20" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.Memory.Data" Version="8.0.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Text.Json" Version="8.0.0" />
Expand Down
13 changes: 9 additions & 4 deletions src/Providers/OpenRouter/src/OpenRouterModel.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
using LangChain.Providers.OpenAI;
using OpenAI.Constants;

namespace LangChain.Providers.OpenRouter;

/// <summary>
///
/// </summary>
public class OpenRouterModel:OpenAiChatModel
public class OpenRouterModel(OpenRouterProvider provider, ChatModels model):OpenAiChatModel(provider,model)
{
public OpenRouterModel(OpenRouterProvider provider,
OpenRouterModelIds id) : base(provider, OpenRouterModelProvider.GetModelById(id))
OpenRouterModelIds id) : this(provider, OpenRouterModelProvider.GetModelById(id))
{

}
public OpenRouterModel(OpenRouterProvider provider, string id):base(provider,id)
public OpenRouterModel(OpenRouterProvider provider, string id):this(provider, new ChatModels(
Id: id,
ContextLength: 0,
PricePerOutputTokenInUsd: 0.0,
PricePerInputTokenInUsd: 0.0))
{

}
Expand Down
11 changes: 7 additions & 4 deletions src/Providers/OpenRouter/src/OpenRouterModelIds.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace LangChain.Providers.OpenRouter
namespace LangChain.Providers.OpenRouter
{
/// <summary>
/// List of all the Predefined OpenRouter Models
/// </summary>
public enum OpenRouterModelIds
{
///<summary>
Expand Down Expand Up @@ -92,13 +95,13 @@ public enum OpenRouterModelIds
///<summary>
/// A fine-tune of CodeLlama-34B on an internal dataset that helps it exceed GPT-4 on some benchmarks, including HumanEval. <br/>
/// </summary>
PhindCodellama34Bv2 = 10,
PhindCodellama34BV2 = 10,


///<summary>
/// A fine-tuned model based on mistralai/Mistral-7B-v0.1 on the open source dataset Open-Orca/SlimOrca, aligned with DPO algorithm. For more details, refer to the blog: The Practice of Supervised Fine-tuning and Direct Preference Optimization on Habana Gaudi2. <br/>
/// </summary>
NeuralChat7Bv31 = 11,
NeuralChat7BV31 = 11,


///<summary>
Expand Down Expand Up @@ -557,7 +560,7 @@ public enum OpenRouterModelIds
///<summary>
/// A 75/25 merge of Chronos 13b v2 and Nous Hermes Llama2 13b. This offers the imaginative writing style of Chronos while retaining coherency. Outputs are long and use exceptional prose. #merge <br/>
/// </summary>
ChronosHermes13Bv2 = 77,
ChronosHermes13BV2 = 77,


///<summary>
Expand Down
Loading
Loading