File size: 3,612 Bytes
6bc4708
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---

title: Customer_Support_Agent
app_file: app.py
sdk: gradio
sdk_version: 5.23.3
---


# πŸ’¬ Customer Support Assistant

An AI-powered voice + text chatbot built with [`pydantic_ai`](https://github.com/roboflow/pydantic-ai), powered by Llama 3.3 70B via Cerebras/Groq. It processes customer issues, detects emotional tone, and records support requests into a structured data table. Deployable on Gradio Spaces and usable locally with both text and audio input.

---

## ⚑ Features

- πŸ”₯ **LLM-powered form extraction** using `Agent` abstraction from `pydantic_ai`
- πŸŽ™οΈ **Voice chat** with real-time streaming via [`fastrtc`](https://github.com/Rikhil-Rai/fastrtc)
- 🧠 **Memory-aware responses** using `message_history`
- πŸ“Š **Live DataFrame updates** for structured customer requests
- πŸ’Ύ **Persistent CSV logging**
- πŸ› οΈ One-click Gradio UI with tabs for Chat + Customer Data

---

## πŸš€ Getting Started

### 1. Clone the Repo

```bash

git clone https://github.com/your-username/customer-support-assistant

cd customer-support-assistant

```

### 2. Install Dependencies

> ⚠️ Make sure you use `uv` to ensure proper dependency resolution (especially for `pydantic_ai`).



```bash

uv pip install -r requirements.txt

```



> Or use `uv` directly:



```bash

uv venv

source .venv/bin/activate

uv pip install -r requirements.txt

```



---



### 3. Setup `.env` File



Create a `.env` file in the root directory.



Refer to `settings.py` for required fields. At a minimum, you will need:



```env

CEREBRAS_API_KEY=your_api_key

CEREBRAS_BASE_URL=https://api.groq.com/openai/v1

```



You can optionally set environment variables for your own STT/TTS models as required by `fastrtc`.



---



### 4. Run the App Locally



```bash

python app.py

```



---



## 🌐 Deploy on Gradio Spaces



1. Add your `CEREBRAS_API_KEY` and `CEREBRAS_BASE_URL` as secrets in the Gradio Space.

2. Make sure `fastrtc` audio support is configured in the hardware tab.

3. Gradio Spaces will auto-launch the app via `app.py`.



---



## πŸ§ͺ Debug Tips



To simulate extraction alone:



```bash

python agents.py

```



Then type messages in the CLI to test how well the form is filled.



---



## πŸ“ File Structure



```plaintext

β”œβ”€β”€ app.py                 # Main Gradio UI

β”œβ”€β”€ agents.py              # Agent config + LLM interaction logic

β”œβ”€β”€ settings.py            # Handles env/config

β”œβ”€β”€ form_prompt.txt        # System prompt for form extraction
β”œβ”€β”€ response_prompt.txt    # System prompt for response generation

β”œβ”€β”€ data.csv               # Auto-generated CSV storage

β”œβ”€β”€ requirements.txt

β”œβ”€β”€ README.md

```



---



## 🧠 What the AI Extracts



The form agent will pull out:



- `customername`: Extracted from input or marked as `"unknown"`

- `requesttype`: e.g., `"billing"`, `"technical support"`

- `issue`: 50-line description of the issue

- `emotion`: `"angry"`, `"happy"`, etc.



---



## πŸ›‘ Known Limitations



- Longform audio may require silence-based segmentation tuning.

- This project assumes inputs are customer support related. General queries may misfire.

- Error handling is basic β€” add guards if scaling for production use.



---



## πŸ™ Credits



- Built using [pydantic_ai](https://github.com/roboflow/pydantic-ai)

- Voice support via [fastrtc](https://github.com/Rikhil-Rai/fastrtc)

- LLM backend: Llama 3.3 70B via [Groq](https://groq.com/)

- UI powered by [Gradio](https://gradio.app/)



---



## ❀️ Made with care by Rikhil