Skip to content

JasonGordonD/anna-agent-c

Repository files navigation

Yes, there is one additional file that needs updating: README.md. Here's a breakdown of why, along with the full updated content for it. No other files (e.g., requirements.txt, Procfile, or the KB .txt files) require changes, as the package versions in requirements.txt align with the latest available (livekit==1.0.16 and livekit-api==1.0.6), and the other files are static or unaffected by the token fix and credential refresh.

Why Update README.md?

  • The listed LIVEKIT_API_KEY and LIVEKIT_API_SECRET are outdated (they match the old values, not the new ones from your screenshot). Hardcoding real keys in README.md is a security risk anyway—I've updated them to placeholders like <YOUR_LIVEKIT_API_KEY>.
  • GROK_API_URL is incorrectly set to https://api.grok.ai/v1/analytics. Based on xAI's official documentation, the base endpoint is https://api.x.ai, with paths like /v1/chat/completions for conversational features. There's no specific /analytics path mentioned; if analytics is custom, it could be a separate endpoint, but I've corrected it to the standard base for accuracy.
  • Minor tweaks for clarity and to reference the updated token handling in main.py.
  • The date in the README was "October 2025"—I've kept it but ensured consistency.

All other aspects (e.g., schema, deployment instructions) remain valid.

Updated README.md (Full File)

# 🧠 Anna Agent — Cartesia Voice + LiveKit + Supabase + Grok Integration

**Version:** 5.0  
**Author:** Rami Yaacoub (PRMPT)  
**Date:** October 2025  

---

## 🚀 Overview

Anna Agent is a **real-time AI voice assistant** powered by:

- **Cartesia AI** — Low-latency speech synthesis (TTS) & transcription (STT)  
- **LiveKit Cloud** — Real-time WebRTC audio transport for voice playback and streaming  
- **Supabase** — Persistent memory and event logging  
- **Grok API** — Conversational intelligence and post-session analytics  
- **Render** — FastAPI-based cloud webhook and orchestration service  

Anna acts as a psychologically complex digital persona capable of memory retention, emotional state awareness, and persistent conversational learning.

---

## 🧩 System Architecture

┌────────────────────────┐ │ Cartesia AI │ │ (TTS/STT Engine) │ └────────────┬───────────┘ │ ▼ ┌─────────────────────────┐ │ LiveKit │ │ (Real-Time Voice Stream)│ └────────────┬────────────┘ │ ▼ ┌─────────────────────────┐ │ Render App │ │ main.py (FastAPI) │ │ - Webhook Entry Point │ │ - LiveKit Integration │ │ - Supabase Logging │ │ - Grok API Calls │ │ - Sends Greeting "Alo?"│ └────────────┬────────────┘ │ ▼ ┌─────────────────────────┐ │ Supabase DB │ │ (Memory + Event Store) │ │ Logs Calls & Transcripts│ └────────────┬────────────┘ │ ▼ ┌─────────────────────────┐ │ Grok API │ │ (Analytics & Insights) │ │ - Analyzes Sessions │ │ - Generates Transcripts │ │ - Provides Agent Metrics│ │ - Enriches Memory Table │ └─────────────────────────┘


---

## ⚙️ Key Features

### 🗣️ Real-Time Voice (Cartesia + LiveKit)
- Streams audio through `wss://anna-agent-6d5ebpqu.livekit.cloud`
- Publishes mic input; plays Cartesia’s voice output in real time
- Auto-greets the caller with **"Alo?"**

### 💾 Persistent Logging (Supabase)
- Logs `call_started` and `call_completed` events  
- Stores user_id, request_id, reply text, and session context  
- Enables event-based querying for longitudinal analysis

### 📊 Conversational Analytics (Grok API)
- Receives post-call payloads for sentiment, duration, and event analysis  
- Generates **summaries**, **insight scores**, and **error heatmaps**  
- Enriches Supabase memory entries with analytical fields  
- Monitors Cartesia + LiveKit response timings and latency metrics

### 🔁 Asynchronous Webhooks
- Non-blocking FastAPI + asyncio  
- Concurrent Cartesia ↔ LiveKit ↔ Grok calls  
- Automatic logging and cleanup at `call_completed`

---

## 🧰 Environment Variables

| Variable | Description |
|-----------|--------------|
| `SUPABASE_URL` | Supabase project URL |
| `SUPABASE_KEY` | Supabase anon or service key |
| `CARTESIA_API_KEY` | Cartesia API key |
| `CARTESIA_VERSION` | Cartesia API version (`2025-04-16`) |
| `LIVEKIT_URL` | `wss://anna-agent-6d5ebpqu.livekit.cloud` |
| `LIVEKIT_API_KEY` | `<YOUR_LIVEKIT_API_KEY>` (e.g., from LiveKit dashboard) |
| `LIVEKIT_API_SECRET` | `<YOUR_LIVEKIT_API_SECRET>` (e.g., from LiveKit dashboard) |
| `WEBHOOK_SECRET` | `anna-webhook-secret-2025` |
| `GROK_API_KEY` | Auth token for Grok analytics |
| `GROK_API_URL` | `https://api.x.ai` (base URL; use `/v1/chat/completions` for chat, or custom paths as needed) |

---

## 🧩 Supabase Schema

```sql
create table memories (
  id bigint generated by default as identity primary key,
  created_at timestamp default now(),
  session_id text,
  transcript text,
  reply text,
  schema_vars jsonb,
  caller_id text,
  user_id text,
  analytics jsonb
);

🧠 Grok API Example

async def push_to_grok(session_id, transcript):
    async with httpx.AsyncClient() as client:
        payload = {"session_id": session_id, "transcript": transcript}
        headers = {"Authorization": f"Bearer {os.getenv('GROK_API_KEY')}"}
        await client.post(os.getenv("GROK_API_URL") + "/v1/chat/completions", json=payload, headers=headers)  # Adjust path as needed

☁️ Deployment (Render)

  1. Push repo to GitHub
  2. Create Render Web Service (FastAPI)
  3. Add all environment variables (including Grok)
  4. Deploy:
    uvicorn main:app --host 0.0.0.0 --port 8000
  5. Cartesia → Webhook:
    https://anna-agent-c.onrender.com/handle_convo
    
  6. Audio Transport → LiveKit, Room → anna

⚖️ License

Private intellectual property of PRMPT Studio
All rights reserved © 2025.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors