Skip to content

Commit df082e5

Browse files
📝 docs: add Langfuse observability to documentation (#4818)
* docs: add Langfuse observability to documentation * moved the docuement to self-hosting/advanced observability/langfuse.mdx
1 parent 7c4f0f2 commit df082e5

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
title: Observability and Tracing for LobeChat
3+
description: >-
4+
Enhance your LobeChat applications with open-source observability and tracing
5+
using Langfuse. Automatically capture detailed traces and metrics for every
6+
request to optimize and debug your chats.
7+
tags:
8+
- Observability
9+
- Tracing
10+
- Langfuse
11+
---
12+
13+
# Monitor your LobeChat application with Langfuse
14+
15+
## What is Langfuse?
16+
17+
[Langfuse](https://langfuse.com/) an **open-source LLM Observability platform**. By enabling the Langfuse integration, you can trace your application data to develop, monitor, and improve the use of LobeChat, including:
18+
19+
- Application [traces](https://langfuse.com/docs/tracing)
20+
- Usage patterns
21+
- Cost data by user and model
22+
- [Evaluations](https://langfuse.com/docs/scores/overview)
23+
24+
## Get Started
25+
26+
<Steps>
27+
28+
### Set up Langfuse
29+
30+
Get your Langfuse API key by signing up for [Langfuse Cloud](https://cloud.langfuse.com) or [self-hosting](https://langfuse.com/docs/deployment/self-host) Langfuse.
31+
32+
### Set up LobeChat
33+
34+
There are multiple ways to [self-host LobeChat](https://lobehub.com/docs/self-hosting/start). For this example, we will use the Docker Desktop deployment.
35+
36+
<Tabs items={["Environment Variables", "Example in Docker Desktop"]}>
37+
<Tab>
38+
39+
Before deploying LobeChat, set the following four environment variables with the Langfuse API keys you created in the previous step.
40+
41+
```sh
42+
ENABLE_LANGFUSE = '1'
43+
LANGFUSE_SECRET_KEY = 'sk-lf...'
44+
LANGFUSE_PUBLIC_KEY = 'pk-lf...'
45+
LANGFUSE_HOST = 'https://cloud.langfuse.com'
46+
```
47+
</Tab>
48+
49+
<Tab>
50+
51+
Before running the Docker container, set the environment variables in the Docker Desktop with the Langfuse API keys you created in the previous step.
52+
53+
<Image
54+
alt={'Environment Variables in Docker Desktop'}
55+
src={'https://langfuse.com/images/docs/lobechat-docker-desktop-env.png'}
56+
/>
57+
58+
</Tab>
59+
60+
</Tabs>
61+
62+
### Activate Analytics in Settings
63+
64+
Once you have LobeChat running, navigate to the **About** tab in the **Settings** and activate analytics. This is necessary for traces to be sent to Langfuse.
65+
66+
<Image
67+
alt={'LobeChat Settings'}
68+
src={'https://langfuse.com/images/docs/lobechat-settings.png'}
69+
/>
70+
71+
### See Chat Traces in Langfuse
72+
73+
After setting your LLM model key, you can start interacting with your LobeChat application.
74+
75+
<Image
76+
alt={'LobeChat Conversation'}
77+
src={'https://langfuse.com/images/docs/lobechat-converstation.png'}
78+
/>
79+
80+
All conversations in the chat are automatically traced and sent to Langfuse. You can view the traces in the [Traces section](https://langfuse.com/docs/tracing) in the Langfuse UI.
81+
82+
<Image
83+
alt={'LobeChat Example Trace'}
84+
src={'https://langfuse.com/images/docs/lobechat-example-trace.png'}
85+
/>
86+
_[Example trace in the Langfuse UI](https://cloud.langfuse.com/project/cloramnkj0002jz088vzn1ja4/traces/63e9246d-3f22-4e45-936d-b0c4ccf55a1e?timestamp=2024-11-26T17%3A00%3A02.028Z&observation=7ea75a0c-d9d1-425c-9b88-27561c63b413)_
87+
88+
</Steps>
89+
90+
## Feedback
91+
92+
If you have any feedback or requests, please create a GitHub [Issue](https://langfuse.com/issue) or share your work with the Langfuse community on [Discord](https://discord.langfuse.com/).

0 commit comments

Comments
 (0)