File size: 3,062 Bytes
09da05c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Lavazza AI Personas Frontend

A Streamlit-based frontend for the Lavazza AI Personas application.

## Features

- **Authentication**: User login and registration with token-based authentication
- **Multiple Personas**: Select and chat with different AI personas
- **Multiple Chat Sessions**: Maintain multiple concurrent chat sessions
- **RAG Context Display**: View retrieved context and citations used for responses
- **Session Management**: Create, switch between, and delete chat sessions
- **Responsive UI**: Clean and intuitive interface with custom styling

## Running the Frontend

1. **Start the backend API server** (in a separate terminal):
   ```bash
   python scripts/run_api.py
   ```

2. **Start the Streamlit frontend**:
   ```bash
   python scripts/run_frontend.py
   ```

3. **Access the application**:
   - Open your browser to `http://localhost:8501`
   - Register a new user or login with existing credentials
   - Select a persona from the sidebar
   - Start chatting

## Usage

### Authentication

1. **Register**: Create a new account with a username and token
2. **Login**: Enter your credentials to access the chat interface

### Chatting with Personas

1. **Select Persona**: Click on a persona in the sidebar to start a new chat
2. **Send Messages**: Type your message and click "Send"
3. **View Context**: Enable "Show retrieved context" in settings to see RAG data
4. **Multiple Sessions**: Switch between different chat sessions in the sidebar

### Chat Settings

- **Show retrieved context**: Display the RAG context and citations
- **Number of context documents (top-k)**: Control how many documents are retrieved (1-20)

## Features in Detail

### Multiple Chat Sessions

- Create multiple chat sessions with the same or different personas
- Switch between sessions without losing conversation history
- Delete sessions when no longer needed

### RAG Context Display

When enabled, each assistant response shows:
- **Retrieved Context**: The text chunks used to generate the response
- **Citations**: Metadata about the sources (persona, domain, category, pages, indicators)

### Session Management

- Each session has a unique ID
- Sessions persist during your browser session
- Clear chat history without deleting the session
- View message count for each session

## Troubleshooting

### Cannot connect to API server

- Ensure the backend API is running
- Check the API URL in the configuration (default: `http://localhost:8000`)

### Authentication fails

- Ensure you've registered your user first
- Check that the token matches exactly (case-sensitive)
- Verify the API server is accepting authentication requests

### No personas available

- Ensure personas are loaded in the backend
- Check the logs for any errors in the API server
- Verify the persona registry is properly initialized

## Development

To modify the frontend:

1. Edit the relevant component files in `adsp/fe/components/`
2. The app will auto-reload when you save changes (Streamlit feature)
3. Check the browser console and terminal for any errors