Skip to content

Commit

Permalink
experimenting litellm
Browse files Browse the repository at this point in the history
  • Loading branch information
semio committed Dec 31, 2024
1 parent 916aca7 commit e9c0698
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 423 deletions.
477 changes: 54 additions & 423 deletions automation-api/poetry.lock

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions litellm/batch_prompts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"model": "claude-3-sonnet-20240229",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
},
{
"role": "user",
"content": "Write a hello world program in Python"
},
{
"role": "user",
"content": "Explain what is machine learning in simple terms"
},
{
"role": "user",
"content": "What is the difference between SQL and NoSQL databases?"
},
{
"role": "user",
"content": "How do I make a chocolate cake?"
}
]
}
25 changes: 25 additions & 0 deletions litellm/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
model_list:
# For response gathering
- model_name: "claude-3-sonnet-20240229"
litellm_params:
model: "anthropic/claude-3-sonnet-20240229"
api_key: "os.environ/ANTHROPIC_API_KEY"
batch_size: 20 # Enable batch API with max 20 messages per batch

# For evaluation models
- model_name: "gpt-4"
litellm_params:
model: "openai/gpt-4"
api_key: "os.environ/OPENAI_API_KEY"

- model_name: "gemini-pro"
litellm_params:
model: "vertex_ai/gemini-pro"
project_id: "os.environ/VERTEX_PROJECT"
location: "os.environ/VERTEX_LOCATION"

general_settings:
# Enable detailed logging for debugging
debug: true
# Set a master key for proxy authentication
master_key: "os.environ/LITELLM_MASTER_KEY"
18 changes: 18 additions & 0 deletions litellm/generate_prompts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import json

prompts = [
{"role": "user", "content": "What is the capital of France?"},
{"role": "user", "content": "Write a hello world program in Python"},
{"role": "user", "content": "Explain what is machine learning in simple terms"},
{
"role": "user",
"content": "What is the difference between SQL and NoSQL databases?",
},
{"role": "user", "content": "How do I make a chocolate cake?"},
]

# Create a single batch request
batch_request = {"model": "claude-3-sonnet-20240229", "messages": prompts}

with open("batch_prompts.json", "w") as f:
json.dump(batch_request, f, indent=2)
30 changes: 30 additions & 0 deletions litellm/start_proxy.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# # Check if required environment variables are set
# if [ -z "$ANTHROPIC_API_KEY" ]; then
# echo "Error: ANTHROPIC_API_KEY is not set"
# exit 1
# fi

# if [ -z "$OPENAI_API_KEY" ]; then
# echo "Error: OPENAI_API_KEY is not set"
# exit 1
# fi

# if [ -z "$VERTEX_PROJECT" ]; then
# echo "Error: VERTEXAI_PROJECT is not set"
# exit 1
# fi

# if [ -z "$VERTEX_LOCATION" ]; then
# echo "Error: VERTEXAI_LOCATION is not set"
# exit 1
# fi

# if [ -z "$LITELLM_MASTER_KEY" ]; then
# echo "Error: LITELLM_MASTER_KEY is not set"
# exit 1
# fi

# Start the LiteLLM proxy with the config file
litellm --config config.yaml --detailed_debug
5 changes: 5 additions & 0 deletions litellm/test_prompts.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"model": "claude-3-sonnet-20240229", "messages": [{"role": "user", "content": "What is the capital of France?"}]}
{"model": "claude-3-sonnet-20240229", "messages": [{"role": "user", "content": "Write a hello world program in Python"}]}
{"model": "claude-3-sonnet-20240229", "messages": [{"role": "user", "content": "Explain what is machine learning in simple terms"}]}
{"model": "claude-3-sonnet-20240229", "messages": [{"role": "user", "content": "What is the difference between SQL and NoSQL databases?"}]}
{"model": "claude-3-sonnet-20240229", "messages": [{"role": "user", "content": "How do I make a chocolate cake?"}]}

0 comments on commit e9c0698

Please sign in to comment.