botserver/docs/src/chapter-08-config/config-csv.md

243 lines
6.4 KiB
Markdown
Raw Normal View History

# config.csv Format
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
The `config.csv` file is the central configuration for each bot, located in the `.gbot` package. It uses a simple name-value pair format.
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
## File Format
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
```csv
name,value
setting_name,setting_value
another_setting,another_value
2025-11-22 16:12:32 -03:00
```
2025-11-24 08:42:58 -03:00
- **Empty rows** are used for visual grouping
- **No quotes** needed for string values
- **Case-sensitive** names
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
## Core Server Settings
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
### Server Configuration
2025-11-22 16:12:32 -03:00
```csv
2025-11-24 08:42:58 -03:00
server_host,0.0.0.0
server_port,8080
sites_root,/tmp
2025-11-22 16:12:32 -03:00
```
2025-11-24 08:42:58 -03:00
| Name | Description | Default | Example |
|------|-------------|---------|---------|
| `server_host` | Bind address for the web server | `0.0.0.0` | `0.0.0.0` |
| `server_port` | Port for the web interface | `8080` | `8080` |
| `sites_root` | Directory for generated sites | `/tmp` | `/tmp` |
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
## LLM Configuration
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
### LLM Connection
```csv
llm-key,none
llm-url,http://localhost:8081
llm-model,../../../../data/llm/DeepSeek-R1-Distill-Qwen-1.5B-Q3_K_M.gguf
```
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
| Name | Description | Default | Example |
|------|-------------|---------|---------|
| `llm-key` | API key for LLM service | `none` | `none` or API key |
| `llm-url` | LLM service endpoint | `http://localhost:8081` | `http://localhost:8081` |
| `llm-model` | Path to GGUF model file | Model path | `../../../../data/llm/model.gguf` |
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
### LLM Cache Settings
```csv
llm-cache,false
llm-cache-ttl,3600
llm-cache-semantic,true
llm-cache-threshold,0.95
```
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
| Name | Description | Default | Example |
|------|-------------|---------|---------|
| `llm-cache` | Enable response caching | `false` | `true` or `false` |
| `llm-cache-ttl` | Cache TTL in seconds | `3600` | `3600` |
| `llm-cache-semantic` | Enable semantic similarity caching | `true` | `true` or `false` |
| `llm-cache-threshold` | Similarity threshold (0-1) | `0.95` | `0.95` |
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
### LLM Server Settings (when running embedded)
```csv
llm-server,false
llm-server-path,botserver-stack/bin/llm/build/bin
llm-server-host,0.0.0.0
llm-server-port,8081
llm-server-gpu-layers,0
llm-server-n-moe,0
llm-server-ctx-size,4096
llm-server-n-predict,1024
llm-server-parallel,6
llm-server-cont-batching,true
llm-server-mlock,false
llm-server-no-mmap,false
```
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
| Name | Description | Default |
|------|-------------|---------|
| `llm-server` | Run embedded LLM server | `false` |
| `llm-server-path` | Path to LLM server binaries | `botserver-stack/bin/llm/build/bin` |
| `llm-server-host` | LLM server bind address | `0.0.0.0` |
| `llm-server-port` | LLM server port | `8081` |
| `llm-server-gpu-layers` | GPU layers to offload | `0` |
| `llm-server-n-moe` | Number of MoE experts | `0` |
| `llm-server-ctx-size` | Context size in tokens | `4096` |
| `llm-server-n-predict` | Max prediction tokens | `1024` |
| `llm-server-parallel` | Parallel requests | `6` |
| `llm-server-cont-batching` | Continuous batching | `true` |
| `llm-server-mlock` | Lock model in memory | `false` |
| `llm-server-no-mmap` | Disable memory mapping | `false` |
## Prompt Settings
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
```csv
prompt-compact,4
prompt-history,2
2025-11-22 16:12:32 -03:00
```
2025-11-24 08:42:58 -03:00
| Name | Description | Default | Example |
|------|-------------|---------|---------|
| `prompt-compact` | Context compaction level | `4` | `4` |
| `prompt-history` | Messages to keep in history | Not set | `2` |
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
## Embedding Configuration
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
```csv
embedding-url,http://localhost:8082
embedding-model,../../../../data/llm/bge-small-en-v1.5-f32.gguf
2025-11-22 16:12:32 -03:00
```
2025-11-24 08:42:58 -03:00
| Name | Description | Default |
|------|-------------|---------|
| `embedding-url` | Embedding service endpoint | `http://localhost:8082` |
| `embedding-model` | Path to embedding model | Model path |
## Email Configuration
```csv
email-from,from@domain.com
email-server,mail.domain.com
email-port,587
email-user,user@domain.com
email-pass,
```
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
| Name | Description | Example |
|------|-------------|---------|
| `email-from` | Sender email address | `noreply@example.com` |
| `email-server` | SMTP server hostname | `smtp.gmail.com` |
| `email-port` | SMTP port | `587` |
| `email-user` | SMTP username | `user@example.com` |
| `email-pass` | SMTP password | Password (empty if not set) |
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
## Theme Configuration
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
```csv
theme-color1,#0d2b55
theme-color2,#fff9c2
theme-logo,https://pragmatismo.com.br/icons/general-bots.svg
theme-title,Announcements General Bots
```
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
| Name | Description | Example |
|------|-------------|---------|
| `theme-color1` | Primary theme color | `#0d2b55` |
| `theme-color2` | Secondary theme color | `#fff9c2` |
| `theme-logo` | Logo URL | `https://example.com/logo.svg` |
| `theme-title` | Bot display title | `My Bot` |
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
## Custom Database
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
```csv
custom-server,localhost
custom-port,5432
custom-database,mycustomdb
custom-username,
custom-password,
```
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
| Name | Description | Example |
|------|-------------|---------|
| `custom-server` | Database server | `localhost` |
| `custom-port` | Database port | `5432` |
| `custom-database` | Database name | `mydb` |
| `custom-username` | Database user | Username |
| `custom-password` | Database password | Password |
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
## MCP Server
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
```csv
mcp-server,false
```
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
| Name | Description | Default |
|------|-------------|---------|
| `mcp-server` | Enable MCP server | `false` |
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
## Complete Example
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
### Minimal Configuration
```csv
name,value
server_port,8080
llm-url,http://localhost:8081
llm-model,../../../../data/llm/model.gguf
```
2025-11-22 16:12:32 -03:00
2025-11-24 08:42:58 -03:00
### Production Configuration
2025-11-22 16:12:32 -03:00
```csv
2025-11-24 08:42:58 -03:00
name,value
,
server_host,0.0.0.0
server_port,443
sites_root,/var/www/sites
,
llm-key,sk-...
llm-url,https://api.openai.com
llm-model,gpt-4
,
llm-cache,true
llm-cache-ttl,7200
,
email-from,bot@company.com
email-server,smtp.company.com
email-port,587
email-user,bot@company.com
email-pass,secure_password
,
theme-title,Company Assistant
theme-color1,#003366
theme-color2,#ffffff
2025-11-22 16:12:32 -03:00
```
2025-11-24 08:42:58 -03:00
## Configuration Loading
1. Default values are applied first
2. `config.csv` values override defaults
3. Environment variables override config.csv (if implemented)
4. All values are strings - parsed as needed by the application
## Best Practices
**DO:**
- Group related settings with empty rows
- Use descriptive values
- Keep sensitive data in environment variables when possible
- Test configuration changes in development first
**DON'T:**
- Include quotes around values
- Use spaces around commas
- Leave trailing commas
- Include comments with # (use empty name field instead)
## Validation
The system validates:
- Required fields are present
- Port numbers are valid (1-65535)
- URLs are properly formatted
- File paths exist (for model files)
- Email settings are complete if email features are used