LangSharp 1.0.15
See the version list below for details.
dotnet add package LangSharp --version 1.0.15
NuGet\Install-Package LangSharp -Version 1.0.15
<PackageReference Include="LangSharp" Version="1.0.15" />
<PackageVersion Include="LangSharp" Version="1.0.15" />
<PackageReference Include="LangSharp" />
paket add LangSharp --version 1.0.15
#r "nuget: LangSharp, 1.0.15"
#addin nuget:?package=LangSharp&version=1.0.15
#tool nuget:?package=LangSharp&version=1.0.15
LangSharp SDK
LangSharp SDK is a .NET 8 library that leverages Python.NET to communicate with AI providers, utilizing powerful Python resources such as LangChain. This SDK provides a robust framework for executing Python commands and scripts within a .NET environment, enabling seamless integration with various AI services.
Table of Contents
Introduction
LangSharp SDK is designed to bridge the gap between .NET applications and Python's extensive ecosystem of AI tools. By using Python.NET, this SDK allows .NET developers to harness the power of Python libraries such as LangChain, enabling advanced AI functionalities within their .NET applications.
Features
- AI Provider Support: Communicate with AI providers like OpenAI using Python scripts.
- Chain Requests: Create chains through Python to make requests to AI providers.
Getting Started
Installation
- Install the LangSharp SDK:
dotnet add package LangSharp.SDK
Configuration
Configure the LangSharp SDK using the builder pattern in your Program.cs
:
using LangSharp.Core.Configuration;
using LangSharp.Core.Enums;
using LangSharp.MicrosoftExtensionsDI;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
// Building the SDK configuration using the LangSharpConfigurationBuilder
var sdkConfiguration = new LangSharpConfigurationBuilder()
.SetAIProvider(AIProviderType.OpenAI)
.SetModel("gpt-4o-mini")
.SetApiKey("your-openai-api-key")
.SetDatabaseUri("your-database-uri") // Optional
.Build();
// Adding the services and the SDK configuration
builder.Services.AddLangSharp(sdkConfiguration);
var app = builder.Build();
app.Run();
Usage
Executing Queries
To execute a database query using the LangSharp SDK, you can ask a question about the table:
using LangSharp.Core.Interfaces.Services;
var service = app.Services.GetService<ILangSharpService>();
string queryResult = await service.ExecuteDatabaseQueryAsync("What are the names of all users in the users table?");
Console.WriteLine(queryResult);
Calling AI Cloud
To call an AI cloud service using the LangSharp SDK:
using LangSharp.Core.Interfaces.Services;
var service = app.Services.GetService<ILangSharpService>();
string aiResponse = await service.CallAIChatAsync("What is the weather like today?");
Console.WriteLine(aiResponse);
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.3)
- python (>= 3.11.7)
- pythonnet (>= 3.0.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on LangSharp:
Package | Downloads |
---|---|
LangSharp.Examples.AspNetCore
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.18 | 0 | 5/13/2025 |
1.0.17 | 0 | 5/13/2025 |
1.0.16 | 0 | 5/12/2025 |
1.0.15 | 109 | 5/8/2025 |
1.0.14 | 125 | 5/2/2025 |
1.0.13 | 123 | 5/2/2025 |
1.0.12 | 130 | 5/2/2025 |
1.0.11 | 132 | 5/2/2025 |
1.0.10 | 134 | 5/1/2025 |
1.0.9 | 124 | 5/1/2025 |
1.0.8 | 129 | 5/1/2025 |
1.0.7 | 124 | 5/1/2025 |
1.0.6 | 132 | 5/1/2025 |
1.0.4 | 129 | 5/1/2025 |
1.0.3 | 129 | 5/1/2025 |
1.0.2 | 125 | 5/1/2025 |
1.0.1 | 131 | 5/1/2025 |
1.0.0 | 127 | 5/1/2025 |