poc-v1/README.md
william.dias 5719fdbe18 feat: Add Agno tool interfaces for LLM, prompt generation, and storage operations
- Introduced LLMTool interface for LLM providers, defining methods for text generation and health checks.
- Created PromptGeneratorTool interface for generating database-specific prompts, including SQL to natural language and vice versa.
- Implemented FileStorageTool and MetadataStoreTool interfaces for file operations and metadata persistence, respectively.
- Defined core types including DatabaseType, QueryHash, and QueryMetric to support optimization flows.
- Established exception handling with specific error classes for query validation, LLM provider issues, and optimization errors.
- Added data models for optimization metadata and results, supporting serialization and versioning.
2026-01-23 09:26:57 -03:00

49 lines
1.5 KiB
Markdown

# SQL Optimizer Team (Agno)
POC de um time de agentes usando o framework **Agno** para reproduzir o fluxo do projeto oracle-sql-query-optimizer.
## Objetivo
- Receber uma SQL e o banco alvo (oracle/sqlserver/postgresql/mysql/sqlite).
- Gerar explicação detalhada (SQL → linguagem natural).
- Gerar SQL otimizada (linguagem natural → SQL), preservando 100% da lógica de negócio.
- (Opcional) Gerar análise conservadora (sem reescrever a query).
As **prompts** são mantidas idênticas às do projeto oracle-sql-query-optimizer.
## Estrutura
```text
src/
sql_optimizer_team/
team_app.py
agents/
tools/
```
## Configuração rápida
1) Crie o ambiente e instale dependências:
- `pip install -r requirements.txt`
2) Configure variáveis de ambiente (exemplo em `sample.env`).
3) Execute o servidor:
- `PYTHONPATH=src python -m main`
Acesse:
- `http://localhost:8204/docs` (Swagger UI)
- `http://localhost:8204` (informações básicas da API)
## Fluxo do time
1) **Gestor** recebe a requisição e valida o contexto (banco + SQL).
2) **SQL Analyst** gera a explicação detalhada usando a prompt original.
3) **SQL Optimizer** gera a query otimizada preservando toda a lógica.
4) **SQL Quality Reviewer** valida fidelidade e checklist.
5) **Conservative Analyst** (se solicitado) gera análise sem reescrever a query.
6) **Gestor** consolida e entrega.
## Observações
- Use o modelo configurado em variáveis de ambiente (ex.: OpenAI, Gemini, Groq, etc.).
- O time é colaborativo e mantém histórico em SQLite (configurável via env).