Langfuse

If you are using Python, Javascript or other Langfuse compatible language, you can submit LLM traces to Darkraven with Langfuse SDK.

Full compatibility reference:

- Langfuse SDKs - Overview

- Langfuse Integrations - Overview

Installation

Installation guides are from Langfuse SDKs document.

pip install langfuse

Setup

  1. Create an API key in Darkraven in settings

  2. Add environment variables

  • LANGFUSE_SECRET_KEY: Your API key

  • LANGFUSE_PUBLIC_KEY: Your API key

  • LANGFUSE_HOST: Use https://api.darkraven.ai/api/dify

Usage Example

Examples are from Langfuse SDKs document.

from langfuse.decorators import observe
from langfuse.openai import openai # OpenAI integration
 
@observe()
def story():
    return openai.chat.completions.create(
        model="gpt-3.5-turbo",
        max_tokens=100,
        messages=[
          {"role": "system", "content": "You are a great storyteller."},
          {"role": "user", "content": "Once upon a time in a galaxy far, far away..."}
        ],
    ).choices[0].message.content
 
@observe()
def main():
    return story()
 
main()

Last updated