Basic Monitoring
Learn how to track and monitor your LLM interactions using the Basalt SDK.
Basic monitoring is only available for prompts retrieved directly from Basalt using the get
method. This approach is designed for simple use cases where you’re using a single prompt and not complex workflows. For advanced monitoring scenarios, please refer to the Tracing documentation.
Basic Usage
When you retrieve a prompt using the SDK, it automatically includes a generation
object that can be used to monitor the complete interaction. Here’s how to use it:
This simple pattern automatically tracks:
- The prompt that was used
- When the prompt was retrieved
- When the completion was received
- The full completion text
- The total time taken for the interaction
User and Organization Identification
You can associate the generation with a specific user and organization by using the identify
method:
Evaluation
You can add automatic evaluators to assess the quality of the LLM output:
Evaluators run automatically when generation.end()
is called. For more information on available evaluators and how to create custom ones, see the Evaluation documentation.
Evaluation Configuration
By default, evaluations are run on 10% of logs. You can configure the evaluation sample rate to control how often evaluations are run.
Complete Example
Here’s a complete example showing how to use basic monitoring with variables, user identification, and automatic evaluation:
Advanced Use Cases
Basic monitoring is suitable for simple scenarios where you’re using a single prompt. For more advanced use cases, such as:
- Tracking multi-step workflows
- Monitoring prompts not stored in Basalt
- Collecting detailed metrics
- Creating custom traces
- Building complex evaluation pipelines
Please refer to the Tracing documentation, which provides comprehensive tools for these scenarios.