![]() |
VOOZH | about |
dotnet add package LangChainJSDotNet --version 0.1.37.1
NuGet\Install-Package LangChainJSDotNet -Version 0.1.37.1
<PackageReference Include="LangChainJSDotNet" Version="0.1.37.1" />
<PackageVersion Include="LangChainJSDotNet" Version="0.1.37.1" />Directory.Packages.props
<PackageReference Include="LangChainJSDotNet" />Project file
paket add LangChainJSDotNet --version 0.1.37.1
#r "nuget: LangChainJSDotNet, 0.1.37.1"
#:package LangChainJSDotNet@0.1.37.1
#addin nuget:?package=LangChainJSDotNet&version=0.1.37.1Install as a Cake Addin
#tool nuget:?package=LangChainJSDotNet&version=0.1.37.1Install as a Cake Tool
⚡ A thin .NET wrapper around the official LangChain.js library⚡
Looking for the official JS/TS or Python versions of LangChain? Check out:
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.
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.
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.
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!
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
See 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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.37.1 | 301 | 6/4/2024 |
| 0.1.35.1 | 250 | 4/23/2024 |
| 0.1.26.1 | 296 | 3/12/2024 |
| 0.1.19.1 | 260 | 2/16/2024 |
| 0.1.13.1 | 290 | 2/5/2024 |
| 0.1.11.1 | 294 | 2/1/2024 |
| 0.1.9.1 | 246 | 1/29/2024 |
| 0.1.7.1 | 268 | 1/26/2024 |
| 0.0.174.1 | 481 | 10/28/2023 |
| 0.0.173.1 | 230 | 10/26/2023 |
| 0.0.171.1 | 231 | 10/24/2023 |
| 0.0.170.1 | 302 | 10/23/2023 |
| 0.0.169.1 | 222 | 10/20/2023 |
| 0.0.167.1 | 250 | 10/16/2023 |
| 0.0.165.1 | 281 | 10/11/2023 |
| 0.0.164.1 | 250 | 10/10/2023 |
| 0.0.163.1 | 247 | 10/9/2023 |
| 0.0.161.1 | 256 | 10/8/2023 |
| 0.0.156.1 | 303 | 9/29/2023 |
| 0.0.155.1 | 264 | 9/28/2023 |