import requests
import json
from datetime import datetime, timezone
def evaluate_with_transcript_data():
"""Example of evaluating a call with inline transcript data"""
api_key = "your-api-key-here"
base_url = "https://api.getbluejay.ai/v1"
# Sample transcript data
transcript = [
{
"start_offset_ms": 100,
"end_offset_ms": 1000,
"speaker": "AGENT",
"utterance": "Hello! Thank you for calling Bluejay support. How can I help you today?"
},
{
"start_offset_ms": 1000,
"end_offset_ms": 2000,
"speaker": "USER",
"utterance": "Hi, I'm having trouble with my recent order. It says it's delayed but I haven't received any updates."
},
{
"start_offset_ms": 2000,
"end_offset_ms": 3000,
"speaker": "AGENT",
"utterance": "I'd be happy to help you with that. Can you please provide your order number?"
},
{
"start_offset_ms": 3000,
"end_offset_ms": 4000,
"speaker": "USER",
"utterance": "Sure, it's BJ-2024-001-5678."
},
{
"start_offset_ms": 4000,
"end_offset_ms": 5000,
"speaker": "AGENT",
"utterance": "Thank you. Let me look that up for you. I can see your order is currently in transit and should arrive by tomorrow. The tracking information shows it's being processed through our fulfillment center."
}
]
call_data = {
"agent_id": "123",
"transcript": transcript,
"start_time_utc": "2024-01-15T10:00:00Z",
"participants": [
{
"role": "USER",
"spoke_first": False
},
{
"role": "AGENT",
"spoke_first": True
}
]
}
# Submit for evaluation
headers = {
"X-API-Key": api_key,
"Content-Type": "application/json"
}
response = requests.post(
f"{base_url}/evaluate",
headers=headers,
json=call_data
)
if response.status_code == 200:
result = response.json()
print("Evaluation submitted successfully!")
print(f"Call ID: {result['call_id']}")
print(f"Status: {result['status']}")
return result
else:
print(f"Error submitting evaluation: {response.text}")
return None
def evaluate_audio_with_transcript_file():
"""Example of evaluating a call with a transcript file URL"""
api_key = "your-api-key-here"
base_url = "https://api.getbluejay.ai/v1"
call_data = {
"agent_id": "123",
"recording_url": "https://storage.example.com/audio.mp3",
"transcript_url": "https://storage.example.com/transcript.json",
"start_time_utc": datetime.now(timezone.utc).isoformat(),
"participants": [
{
"role": "USER",
"spoke_first": False
},
{
"role": "AGENT",
"spoke_first": True
}
],
}
headers = {
"X-API-Key": api_key,
"Content-Type": "application/json"
}
response = requests.post(
f"{base_url}/evaluate",
headers=headers,
json=call_data
)
return response.json()