mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-18 18:18:28 +00:00
Merge pull request #2541 from udit-001/docs/chatlitellm-langfuse
docs(langfuse): add chatlitellm section
This commit is contained in:
@@ -133,3 +133,6 @@ chat(messages)
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Use LangChain ChatLiteLLM + Langfuse
|
||||
Checkout this section [here](../observability/langfuse_integration#use-langchain-chatlitellm--langfuse) for more details on how to integrate Langfuse with ChatLiteLLM.
|
||||
|
||||
@@ -132,6 +132,41 @@ print(response)
|
||||
|
||||
```
|
||||
|
||||
### Use LangChain ChatLiteLLM + Langfuse
|
||||
Pass `trace_user_id`, `session_id` in model_kwargs
|
||||
```python
|
||||
import os
|
||||
from langchain.chat_models import ChatLiteLLM
|
||||
from langchain.schema import HumanMessage
|
||||
import litellm
|
||||
|
||||
# from https://cloud.langfuse.com/
|
||||
os.environ["LANGFUSE_PUBLIC_KEY"] = ""
|
||||
os.environ["LANGFUSE_SECRET_KEY"] = ""
|
||||
|
||||
os.environ['OPENAI_API_KEY']=""
|
||||
|
||||
# set langfuse as a callback, litellm will send the data to langfuse
|
||||
litellm.success_callback = ["langfuse"]
|
||||
|
||||
chat = ChatLiteLLM(
|
||||
model="gpt-3.5-turbo"
|
||||
model_kwargs={
|
||||
"metadata": {
|
||||
"trace_user_id": "user-id2", # set langfuse Trace User ID
|
||||
"session_id": "session-1" , # set langfuse Session ID
|
||||
"tags": ["tag1", "tag2"]
|
||||
}
|
||||
}
|
||||
)
|
||||
messages = [
|
||||
HumanMessage(
|
||||
content="what model are you"
|
||||
)
|
||||
]
|
||||
chat(messages)
|
||||
```
|
||||
|
||||
|
||||
## Troubleshooting & Errors
|
||||
### Data not getting logged to Langfuse ?
|
||||
@@ -142,4 +177,4 @@ print(response)
|
||||
- [Schedule Demo 👋](https://calendly.com/d/4mp-gd3-k5k/berriai-1-1-onboarding-litellm-hosted-version)
|
||||
- [Community Discord 💭](https://discord.gg/wuPM9dRgDw)
|
||||
- Our numbers 📞 +1 (770) 8783-106 / +1 (412) 618-6238
|
||||
- Our emails ✉️ ishaan@berri.ai / krrish@berri.ai
|
||||
- Our emails ✉️ ishaan@berri.ai / krrish@berri.ai
|
||||
|
||||
Reference in New Issue
Block a user