语音代理
实时语音代理应用程序,具有React前端和Python后端,基于具有RAG功能的LiveKit构建。
先决条件
- Node.js 18+和npm
- Python 3.10+
- 紫外线 包管理器
- LiveKit CLI:
winget install LiveKit.LiveKitCLI - LiveKit Cloud、Pinecone和Azure OpenAI帐户
安装
前端
cd agent-react
npm install后端
cd backend
uv sync配置
创建一个 .env 项目根目录中的文件:
VITE_LIVEKIT_URL=wss://your-project.livekit.cloud
VITE_LIVEKIT_API_KEY=your-api-key
VITE_LIVEKIT_API_SECRET=your-api-secret
PINECONE_API_KEY=your-pinecone-api-key
AZURE_OPENAI_API_KEY=your-azure-openai-key
AZURE_OPENAI_ENDPOINT=your-azure-endpoint
AZURE_OPENAI_API_VERSION=2024-02-15-preview从获取LiveKit凭据 LiveKit云仪表板 → 项目设置→ Keys.
跑步
前端
cd agent-react
npm run dev访问地址: http://localhost:3000
后端
cd backend
uv run agent.py dev
lk agent create
lk agent delete
项目结构
voice-agent/
├── agent-react/ # React frontend
├── backend/ # Python agent
│ ├── agent.py # Agent entrypoint
│ └── rag/ # RAG implementation
└── README.md