Skip to content

Commit

Permalink
docs: rewrite tracing.md (prioritize open source solution), fix misle…
Browse files Browse the repository at this point in the history
…ading info
  • Loading branch information
maciejmajek committed Sep 30, 2024
1 parent 3c5cc3d commit 236bc4e
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions docs/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ The `project` field under the `[tracing]` section sets the name for your tracing
> [!NOTE]
> Project name is currently only used by LangSmith. Langfuse will upload traces to the default project.
### LangSmith
### Langfuse (open-source)

[Langfuse](https://langfuse.com/) is an open-source observability & analytics platform for LLM applications.

To enable Langfuse tracing:

1. Set `use_langfuse = true` in the `config.toml` file.
2. Set the `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY` environment variables with your Langfuse credentials.
3. Optionally, you can specify a custom Langfuse host by modifying the `host` field under `[tracing.langfuse]`.

### LangSmith (closed-source, paid)

[LangSmith](https://www.langchain.com/langsmith) is a platform for debugging, testing, and monitoring LangChain applications.

Expand All @@ -22,23 +32,26 @@ To enable LangSmith tracing:
1. Set `use_langsmith = true` in the `config.toml` file.
2. Set the `LANGCHAIN_API_KEY` environment variable with your LangSmith API key.

When enabled, LangSmith tracing will automatically be set up with the following environment variables:

### Langfuse
## Usage

[Langfuse](https://langfuse.com/) is an open-source observability & analytics platform for LLM applications.
To enable tracing in your RAI application, you need to import the get_tracing_callbacks() function and add it to the configuration when invoking your agent or model. Here's how to do it:

To enable Langfuse tracing:
1. First, import the get_tracing_callbacks() function:

1. Set `use_langfuse = true` in the `config.toml` file.
2. Set the `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY` environment variables with your Langfuse credentials.
3. Optionally, you can specify a custom Langfuse host by modifying the `host` field under `[tracing.langfuse]`.
```python
from rai.utils.model_initialization import get_tracing_callbacks
```

## Usage
2. Then, add it to the configuration when invoking your agent or model:

The tracing configuration is automatically loaded and applied when initializing models in RAI. The `get_tracing_callbacks()` function in `model_initialization.py` sets up the appropriate callbacks based on your configuration:
```python
response = agent.invoke(
input_dict,
config={"callbacks": get_tracing_callbacks()}
)
```

This function returns a list of callback handlers that can be used with LangChain.
By adding the get_tracing_callbacks() to the config parameter, you enable tracing for that specific invocation. The get_tracing_callbacks() function returns a list of callback handlers based on your configuration in config.toml.

## Troubleshooting

Expand Down

0 comments on commit 236bc4e

Please sign in to comment.