zborek.LangfuseDotnet 0.0.1

Suggested Alternatives

zborek.LangfuseDotnet 0.2.1

Additional Details

test message

There is a newer version of this package available.
See the version list below for details.
dotnet add package zborek.LangfuseDotnet --version 0.0.1
                    
NuGet\Install-Package zborek.LangfuseDotnet -Version 0.0.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="zborek.LangfuseDotnet" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="zborek.LangfuseDotnet" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="zborek.LangfuseDotnet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add zborek.LangfuseDotnet --version 0.0.1
                    
#r "nuget: zborek.LangfuseDotnet, 0.0.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.
#:package zborek.LangfuseDotnet@0.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=zborek.LangfuseDotnet&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=zborek.LangfuseDotnet&version=0.0.1
                    
Install as a Cake Tool

WORK IN PROGRESS

Langfuse Example Web API

This repository contains library for Langfuse in .net

In default behaviour, application add background service for sending logs to Langfuse. You can disable it by setting SendLogs to false in appsettings.json.

{
  "Langfuse": {
    "SendLogs": false
  }
}

Getting Started

Usage in Your Project

Inject LangfuseClient into your service and use it to send events to Langfuse.

For creating trace events use LangfuseTrace. Use can inject it into your service or create it.

You can use methods for creating observations:

var trace = new LangfuseTrace("traceName", TimeProvider.System);
var span = trace.CreateSpan("GetDataFromDb");
var generation = trace.CreateGeneration("DbGeneration");
var event = trace.CreateEvent("DbEvent");

// or use from created span

var eventFromSpan = span.CreateEvent("DbEvent");

Logs can be viewed on https://cloud.langfuse.com/ or on local hosted Langfuse.

Examples

  1. Clone the repository:

    git clone https://github.com/your-repo/langfuse-example-webapi.git
    cd langfuse-example-webapi
    
  2. Set api key in appsettings.json:

    {
      "Langfuse": {
        "PublicKey": "",
        "SecretKey": ""
      },
      "OpenAI": {
        "ApiKey": ""
      }
    }
    
  3. Restore dependencies:

    dotnet restore
    

Running the Application

  1. Build the project:

    dotnet build
    
  2. Run the project:

    dotnet run --project Examples/Langfuse.Example.WebApi
    

API Endpoints

  • POST /chat: Processes a chat request and returns a response.
  • POST /chatDi: Processes a chat request with dependency injection and returns a response.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Product 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 is compatible.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows 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.2.1 214 6/8/2025
0.2.0 324 3/3/2025
0.1.0 167 2/16/2025
0.0.1 714 2/7/2025 0.0.1 is deprecated because it is no longer maintained.