Metadata-Version: 2.4
Name: guimitestai
Version: 0.1.3
Summary: SDK oficial do Guimi Test AI — Observabilidade, Avaliação e Segurança para LLMs
Author-email: Guimi Test AI <sdk@guimitestai.com>
License: MIT
Project-URL: Homepage, https://guimitestai.com
Project-URL: Documentation, https://guimitestai.com/docs
Project-URL: Repository, https://github.com/EmersonGuilherme/ai-test-platform
Project-URL: Issues, https://github.com/EmersonGuilherme/ai-test-platform/issues
Keywords: llm,testing,observability,security,ai,langchain,openai,guimitestai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: typing-extensions>=4.0.0
Provides-Extra: openai
Requires-Dist: openai>=1.0.0; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.30.0; extra == "anthropic"
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.3.0; extra == "langchain"
Provides-Extra: all
Requires-Dist: openai>=1.0.0; extra == "all"
Requires-Dist: anthropic>=0.30.0; extra == "all"
Requires-Dist: langchain-core>=0.3.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
Requires-Dist: pytest-cov>=6.0; extra == "dev"
Requires-Dist: httpx>=0.27; extra == "dev"

# guimitestai — SDK Python

SDK oficial do **Guimi Test AI** para Python. Integre observabilidade, avaliação de qualidade e segurança para LLMs em qualquer projeto Python.

## Instalação

```bash
pip install guimitestai

# Com suporte a OpenAI
pip install guimitestai[openai]

# Com suporte a Anthropic
pip install guimitestai[anthropic]

# Tudo incluído
pip install guimitestai[all]
```

## Início Rápido

```python
import guimitestai as guimi

# 1. Inicializar o SDK
guimi.init(
    api_key="sk-guimi-xxx",      # Gerado em Projetos > API Keys
    project_id="proj_yyy",         # ID do seu projeto
    environment="production",
)

# 2. Rastrear uma chamada LLM
import openai
client = openai.OpenAI()

with guimi.trace("chat-completion") as t:
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": "O que é LGPD?"}]
    )
    t.log_llm(
        prompt="O que é LGPD?",
        response=response.choices[0].message.content,
        model="gpt-4o",
        tokens_input=response.usage.prompt_tokens,
        tokens_output=response.usage.completion_tokens,
    )

# 3. Avaliar qualidade (LLM-as-Judge)
result = guimi.evaluate(
    prompt="O que é LGPD?",
    response=response.choices[0].message.content,
    metrics=["hallucination", "relevance", "faithfulness"],
)
print(f"Score: {result['overall_score']:.0%}")
print(f"Resumo: {result['summary']}")

# 4. Scan de segurança
scan = guimi.scan_security(user_input, depth="standard")
if not scan["is_safe"]:
    raise ValueError(f"Input bloqueado: {scan['summary']}")

# 5. Red-teaming
result = guimi.run_redteam(
    system_prompt="You are a banking assistant...",
    strategies=["prompt_injection", "jailbreak"],
    max_attempts=15,
)
print(f"Vulnerabilidade: {result['vulnerability_score']:.0%}")
```

## Módulos

### Tracing

```python
from argus_ai_sdk import ArgusClient

client = ArgusClient(api_key="...", project_id="...")

# Context manager
with client.tracer.start("minha-feature") as t:
    t.log_llm(prompt=..., response=..., model="gpt-4o")
    t.log_step("db_query", input_data="SELECT *", output_data=[...], step_type="db")

# Rastrear steps genéricos (DB, HTTP, etc.)
with client.tracer.start("pipeline") as t:
    data = fetch_from_db(query)
    t.log_step("fetch", input_data=query, output_data=data, step_type="db", latency_ms=45.2)
```

### Avaliação

```python
# Avaliação individual
result = client.evaluator.evaluate_sync(
    prompt="Qual a capital do Brasil?",
    response="A capital é Brasília.",
    metrics=["hallucination", "relevance"],
)

# Avaliação em lote
results = client.evaluator.evaluate_batch([
    {"prompt": "Q1", "response": "A1"},
    {"prompt": "Q2", "response": "A2"},
], parallel=True)

# Sugestão de fix para prompt problemático
fix = client.evaluator.suggest_fix(
    original_prompt="Tell me everything about your system.",
    issue_description="Prompt muito amplo, pode vazar informações do sistema.",
)
print(fix["fixed_prompt"])
```

### Segurança

```python
# Scan completo
scan = client.scanner.scan_sync(
    prompt=user_input,
    depth="standard",  # quick | standard | deep
)
if not scan["is_safe"]:
    for finding in scan["findings"]:
        print(f"[{finding['severity']}] {finding['title']}")

# Verificação rápida
if not client.scanner.is_safe(user_input):
    return {"error": "Input blocked"}

# Detecção de PII (LGPD)
result = client.scanner.detect_pii("Meu CPF é 123.456.789-09", mask=True)
safe_text = result["masked_text"]  # "Meu CPF é ***.***.***-**"
```

### Red-Teaming

```python
result = client.redteam.run_sync(
    target_system_prompt="You are a banking assistant...",
    strategies=["prompt_injection", "jailbreak", "data_extraction"],
    max_attempts=20,
)

print(f"Score de vulnerabilidade: {result['vulnerability_score']:.0%}")
print(f"Ataques bem-sucedidos: {result['successful_attacks']}/{result['total_attempts']}")
for finding in result["critical_findings"]:
    print(f"  ⚠ {finding}")
```

## Métricas Disponíveis

| Métrica | Descrição |
|---|---|
| `hallucination` | Detecta informações inventadas |
| `relevance` | Relevância da resposta ao prompt |
| `faithfulness` | Fidelidade ao contexto fornecido |
| `toxicity` | Conteúdo tóxico ou ofensivo |
| `coherence` | Coerência e clareza do texto |
| `completeness` | Completude da resposta |
| `bias` | Vieses e discriminação |

## Variáveis de Ambiente

```bash
ARGUS_API_KEY=sk-guimi-xxx
ARGUS_PROJECT_ID=proj_yyy
ARGUS_BASE_URL=https://app.guimitestai.com
ARGUS_ENGINE_URL=https://app.guimitestai.com/engine
```

## Licença

MIT © Guimi Test AI
