116 lines
2.4 KiB
Markdown
116 lines
2.4 KiB
Markdown
|
|
# Guía de Uso
|
||
|
|
|
||
|
|
## Conexión
|
||
|
|
|
||
|
|
```bash
|
||
|
|
ssh -i ~/.ssh/tzzr root@localhost "sudo -u postgres psql -d architect"
|
||
|
|
```
|
||
|
|
|
||
|
|
## Consultar Contexto
|
||
|
|
|
||
|
|
### Contexto completo de un agente
|
||
|
|
```sql
|
||
|
|
SELECT get_agent_full_context('architect');
|
||
|
|
```
|
||
|
|
|
||
|
|
### Ver bloques asignados
|
||
|
|
```sql
|
||
|
|
SELECT cb.codigo, cb.tipo, aci.peso, aci.orden
|
||
|
|
FROM agent_context_index aci
|
||
|
|
JOIN context_blocks cb ON aci.block_id = cb.id
|
||
|
|
WHERE aci.agent_id = 'architect' AND aci.activo = true
|
||
|
|
ORDER BY aci.orden;
|
||
|
|
```
|
||
|
|
|
||
|
|
### Listar todos los bloques
|
||
|
|
```sql
|
||
|
|
SELECT codigo, tipo, length(contenido) as bytes, tags
|
||
|
|
FROM context_blocks
|
||
|
|
ORDER BY tipo, codigo;
|
||
|
|
```
|
||
|
|
|
||
|
|
## Añadir Bloques
|
||
|
|
|
||
|
|
### Crear nuevo bloque
|
||
|
|
```sql
|
||
|
|
INSERT INTO context_blocks (codigo, tipo, contenido, tags) VALUES
|
||
|
|
('mi_bloque', 'knowledge', 'Contenido del bloque...', '{tag1,tag2}');
|
||
|
|
```
|
||
|
|
|
||
|
|
### Asignar bloque a agente
|
||
|
|
```sql
|
||
|
|
INSERT INTO agent_context_index (agent_id, block_id, peso, orden)
|
||
|
|
SELECT 'deck', id, 0.9, 10
|
||
|
|
FROM context_blocks WHERE codigo = 'mi_bloque';
|
||
|
|
```
|
||
|
|
|
||
|
|
## Modificar Bloques
|
||
|
|
|
||
|
|
### Actualizar contenido
|
||
|
|
```sql
|
||
|
|
UPDATE context_blocks SET contenido = 'Nuevo contenido...'
|
||
|
|
WHERE codigo = 'mi_bloque';
|
||
|
|
```
|
||
|
|
|
||
|
|
### Cambiar peso/orden
|
||
|
|
```sql
|
||
|
|
UPDATE agent_context_index SET peso = 0.8, orden = 5
|
||
|
|
WHERE agent_id = 'deck'
|
||
|
|
AND block_id = (SELECT id FROM context_blocks WHERE codigo = 'mi_bloque');
|
||
|
|
```
|
||
|
|
|
||
|
|
## Desactivar Bloques
|
||
|
|
|
||
|
|
### Desactivar temporalmente
|
||
|
|
```sql
|
||
|
|
UPDATE agent_context_index SET activo = false
|
||
|
|
WHERE agent_id = 'deck'
|
||
|
|
AND block_id = (SELECT id FROM context_blocks WHERE codigo = 'mi_bloque');
|
||
|
|
```
|
||
|
|
|
||
|
|
### Bloque con expiración
|
||
|
|
```sql
|
||
|
|
INSERT INTO agent_context_index (agent_id, block_id, expires_at)
|
||
|
|
SELECT 'architect', id, NOW() + INTERVAL '1 day'
|
||
|
|
FROM context_blocks WHERE codigo = 'temporal_block';
|
||
|
|
```
|
||
|
|
|
||
|
|
## Buscar Bloques
|
||
|
|
|
||
|
|
### Por tag
|
||
|
|
```sql
|
||
|
|
SELECT * FROM context_blocks WHERE 'services' = ANY(tags);
|
||
|
|
```
|
||
|
|
|
||
|
|
### Por contenido
|
||
|
|
```sql
|
||
|
|
SELECT codigo, tipo FROM context_blocks
|
||
|
|
WHERE contenido ILIKE '%mailcow%';
|
||
|
|
```
|
||
|
|
|
||
|
|
## Estadísticas
|
||
|
|
|
||
|
|
### Bloques por tipo
|
||
|
|
```sql
|
||
|
|
SELECT tipo, COUNT(*) as cantidad
|
||
|
|
FROM context_blocks
|
||
|
|
GROUP BY tipo ORDER BY tipo;
|
||
|
|
```
|
||
|
|
|
||
|
|
### Bloques por agente
|
||
|
|
```sql
|
||
|
|
SELECT agent_id, COUNT(*) as bloques
|
||
|
|
FROM agent_context_index
|
||
|
|
WHERE activo = true
|
||
|
|
GROUP BY agent_id ORDER BY bloques DESC;
|
||
|
|
```
|
||
|
|
|
||
|
|
### Tamaño total por agente
|
||
|
|
```sql
|
||
|
|
SELECT agent_id, SUM(length(cb.contenido)) as bytes
|
||
|
|
FROM agent_context_index aci
|
||
|
|
JOIN context_blocks cb ON aci.block_id = cb.id
|
||
|
|
WHERE aci.activo = true
|
||
|
|
GROUP BY agent_id ORDER BY bytes DESC;
|
||
|
|
```
|