Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

docs: update langfuse.md

Jannik Maierhöfer4ad236b0f15d
diff --git a/docs/api/language_model_clients/langfuse.md b/docs/api/language_model_clients/langfuse.md
index 05afed57f..2b453c116 100644
--- a/docs/api/language_model_clients/langfuse.md
+++ b/docs/api/language_model_clients/langfuse.md
@@ -2,7 +2,11 @@
We have now integrated Langfuse as one of the trackers.
-How to configure Langfuse?[Langfuse details](https://langfuse.com/docs/deployment/self-host) .
+## What is Langfuse?
+
+Langfuse ([GitHub](https://github.com/langfuse/langfuse)) is an open-source LLM engineering and observability platform for model [tracing](https://langfuse.com/docs/tracing), [prompt management](https://langfuse.com/docs/prompts/get-started), and application [evaluation](https://langfuse.com/docs/scores/overview). Langfuse enables teams to collaboratively debug, analyze, and refine their LLM applications.
+
+To get started, you can [self-host](https://langfuse.com/docs/deployment/self-host) Langfuse or use the Langfuse [cloud](https://cloud.langfuse.com/).
### Install Langfuse.
@@ -10,13 +14,24 @@ How to configure Langfuse?[Langfuse details](https://langfuse.com/docs/deploymen
pip install langfuse
```
-Additionally, configure the following environment variables: `LANGFUSE_SECRET_KEY`、`LANGFUSE_PUBLIC_KEY` and `LANGFUSE_HOST`.
+Next, configure the following environment variables: `LANGFUSE_SECRET_KEY`、`LANGFUSE_PUBLIC_KEY` and `LANGFUSE_HOST`. You can get your Langfuse API keys by navigating to **Project** -> **Settings** within Langfuse.
+
+```python
+import os
+
+# Get keys for your project from the project settings page
+# https://cloud.langfuse.com
+os.environ["LANGFUSE_SECRET_KEY"] = "sk-..."
+os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-..."
+os.environ["LANGFUSE_HOST"] = "https://cloud.langfuse.com" # 🇪🇺 EU region
+# os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com" # 🇺🇸 US region
+```
If you are using **openai** or **azure_openai**, your LMs are configured.
For other LM providers, you need to configure the Langfuse tracker and call it manually.
-### example
+### Example
```python
import dspy
@@ -31,7 +46,9 @@ completions = turbo("Hi,how's it going today?")
turbo.tracker_call(tracker=langfuse)
```
-## Custom Tracker
+Example trace in Langfuse: https://cloud.langfuse.com/project/cloramnkj0002jz088vzn1ja4/traces/5abece99-91bf-414e-a952-407ba8401c98
+
+### Custom Tracker
We also provide `BaseTracker`: simply inherit it and override the `call()` method
```python
@@ -44,3 +61,7 @@ class CustomTracker(BaseTracker):
pass
```
+
+### Resources
+
+Have a look at the [DSPy cookbook](https://langfuse.com/docs/integrations/dspy) in the Langfuse docs for an end-to-end example.