Skip to main content

Google Gemini oracles for Robot Framework: text-only and multimodal (image) assertions.

Project description

robotframework-gemini

Biblioteca Python e keywords do Robot Framework para oráculos com Google Gemini: avaliação só texto (API, logs, JSON, etc.) ou multimodal com imagem (arquivo PNG ou captura do Robot Framework Browser).

  • Multimodal: envia o texto do prompt e a captura como Part em bytes (google-genai).
  • Fluxo recomendado: duas entradas — contexto (enquadramento do teste) e avaliação (critério ou pergunta objetiva).
  • Browser opcional: keywords de screenshot exigem Library Browser; keywords de texto funcionam sem navegador.

Instalação

pip install robotframework-gemini

Com suporte a captura via Robot Framework Browser (Playwright):

pip install "robotframework-gemini[browser]"
python -m pip install robotframework

Desenvolvimento local:

python -m pip install -e ".[dev]"

Variáveis de ambiente

Variável Função
GEMINI_API_KEY Chave da API Gemini (obrigatória se não passar api_key na Library)
GEMINI_MODEL Modelo (ex.: gemini-2.0-flash). Se omitido, usa gemini-2.0-flash.

Uso em Python (GeminiOrchestrator)

from pathlib import Path
from robotframework_gemini import GeminiOrchestrator

orc = GeminiOrchestrator()
ctx = "Web dashboard with the 'Active' category filter applied."
crit = "Do the visible list items match the selected category?"
raw = orc.evaluate_with_image(ctx, crit, Path("screen.png"))

Para formato de saída restrito (ex.: Yes/No), use extra_instructions:

raw = orc.evaluate_with_text(
    ctx,
    crit,
    extra_instructions="Reply with one word only: Yes or No.",
)

Uso no Robot Framework

Só texto (sem Browser)

*** Settings ***
Library    GeminiLibrary

*** Keywords ***
Validar resposta da API
    ${ctx}=       Set Variable    {"status": "ok", "items": 3}
    ${crit}=      Set Variable    O payload indica sucesso com itens?
    ${raw}=       Gemini Evaluate Text    ${ctx}    ${crit}
    Log    ${raw}

Com captura de tela (Browser)

Declare a biblioteca Browser antes de Gemini:

*** Settings ***
Library    Browser
Library    GeminiLibrary

*** Keywords ***
Checar tela por critério neutro
    ${ctx}=       Set Variable    Lista filtrada por status Ativo.
    ${crit}=      Set Variable    Todos os itens visíveis mostram status Ativo?
    ${raw}=       Gemini Evaluate With Screen    ${ctx}    ${crit}
    Log    ${raw}

Import explícito (equivalente):

Library    robotframework_gemini.library.GeminiLibrary

Com arquivo já salvo:

Browser.Take Screenshot    ${OUTPUT_DIR}/tela.png
${raw}=    Gemini Evaluate With Image File    ${ctx}    ${crit}    ${OUTPUT_DIR}/tela.png

Veredito via prompt (primeira linha) e nota 1–5:

${raw}=    Gemini Evaluate With Screen    ${ctx}    ${crit}
...    extra_instructions=Responda com uma palavra na primeira linha: Sim ou Não.
${v}=    Get Line    ${raw}    0
Should Be Equal As Strings    ${v}    Sim

${raw}=    Gemini Evaluate Text Rating    ${ctx}    ${criterion}
${score}=    Gemini Parse Rating    ${raw}

Consulte também examples/demo_template.robot.

Documentação de Keywords

Compatibilidade

  • BrowserGeminiLibrary permanece como alias de GeminiLibrary para suítes existentes.
  • Variáveis legadas (LLM_API_KEY, LLM_API_KEY_LIA, LLM_LIA_MODEL) são mapeadas para GEMINI_* ao importar o pacote.

Testes

pytest

Os testes usam mocks de generate_content; não há chamadas reais à API.

Licença

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework_gemini-0.2.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robotframework_gemini-0.2.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file robotframework_gemini-0.2.0.tar.gz.

File metadata

  • Download URL: robotframework_gemini-0.2.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for robotframework_gemini-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4f995a43a5e8d45670ac29174985fd2fa0b342c2d6196266ad579f5aa144ad30
MD5 0946ce274fbedbcb5f972e309ef8a4c9
BLAKE2b-256 ef169fbb49a4586dba5628a08feb4f4f06571c0f3f352088469ae4ed818328e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for robotframework_gemini-0.2.0.tar.gz:

Publisher: publish.yml on carlosnizolli/robotframework-gemini

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file robotframework_gemini-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_gemini-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 607d9a9a86bbe28e79121af3e5a4aad6eeddfd7af328147eef3266e67b664465
MD5 873af014d6566158415221997575e618
BLAKE2b-256 ded4eed561162458e885c9227d88d94f15dfd3029ccecf3dd0cffe79e8b1f1af

See more details on using hashes here.

Provenance

The following attestation bundles were made for robotframework_gemini-0.2.0-py3-none-any.whl:

Publisher: publish.yml on carlosnizolli/robotframework-gemini

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page