https://github.com/tryagi/langsmith
LangSmith C# SDK based on official LangSmith OpenAPI specification
https://github.com/tryagi/langsmith
ai api client csharp debugging dotnet generated langchain langchain-dotnet langsmith openapi sdk trace tracing
Last synced: 7 days ago
JSON representation
LangSmith C# SDK based on official LangSmith OpenAPI specification
- Host: GitHub
- URL: https://github.com/tryagi/langsmith
- Owner: tryAGI
- License: mit
- Created: 2023-08-16T08:27:19.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-12T15:07:38.000Z (2 months ago)
- Last Synced: 2025-05-13T01:16:45.552Z (2 months ago)
- Topics: ai, api, client, csharp, debugging, dotnet, generated, langchain, langchain-dotnet, langsmith, openapi, sdk, trace, tracing
- Language: C#
- Homepage: https://tryagi.github.io/LangSmith/
- Size: 3.9 MB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LangSmith SDK for .NET
[](https://www.nuget.org/packages/LangSmith/)
[](https://github.com/tryAGI/LangSmith/actions/workflows/dotnet.yml)
[](https://github.com/tryAGI/LangSmith/blob/main/LICENSE.txt)
[](https://discord.gg/Ca2xhfBf3v)## Features 🔥
- Fully generated C# SDK based on [official OpenAPI specification](https://api.smith.langchain.com/openapi.json) using [AutoSDK](https://github.com/tryAGI/AutoSDK)
- Automatic releases of new preview versions if there was an update to the OpenAPI specification
- All modern .NET features - nullability, trimming, NativeAOT, etc.
- Support .Net Framework/.Net Standard 2.0## Usage
### Initializing
```csharp
using var client = new LangSmithClient();
using var openAiClient = new OpenAiClient();client.JsonSerializerContext = new SpecialJsonSerializerContext(tryAGI.OpenAI.SourceGenerationContext.Default);
// This can be a user input to your app
var question = "Can you summarize this morning's meetings?";// This can be retrieved in a retrieval step
const string context = "During this morning's meeting, we solved all world conflict.";
var messages = new[]
{
"You are a helpful assistant. Please respond to the user's request only based on the given context."
.AsSystemMessage(),
$"Question: {question}\\nContext: {context}",
};// Create parent run
var parentRunId = Guid.NewGuid();
await client.Run.CreateRunAsync(
name: "Chat Pipeline",
runType: CreateRunRequestRunType.Chain,
id: parentRunId,
inputs: new Dictionary
{
["question"] = question,
});// Create child run
var childRunId = Guid.NewGuid();
await client.Run.CreateRunAsync(
name: "OpenAI Call",
runType: CreateRunRequestRunType.Llm,
id: childRunId,
parentRunId: parentRunId,
inputs: new Dictionary
{
["messages"] = messages,
});// Generate a completion
var chatCompletion = await openAiClient.Chat.CreateChatCompletionAsync(
model: CreateChatCompletionRequestModel.Gpt35Turbo,
messages: messages);// End runs
await client.Run.UpdateRunAsync(
runId: childRunId,
outputs: new Dictionary
{
["chatCompletion"] = chatCompletion,
},
endTime: DateTime.UtcNow.ToString("O"));
await client.Run.UpdateRunAsync(
runId: parentRunId,
outputs: new Dictionary
{
["answer"] = chatCompletion.Choices[0].Message.Content ?? string.Empty,
},
endTime: DateTime.UtcNow.ToString("O"));
```## Support
Priority place for bugs: https://github.com/tryAGI/LangSmith/issues
Priority place for ideas and general questions: https://github.com/tryAGI/LangSmith/discussions
Discord: https://discord.gg/Ca2xhfBf3v## Acknowledgments

This project is supported by JetBrains through the [Open Source Support Program](https://jb.gg/OpenSourceSupport).

This project is supported by CodeRabbit through the [Open Source Support Program](https://github.com/marketplace/coderabbitai).