LangChainJSDotNet 0.1.37.1

dotnet add package LangChainJSDotNet --version 0.1.37.1                
NuGet\Install-Package LangChainJSDotNet -Version 0.1.37.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LangChainJSDotNet" Version="0.1.37.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LangChainJSDotNet --version 0.1.37.1                
#r "nuget: LangChainJSDotNet, 0.1.37.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LangChainJSDotNet as a Cake Addin
#addin nuget:?package=LangChainJSDotNet&version=0.1.37.1

// Install LangChainJSDotNet as a Cake Tool
#tool nuget:?package=LangChainJSDotNet&version=0.1.37.1                

🦜️🔗🟪 - LangChainJSDotNet

⚡ A thin .NET wrapper around the official LangChain.js library⚡

Looking for the official JS/TS or Python versions of LangChain? Check out:

🤔 What is this?

LangChainJSDotNet provides a seamless interface for .NET developers to run LangChain based code with minimal adjustments.

The official JS/TS version tracks the official Python version closely, therefore LangChain code could be easily ported and run in .NET using LangChainJSDotNet, potentially exposing all of the latest AI advancements and features from LangChain and its vast ecosystem to .NET developers.

While integrating Python code in .NET presents challenges, Microsoft's ClearScript library greatly simplifies the integration process with JavaScript code. Hence, for now, this library focuses exclusively on wrapping the JS version of LangChain.

Features

  • No porting required: Use the official LangChain.js library in .NET.
  • The latest LangChain features are readily available.
  • Async support: LangChain agents can await .NET async methods.
  • Connect from .NET to the new LangSmith Platform.
  • Debugging capability: Support for debugging LangChain.js code.

Versioning

This library employs a four-part SemVer-like version scheme. The initial three parts mirror the version of LangChain.js that the library embeds and wraps. The fourth part, always starting at 1, is reserved for incremental bug fixes or non-breaking feature additions.

For instance, v0.0.124.1 of this library embeds and wraps v0.0.124 of LangChain.js.

While the first part currently matches LangChain.js's major version, it might be repurposed in the future to also indicate major breaking changes specific to this library.

Installation

Install the LangChainJSDotNet NuGet package.

You may use the .NET command-line interface:

dotnet add package LangChainJSDotNet

This command will download and install LangChainJSDotNet along with all its required dependencies.

💡 Usage

using var langchainjs = new LangChainJS();

langchainjs.Setup(@"

    const model = new OpenAI({ openAIApiKey: 'API_KEY' });

    globalThis.run = async () => {

        const result = await model.call('What is a good name for a company that makes colorful socks?');

        console.log(result.trim());
    }
");

await langchainjs.InvokeAsync("run");
Socktacular!

Chains

using var langchainjs = new LangChainJS();

langchainjs.SetEnvironmentVariable("OPENAI_API_KEY", "API_KEY");

langchainjs.Setup(@"

    const model = new OpenAI({ temperature: 0.9 });

    const template = new PromptTemplate({
                                          template: 'What is a good name for a company that makes {product}?',
                                          inputVariables: ['product'],
                                        });

    chain = new LLMChain({ llm: model, prompt: template });

    globalThis.run = async (prompt) => {
        const res = await chain.call({ product: prompt });
        return res.text.trim();
    }
");

string result = await langchainjs.InvokeAsync<string>("run", "colorful socks");

Console.WriteLine(result);
BrightSox

Agents

See sample code for an example of a ReAct agent calling dynamic tools.

Agent input: "What is the result if you substruct 8 by foo?"...
The result is 3
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.37.1 71 6/4/2024
0.1.35.1 97 4/23/2024
0.1.26.1 110 3/12/2024
0.1.19.1 107 2/16/2024
0.1.13.1 110 2/5/2024
0.1.11.1 86 2/1/2024
0.1.9.1 85 1/29/2024
0.1.7.1 84 1/26/2024
0.0.174.1 340 10/28/2023
0.0.173.1 117 10/26/2023
0.0.171.1 116 10/24/2023
0.0.170.1 168 10/23/2023
0.0.169.1 82 10/20/2023
0.0.167.1 123 10/16/2023
0.0.165.1 108 10/11/2023
0.0.164.1 126 10/10/2023
0.0.163.1 115 10/9/2023
0.0.161.1 104 10/8/2023
0.0.156.1 151 9/29/2023
0.0.155.1 110 9/28/2023
0.0.154.1 126 9/26/2023
0.0.153.1 127 9/21/2023
0.0.152.1 123 9/21/2023
0.0.151.1 131 9/19/2023
0.0.150.1 148 9/15/2023
0.0.149.1 152 9/15/2023
0.0.148.1 148 9/13/2023
0.0.147.1 125 9/12/2023
0.0.146.1 156 9/9/2023
0.0.141.2 158 9/9/2023
0.0.139.1 170 9/1/2023
0.0.138.1 143 9/1/2023
0.0.136.1 142 8/31/2023
0.0.135.1 170 8/27/2023
0.0.134.1 162 8/25/2023
0.0.133.1 162 8/24/2023
0.0.132.1 177 8/22/2023
0.0.131.1 147 8/19/2023
0.0.126.1 210 8/11/2023
0.0.125.1 231 8/9/2023
0.0.124.1 203 8/8/2023