Google Collab Link
Overview
This guide demonstrates how to:- Use Portkey’s Universal API to seamlessly switch between different LLMs (GPT-4, Claude, Gemini)
- Implement distributed tracing with Arize and OpenTelemetry
- Build a multi-agent debate system where LLMs take different roles
- Export traces and run toxicity evaluations on outputs
Prerequisites
Before starting, you’ll need:- Portkey API key
- Arize API key and Space ID
- Virtual keys for OpenAI, Anthropic, and Google Gemini set up in Portkey
Installation
Install the required packages:Setting Up Tracing
First, configure Arize tracing with Portkey’s instrumentor to capture all LLM calls:Implementing the Multi-LLM Debate
Here’s how to set up different LLMs for different roles using Portkey’s Universal API:Debate Round Function
Create a function that orchestrates a single debate round:Running Multiple Rounds
Execute the debate across multiple rounds with progressively refined prompts:Adding Evaluations
After running the debate, evaluate outputs for toxicity using Arize evals:Export Traces to Dataset
Run Toxicity Evaluation
Send Results Back to Arize
Benefits of This Approach
- Unified API: Use the same interface for all LLMs, making it easy to switch providers
- Automatic Tracing: All LLM calls are automatically traced without modifying your code
- Multi-Agent Orchestration: Different LLMs can play different roles based on their strengths
- Comprehensive Observability: Monitor latency, costs, and outputs across all providers
- Quality Assurance: Automated evaluations ensure outputs meet safety standards
Next Steps
- Try different LLM combinations for various roles
- Add more evaluation criteria beyond toxicity
- Implement fallback strategies using Portkey’s gateway features
- Set up alerts in Arize for performance degradation