2025-10-25 15:59:06 -03:00
|
|
|
## Run and Talk
|
|
|
|
|
```bas
|
|
|
|
|
TALK "Welcome! How can I help you today?"
|
|
|
|
|
HEAR user_input
|
|
|
|
|
```
|
|
|
|
|
*Start the server:* `cargo run --release`
|
2025-10-25 14:50:14 -03:00
|
|
|
|
2025-10-25 15:59:06 -03:00
|
|
|
### Installation
|
|
|
|
|
```bash
|
|
|
|
|
# Clone the repository
|
|
|
|
|
git clone https://github.com/GeneralBots/BotServer.git
|
|
|
|
|
cd BotServer
|
2025-10-25 14:50:14 -03:00
|
|
|
|
2025-10-25 15:59:06 -03:00
|
|
|
# Build the project
|
|
|
|
|
cargo build --release
|
2025-10-25 14:50:14 -03:00
|
|
|
|
2025-10-25 15:59:06 -03:00
|
|
|
# Run the server
|
|
|
|
|
cargo run --release
|
|
|
|
|
```
|
2025-10-25 14:50:14 -03:00
|
|
|
|
2025-10-25 15:59:06 -03:00
|
|
|
### First Conversation
|
|
|
|
|
```bas
|
|
|
|
|
TALK "Hello! I'm your GeneralBots assistant."
|
|
|
|
|
HEAR user_input
|
|
|
|
|
IF user_input CONTAINS "weather" THEN
|
|
|
|
|
TALK "Sure, let me check the weather for you."
|
|
|
|
|
CALL GET_WEATHER
|
|
|
|
|
ELSE
|
|
|
|
|
TALK "I can help with many tasks, just ask!"
|
|
|
|
|
ENDIF
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Understanding Sessions
|
2025-11-03 20:42:38 -03:00
|
|
|
Each conversation is represented by a **BotSession** that persists across multiple interactions. The session manages:
|
2025-10-25 15:59:06 -03:00
|
|
|
|
2025-11-03 20:42:38 -03:00
|
|
|
- **User identity** (authenticated or anonymous)
|
|
|
|
|
- **Conversation history** (full message transcript)
|
|
|
|
|
- **Context state** (variables, knowledge base references, active tools)
|
|
|
|
|
- **Interaction metrics** (message counts, timing)
|
|
|
|
|
|
|
|
|
|
#### Storage Architecture
|
|
|
|
|
Sessions use a multi-layer persistence model:
|
|
|
|
|
1. **PostgreSQL** - Primary storage for all session data
|
|
|
|
|
2. **Redis** - Caching layer for active session state
|
|
|
|
|
3. **In-memory** - Hot session data for performance
|
|
|
|
|
|
|
|
|
|
#### Key API Endpoints
|
|
|
|
|
- `POST /api/sessions` - Create new session
|
|
|
|
|
- `GET /api/sessions` - List user sessions
|
|
|
|
|
- `POST /api/sessions/{id}/start` - Activate session
|
|
|
|
|
- `GET /api/sessions/{id}` - Get conversation history
|
|
|
|
|
|
|
|
|
|
#### Advanced Features
|
|
|
|
|
- **Context compaction** - Reduces memory usage for long conversations
|
|
|
|
|
- **Interaction counting** - Tracks message frequency
|
|
|
|
|
- **Multi-device sync** - Shared state across clients
|