diff --git a/docs/assets/crewai-langtrace-spans.png b/docs/assets/crewai-langtrace-spans.png deleted file mode 100644 index 58632ea68..000000000 Binary files a/docs/assets/crewai-langtrace-spans.png and /dev/null differ diff --git a/docs/assets/crewai-langtrace-stats.png b/docs/assets/crewai-langtrace-stats.png deleted file mode 100644 index ea1f60e97..000000000 Binary files a/docs/assets/crewai-langtrace-stats.png and /dev/null differ diff --git a/docs/assets/langtrace1.png b/docs/assets/langtrace1.png new file mode 100644 index 000000000..e1d7df418 Binary files /dev/null and b/docs/assets/langtrace1.png differ diff --git a/docs/assets/langtrace2.png b/docs/assets/langtrace2.png new file mode 100644 index 000000000..22fe43578 Binary files /dev/null and b/docs/assets/langtrace2.png differ diff --git a/docs/assets/langtrace3.png b/docs/assets/langtrace3.png new file mode 100644 index 000000000..77eefbf2b Binary files /dev/null and b/docs/assets/langtrace3.png differ diff --git a/docs/how-to/Langtrace-Observability.md b/docs/how-to/Langtrace-Observability.md index 29949bbae..168f7e340 100644 --- a/docs/how-to/Langtrace-Observability.md +++ b/docs/how-to/Langtrace-Observability.md @@ -7,10 +7,14 @@ description: How to monitor cost, latency, and performance of CrewAI Agents usin Langtrace is an open-source, external tool that helps you set up observability and evaluations for Large Language Models (LLMs), LLM frameworks, and Vector Databases. While not built directly into CrewAI, Langtrace can be used alongside CrewAI to gain deep visibility into the cost, latency, and performance of your CrewAI Agents. This integration allows you to log hyperparameters, monitor performance regressions, and establish a process for continuous improvement of your Agents. +![Overview of a select series of agent session runs](..%2Fassets%2Flangtrace1.png) +![Overview of agent traces](..%2Fassets%2Flangtrace2.png) +![Overview of llm traces in details](..%2Fassets%2Flangtrace3.png) + ## Setup Instructions 1. Sign up for [Langtrace](https://langtrace.ai/) by visiting [https://langtrace.ai/signup](https://langtrace.ai/signup). -2. Create a project and generate an API key. +2. Create a project, set the project type to crewAI & generate an API key. 3. Install Langtrace in your CrewAI project using the following commands: ```bash @@ -32,58 +36,29 @@ langtrace.init(api_key='') from crewai import Agent, Task, Crew ``` -2. Create your CrewAI agents and tasks as usual. - -3. Use Langtrace's tracking functions to monitor your CrewAI operations. For example: - -```python -with langtrace.trace("CrewAI Task Execution"): - result = crew.kickoff() -``` - ### Features and Their Application to CrewAI 1. **LLM Token and Cost Tracking** + - Monitor the token usage and associated costs for each CrewAI agent interaction. - - Example: - ```python - with langtrace.trace("Agent Interaction"): - agent_response = agent.execute(task) - ``` 2. **Trace Graph for Execution Steps** + - Visualize the execution flow of your CrewAI tasks, including latency and logs. - Useful for identifying bottlenecks in your agent workflows. 3. **Dataset Curation with Manual Annotation** + - Create datasets from your CrewAI task outputs for future training or evaluation. - - Example: - ```python - langtrace.log_dataset_item(task_input, agent_output, {"task_type": "research"}) - ``` 4. **Prompt Versioning and Management** + - Keep track of different versions of prompts used in your CrewAI agents. - Useful for A/B testing and optimizing agent performance. 5. **Prompt Playground with Model Comparisons** + - Test and compare different prompts and models for your CrewAI agents before deployment. 6. **Testing and Evaluations** - Set up automated tests for your CrewAI agents and tasks. - - Example: - ```python - langtrace.evaluate(agent_output, expected_output, "accuracy") - ``` - -## Monitoring New CrewAI Features - -CrewAI has introduced several new features that can be monitored using Langtrace: - -1. **Code Execution**: Monitor the performance and output of code executed by agents. - ```python - with langtrace.trace("Agent Code Execution"): - code_output = agent.execute_code(code_snippet) - ``` - -2. **Third-party Agent Integration**: Track interactions with LlamaIndex, LangChain, and Autogen agents. \ No newline at end of file