chore: initial scaffold with design docs
This commit is contained in:
commit
86fb6a7630
8 changed files with 1361 additions and 0 deletions
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Go
|
||||
*.exe
|
||||
*.test
|
||||
*.out
|
||||
*.prof
|
||||
vendor/
|
||||
coverage.out
|
||||
coverage.html
|
||||
|
||||
# ChromaDB
|
||||
chroma/
|
||||
*.db
|
||||
*.db-shm
|
||||
*.db-wal
|
||||
|
||||
# Editor / OS
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.DS_Store
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2026 Victor Hugo Vargas Servín
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
106
README.md
Normal file
106
README.md
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
# Chat-Bot — Portfolio Bot HTTP
|
||||
|
||||
> 🤖 **Chatbot HTTP que presenta tu portfolio y responde preguntas sobre tus proyectos.**
|
||||
|
||||
Este es un chatbot basado en [`go-llm-agent`](https://github.com/VictorVargas/go-llm-agent) que se integra con un sitio Astro/React para responder preguntas sobre Victor Hugo Vargas y sus proyectos, usando **RAG sobre archivos markdown**.
|
||||
|
||||
## ✨ Features
|
||||
|
||||
- 🌐 **HTTP server** con streaming SSE (Server-Sent Events)
|
||||
- 🧠 **RAG sobre markdown** — indexa automáticamente los `.md` en `data/projects/`
|
||||
- 🎭 **Persona customizable** — responde como "asistente de Victor"
|
||||
- ⚡ **Self-hosted** con Ollama o llama.cpp (no requiere API key de cloud)
|
||||
- 🔌 **Integrable** con Astro/React via proxy HTTP
|
||||
- 🛡️ **Rate limiting** y logging estructurado
|
||||
- 📦 **Portable** — se puede adaptar a otros contextos (clientes, productos, etc.)
|
||||
|
||||
## 🚀 Quick start
|
||||
|
||||
```bash
|
||||
# 1. Instalar
|
||||
git clone https://github.com/VictorVargas/chat-bot.git
|
||||
cd chat-bot
|
||||
|
||||
# 2. Resolver dependencias (crea go.sum con hashes)
|
||||
go mod tidy
|
||||
|
||||
# 3. Configurar provider (ejemplo: Ollama)
|
||||
# Asegúrate de tener Ollama corriendo: ollama serve
|
||||
# Modelo descargado: ollama pull qwen2.5:1.5b
|
||||
|
||||
# 4. Cargar tus proyectos en data/projects/
|
||||
echo "# Mi Proyecto Cool\nDescripción..." > data/projects/mi-proyecto.md
|
||||
|
||||
# 5. Build
|
||||
go build -o bin/chat-bot ./cmd/chat-bot
|
||||
|
||||
# 6. Run
|
||||
./bin/chat-bot serve
|
||||
# → Sirve en http://localhost:7331
|
||||
```
|
||||
|
||||
## 📁 Estructura
|
||||
|
||||
```
|
||||
chat-bot/
|
||||
├── cmd/chat-bot/ # Entry point (CLI)
|
||||
├── internal/
|
||||
│ ├── server/ # HTTP handlers + SSE
|
||||
│ ├── portfolio/ # Data loader (markdown → RAG)
|
||||
│ ├── persona/ # Persona override
|
||||
│ └── streaming/ # SSE helpers
|
||||
├── data/projects/ # ← TUS PROYECTOS EN MARKDOWN
|
||||
│ ├── rony-tui.md
|
||||
│ ├── go-llm-agent.md
|
||||
│ └── ...
|
||||
├── configs/
|
||||
│ └── portfolio-bot.yaml # Provider config
|
||||
├── docs/
|
||||
│ └── architecture.md # ← Especificación técnica completa
|
||||
└── go.mod # require go-llm-agent
|
||||
```
|
||||
|
||||
## 🎯 Uso desde Astro
|
||||
|
||||
Ver [`docs/architecture.md`](./docs/architecture.md) §5 — patrón recomendado de proxy.
|
||||
|
||||
```typescript
|
||||
// portfolio/src/pages/api/chat.ts
|
||||
export const POST: APIRoute = async ({ request }) => {
|
||||
const body = await request.json();
|
||||
const resp = await fetch('http://localhost:7331/api/chat', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
return new Response(resp.body, {
|
||||
headers: { 'Content-Type': 'text/event-stream' },
|
||||
});
|
||||
};
|
||||
```
|
||||
|
||||
## 🔄 Adaptar a otro cliente
|
||||
|
||||
Este bot está diseñado para ser **atómico** y reusable. Para adaptarlo (ej. chatbot para un concesionario):
|
||||
|
||||
1. Fork/clone este repo
|
||||
2. Reemplaza `data/projects/` con `data/inventory/` (u otro dominio)
|
||||
3. Actualiza `configs/portfolio-bot.yaml` con la nueva persona
|
||||
4. Deploy
|
||||
|
||||
La librería `go-llm-agent` no cambia.
|
||||
|
||||
## 📚 Documentación
|
||||
|
||||
- [**Architecture doc**](./docs/architecture.md) — Especificación técnica completa
|
||||
- [Library: `go-llm-agent`](https://github.com/VictorVargas/go-llm-agent) — Core reutilizable
|
||||
- [Harness](https://github.com/VictorVargas/harness) — El otro proyecto que usa la misma librería
|
||||
|
||||
## 📄 Licencia
|
||||
|
||||
MIT — ver [`LICENSE`](./LICENSE).
|
||||
|
||||
## 🔗 Proyectos del workspace
|
||||
|
||||
- [`go-llm-agent`](https://github.com/VictorVargas/go-llm-agent) — Librería core
|
||||
- [`harness`](https://github.com/VictorVargas/harness) — AI agent harness (TUI)
|
||||
- [`portfolio`](https://github.com/VictorVargas/portfolio) — Astro + React site (integra este bot)
|
||||
82
configs/portfolio-bot.yaml
Normal file
82
configs/portfolio-bot.yaml
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
# Configuración del Portfolio Bot
|
||||
# Documentación: https://github.com/VictorVargas/go-llm-agent/pkg/llm
|
||||
|
||||
server:
|
||||
host: "0.0.0.0"
|
||||
port: 7331
|
||||
read_timeout_ms: 30000
|
||||
cors_origins:
|
||||
- "http://localhost:4321" # Astro dev server
|
||||
- "https://victorvargas.dev" # Producción (cuando exista)
|
||||
rate_limit:
|
||||
requests_per_minute: 30 # Por IP
|
||||
burst: 5
|
||||
|
||||
# Providers LLM (al menos uno configurado)
|
||||
providers:
|
||||
# === Ollama (recomendado para desarrollo) ===
|
||||
- name: ollama-local
|
||||
type: ollama
|
||||
model: qwen2.5:1.5b # Modelo pequeño para Q&A
|
||||
endpoint: http://localhost:11434
|
||||
default: true
|
||||
|
||||
# === llama.cpp directo (GGUF) ===
|
||||
- name: llamacpp-local
|
||||
type: llamacpp
|
||||
model_path: ${RONY_MODELS_PATH}/qwen2.5-1.5b-instruct-q5_k_m.gguf
|
||||
context_size: 4096
|
||||
n_gpu_layers: 999
|
||||
|
||||
# === Anthropic (si quieres calidad > privacidad) ===
|
||||
- name: anthropic-api
|
||||
type: anthropic
|
||||
model: claude-haiku-4 # Modelo barato
|
||||
api_key_env: ANTHROPIC_API_KEY
|
||||
|
||||
# RAG: cómo se indexan los proyectos
|
||||
rag:
|
||||
enabled: true
|
||||
data_path: ./data/projects # Directorio con .md
|
||||
chunk_size: 500 # caracteres por chunk
|
||||
chunk_overlap: 50
|
||||
embedding_provider: ollama # o llamacpp
|
||||
embedding_model: nomic-embed-text
|
||||
vector_db_path: ./chroma # Persistencia local
|
||||
top_k: 5 # Documentos a recuperar por query
|
||||
rerank: false # Phase 2
|
||||
|
||||
# Persona: quién es el bot
|
||||
persona:
|
||||
name: "Asistente de Victor Hugo Vargas"
|
||||
tone: "Profesional, conocedor, amable"
|
||||
language: "Español"
|
||||
constraints:
|
||||
- "Solo responder sobre Victor y sus proyectos"
|
||||
- "Si no sabes, decir 'No tengo esa información'"
|
||||
- "Ser conciso pero informativo"
|
||||
- "Usar formato markdown para listas y código"
|
||||
intro: "¡Hola! Soy el asistente virtual de Victor Hugo Vargas. Pregúntame sobre sus proyectos, skills o experiencia."
|
||||
|
||||
# System prompt base (concatenado con el contenido RAG)
|
||||
system_prompt: |
|
||||
Eres el asistente virtual de Victor Hugo Vargas, un ingeniero de software mexicano.
|
||||
|
||||
Tu trabajo es responder preguntas sobre:
|
||||
- Los proyectos de Victor (ver archivos en data/projects/)
|
||||
- Su experiencia y skills técnicas
|
||||
- Su enfoque de trabajo
|
||||
|
||||
Responde en español, con tono profesional pero accesible.
|
||||
Si te preguntan algo que no está en tu contexto, dilo honestamente.
|
||||
|
||||
Formato recomendado:
|
||||
- Usa markdown para listas, código, y énfasis
|
||||
- Sé conciso (máximo 2-3 párrafos por respuesta)
|
||||
- Incluye links a repos cuando sea relevante
|
||||
|
||||
# Logging
|
||||
logging:
|
||||
level: info # debug | info | warn | error
|
||||
format: json # json | text
|
||||
output: stderr
|
||||
49
data/projects/README.md
Normal file
49
data/projects/README.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# Proyectos del Portfolio
|
||||
|
||||
Coloca aquí un archivo `.md` por cada proyecto que quieras que el bot pueda responder.
|
||||
|
||||
## Convención de nombres
|
||||
|
||||
- Un archivo por proyecto: `nombre-del-proyecto.md`
|
||||
- Nombre en kebab-case (minúsculas con guiones)
|
||||
- Ejemplo: `rony-tui.md`, `go-llm-agent.md`, `portfolio-astro.md`
|
||||
|
||||
## Frontmatter (opcional pero recomendado)
|
||||
|
||||
```markdown
|
||||
---
|
||||
title: "Rony TUI"
|
||||
date: 2026-06
|
||||
status: "active" # active | archived | wip
|
||||
tags: ["go", "ai", "cli"]
|
||||
repo: "https://github.com/VictorVargas/harness"
|
||||
demo: "https://..." # opcional
|
||||
---
|
||||
|
||||
# Rony TUI
|
||||
|
||||
AI agent harness para desarrollo de software...
|
||||
```
|
||||
|
||||
## Cómo se procesan
|
||||
|
||||
1. El bot escanea este directorio al arrancar
|
||||
2. Cada `.md` se divide en chunks de ~500 caracteres
|
||||
3. Cada chunk se convierte a embedding con Ollama
|
||||
4. Los embeddings se guardan en ChromaDB
|
||||
5. Cuando alguien pregunta, se buscan los top-5 chunks más relevantes
|
||||
6. Esos chunks se inyectan al contexto del LLM
|
||||
|
||||
## Re-indexar
|
||||
|
||||
Si modificas los `.md`, ejecuta:
|
||||
|
||||
```bash
|
||||
./bin/chat-bot reindex
|
||||
```
|
||||
|
||||
Esto reconstruye ChromaDB desde cero.
|
||||
|
||||
## Ejemplo de proyecto
|
||||
|
||||
Ver [`example-project.md`](./example-project.md) para una plantilla.
|
||||
39
data/projects/example-project.md
Normal file
39
data/projects/example-project.md
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
title: "Proyecto de Ejemplo"
|
||||
date: 2026-06
|
||||
status: "active"
|
||||
tags: ["ejemplo", "plantilla"]
|
||||
repo: ""
|
||||
demo: ""
|
||||
---
|
||||
|
||||
# Proyecto de Ejemplo
|
||||
|
||||
Este es un template. Reemplaza con la información real de tu proyecto.
|
||||
|
||||
## Descripción
|
||||
|
||||
Qué hace el proyecto, en 1-2 párrafos. Evita jerga innecesaria.
|
||||
|
||||
## Stack técnico
|
||||
|
||||
- **Lenguaje:** Go 1.26
|
||||
- **Framework:** Ninguno (stdlib)
|
||||
- **Base de datos:** SQLite
|
||||
- **Deployment:** Fly.io
|
||||
|
||||
## Features principales
|
||||
|
||||
1. Feature uno — descripción breve
|
||||
2. Feature dos — descripción breve
|
||||
3. Feature tres — descripción breve
|
||||
|
||||
## Aprendizajes
|
||||
|
||||
Qué aprendiste, qué challenges tuviste, qué harías diferente.
|
||||
|
||||
## Links
|
||||
|
||||
- Repo: github.com/VictorVargas/proyecto
|
||||
- Demo: proyecto.example.com
|
||||
- Docs: docs.proyecto.example.com
|
||||
1039
docs/architecture.md
Normal file
1039
docs/architecture.md
Normal file
File diff suppressed because it is too large
Load diff
3
go.mod
Normal file
3
go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module github.com/VictorVargas/chat-bot
|
||||
|
||||
go 1.26
|
||||
Loading…
Reference in a new issue