robotframework-gemini 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/PKG-INFO +29 -22
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/README.md +28 -21
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/pyproject.toml +1 -1
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/src/robotframework_gemini/__init__.py +1 -1
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/src/robotframework_gemini/library.py +26 -2
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/.gitignore +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/LICENSE +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/src/robotframework_gemini/browser_helpers.py +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/src/robotframework_gemini/client.py +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/src/robotframework_gemini/legacy_env.py +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/src/robotframework_gemini/prompt_build.py +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/src/robotframework_gemini/response_parse.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: robotframework-gemini
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Google Gemini oracles for Robot Framework: text-only and multimodal (image) assertions.
|
|
5
5
|
Project-URL: Homepage, https://github.com/carlosnizolli/robotframework-gemini
|
|
6
6
|
Project-URL: Documentation, https://github.com/carlosnizolli/robotframework-gemini#readme
|
|
@@ -72,24 +72,26 @@ python -m pip install -e ".[dev]"
|
|
|
72
72
|
from pathlib import Path
|
|
73
73
|
from robotframework_gemini import GeminiOrchestrator
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
orchestrator = GeminiOrchestrator()
|
|
76
|
+
context = "Web dashboard with the 'Active' category filter applied."
|
|
77
|
+
evaluation = "Do the visible list items match the selected category?"
|
|
78
|
+
model_response = orchestrator.evaluate_with_image(context, evaluation, Path("screen.png"))
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
Para formato de saída restrito (ex.: Yes/No), use `extra_instructions`:
|
|
82
82
|
|
|
83
83
|
```python
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
model_response = orchestrator.evaluate_with_text(
|
|
85
|
+
context,
|
|
86
|
+
evaluation,
|
|
87
87
|
extra_instructions="Reply with one word only: Yes or No.",
|
|
88
88
|
)
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
## Uso no Robot Framework
|
|
92
92
|
|
|
93
|
+
> **Nota:** os exemplos usam `Set Variable` e `Catenate` em vez da keyword `VAR` (Robot Framework 7.0+) para manter retrocompatibilidade com versões anteriores do Robot Framework.
|
|
94
|
+
|
|
93
95
|
### Só texto (sem Browser)
|
|
94
96
|
|
|
95
97
|
```robot
|
|
@@ -98,10 +100,10 @@ Library GeminiLibrary
|
|
|
98
100
|
|
|
99
101
|
*** Keywords ***
|
|
100
102
|
Validar resposta da API
|
|
101
|
-
${
|
|
102
|
-
${
|
|
103
|
-
${
|
|
104
|
-
Log ${
|
|
103
|
+
${context}= Set Variable {"status": "ok", "items": 3}
|
|
104
|
+
${evaluation}= Set Variable O payload indica sucesso com itens?
|
|
105
|
+
${model_response}= Gemini Evaluate Text ${context} ${evaluation}
|
|
106
|
+
Log ${model_response}
|
|
105
107
|
```
|
|
106
108
|
|
|
107
109
|
### Com captura de tela (Browser)
|
|
@@ -115,10 +117,10 @@ Library GeminiLibrary
|
|
|
115
117
|
|
|
116
118
|
*** Keywords ***
|
|
117
119
|
Checar tela por critério neutro
|
|
118
|
-
${
|
|
119
|
-
${
|
|
120
|
-
${
|
|
121
|
-
Log ${
|
|
120
|
+
${context}= Set Variable Lista filtrada por status Ativo.
|
|
121
|
+
${evaluation}= Set Variable Todos os itens visíveis mostram status Ativo?
|
|
122
|
+
${model_response}= Gemini Evaluate With Screen ${context} ${evaluation}
|
|
123
|
+
Log ${model_response}
|
|
122
124
|
```
|
|
123
125
|
|
|
124
126
|
Import explícito (equivalente):
|
|
@@ -131,21 +133,26 @@ Com arquivo já salvo:
|
|
|
131
133
|
|
|
132
134
|
```robot
|
|
133
135
|
Browser.Take Screenshot ${OUTPUT_DIR}/tela.png
|
|
134
|
-
${
|
|
136
|
+
${model_response}= Gemini Evaluate With Image File ${context} ${evaluation} ${OUTPUT_DIR}/tela.png
|
|
135
137
|
```
|
|
136
138
|
|
|
137
139
|
Veredito via prompt (primeira linha) e nota 1–5:
|
|
138
140
|
|
|
139
141
|
```robot
|
|
140
|
-
${
|
|
142
|
+
${model_response}= Gemini Evaluate With Screen ${context} ${evaluation}
|
|
141
143
|
... extra_instructions=Responda com uma palavra na primeira linha: Sim ou Não.
|
|
142
|
-
${
|
|
143
|
-
Should Be Equal As Strings ${
|
|
144
|
+
${verdict}= Get Line ${model_response} 0
|
|
145
|
+
Should Be Equal As Strings ${verdict} Sim
|
|
146
|
+
|
|
147
|
+
# Nota 1–5: duas etapas (log da justificativa) ou atalho em uma linha
|
|
148
|
+
${model_response}= Gemini Evaluate Text Rating ${context} ${evaluation}
|
|
149
|
+
${rating_score}= Gemini Parse Rating ${model_response}
|
|
144
150
|
|
|
145
|
-
${
|
|
146
|
-
${score}= Gemini Parse Rating ${raw}
|
|
151
|
+
${rating_score}= Gemini Evaluate Text Rating Score ${context} ${evaluation}
|
|
147
152
|
```
|
|
148
153
|
|
|
154
|
+
Detalhes das três keywords de nota: [`docs/KEYWORDS.pt-BR.md#notas-15-três-keywords-quando-usar`](docs/KEYWORDS.pt-BR.md#notas-15-três-keywords-quando-usar).
|
|
155
|
+
|
|
149
156
|
Consulte também [`examples/demo_template.robot`](examples/demo_template.robot).
|
|
150
157
|
|
|
151
158
|
## Documentação de Keywords
|
|
@@ -38,24 +38,26 @@ python -m pip install -e ".[dev]"
|
|
|
38
38
|
from pathlib import Path
|
|
39
39
|
from robotframework_gemini import GeminiOrchestrator
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
orchestrator = GeminiOrchestrator()
|
|
42
|
+
context = "Web dashboard with the 'Active' category filter applied."
|
|
43
|
+
evaluation = "Do the visible list items match the selected category?"
|
|
44
|
+
model_response = orchestrator.evaluate_with_image(context, evaluation, Path("screen.png"))
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
Para formato de saída restrito (ex.: Yes/No), use `extra_instructions`:
|
|
48
48
|
|
|
49
49
|
```python
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
model_response = orchestrator.evaluate_with_text(
|
|
51
|
+
context,
|
|
52
|
+
evaluation,
|
|
53
53
|
extra_instructions="Reply with one word only: Yes or No.",
|
|
54
54
|
)
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
## Uso no Robot Framework
|
|
58
58
|
|
|
59
|
+
> **Nota:** os exemplos usam `Set Variable` e `Catenate` em vez da keyword `VAR` (Robot Framework 7.0+) para manter retrocompatibilidade com versões anteriores do Robot Framework.
|
|
60
|
+
|
|
59
61
|
### Só texto (sem Browser)
|
|
60
62
|
|
|
61
63
|
```robot
|
|
@@ -64,10 +66,10 @@ Library GeminiLibrary
|
|
|
64
66
|
|
|
65
67
|
*** Keywords ***
|
|
66
68
|
Validar resposta da API
|
|
67
|
-
${
|
|
68
|
-
${
|
|
69
|
-
${
|
|
70
|
-
Log ${
|
|
69
|
+
${context}= Set Variable {"status": "ok", "items": 3}
|
|
70
|
+
${evaluation}= Set Variable O payload indica sucesso com itens?
|
|
71
|
+
${model_response}= Gemini Evaluate Text ${context} ${evaluation}
|
|
72
|
+
Log ${model_response}
|
|
71
73
|
```
|
|
72
74
|
|
|
73
75
|
### Com captura de tela (Browser)
|
|
@@ -81,10 +83,10 @@ Library GeminiLibrary
|
|
|
81
83
|
|
|
82
84
|
*** Keywords ***
|
|
83
85
|
Checar tela por critério neutro
|
|
84
|
-
${
|
|
85
|
-
${
|
|
86
|
-
${
|
|
87
|
-
Log ${
|
|
86
|
+
${context}= Set Variable Lista filtrada por status Ativo.
|
|
87
|
+
${evaluation}= Set Variable Todos os itens visíveis mostram status Ativo?
|
|
88
|
+
${model_response}= Gemini Evaluate With Screen ${context} ${evaluation}
|
|
89
|
+
Log ${model_response}
|
|
88
90
|
```
|
|
89
91
|
|
|
90
92
|
Import explícito (equivalente):
|
|
@@ -97,21 +99,26 @@ Com arquivo já salvo:
|
|
|
97
99
|
|
|
98
100
|
```robot
|
|
99
101
|
Browser.Take Screenshot ${OUTPUT_DIR}/tela.png
|
|
100
|
-
${
|
|
102
|
+
${model_response}= Gemini Evaluate With Image File ${context} ${evaluation} ${OUTPUT_DIR}/tela.png
|
|
101
103
|
```
|
|
102
104
|
|
|
103
105
|
Veredito via prompt (primeira linha) e nota 1–5:
|
|
104
106
|
|
|
105
107
|
```robot
|
|
106
|
-
${
|
|
108
|
+
${model_response}= Gemini Evaluate With Screen ${context} ${evaluation}
|
|
107
109
|
... extra_instructions=Responda com uma palavra na primeira linha: Sim ou Não.
|
|
108
|
-
${
|
|
109
|
-
Should Be Equal As Strings ${
|
|
110
|
+
${verdict}= Get Line ${model_response} 0
|
|
111
|
+
Should Be Equal As Strings ${verdict} Sim
|
|
112
|
+
|
|
113
|
+
# Nota 1–5: duas etapas (log da justificativa) ou atalho em uma linha
|
|
114
|
+
${model_response}= Gemini Evaluate Text Rating ${context} ${evaluation}
|
|
115
|
+
${rating_score}= Gemini Parse Rating ${model_response}
|
|
110
116
|
|
|
111
|
-
${
|
|
112
|
-
${score}= Gemini Parse Rating ${raw}
|
|
117
|
+
${rating_score}= Gemini Evaluate Text Rating Score ${context} ${evaluation}
|
|
113
118
|
```
|
|
114
119
|
|
|
120
|
+
Detalhes das três keywords de nota: [`docs/KEYWORDS.pt-BR.md#notas-15-três-keywords-quando-usar`](docs/KEYWORDS.pt-BR.md#notas-15-três-keywords-quando-usar).
|
|
121
|
+
|
|
115
122
|
Consulte também [`examples/demo_template.robot`](examples/demo_template.robot).
|
|
116
123
|
|
|
117
124
|
## Documentação de Keywords
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "robotframework-gemini"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Google Gemini oracles for Robot Framework: text-only and multimodal (image) assertions."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
{robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/src/robotframework_gemini/library.py
RENAMED
|
@@ -162,7 +162,8 @@ class GeminiLibrary:
|
|
|
162
162
|
|
|
163
163
|
``context`` — any test evidence (API body, logs, UI text, file excerpt, etc.).
|
|
164
164
|
``evaluation`` — criterion to score (how well the evidence meets the test intent).
|
|
165
|
-
Use ``Gemini Parse Rating`` to extract
|
|
165
|
+
Returns raw model text (``SCORE:`` + ``REASON:``). Use ``Gemini Parse Rating`` to extract
|
|
166
|
+
the integer, or ``Gemini Evaluate Text Rating Score`` for a one-step score only.
|
|
166
167
|
``extra_instructions`` is appended after the built-in rubric.
|
|
167
168
|
"""
|
|
168
169
|
return self._get_orchestrator().evaluate_with_text_rating(
|
|
@@ -173,9 +174,32 @@ class GeminiLibrary:
|
|
|
173
174
|
|
|
174
175
|
@keyword("Gemini Parse Rating")
|
|
175
176
|
def gemini_parse_rating(self, raw_response: str) -> str:
|
|
176
|
-
"""Extract score 1–5 from a judge response; returns raw text if parsing fails.
|
|
177
|
+
"""Extract score 1–5 from a judge response; returns raw text if parsing fails.
|
|
178
|
+
|
|
179
|
+
Local parsing only (no API call). Works on output from ``Gemini Evaluate Text Rating``
|
|
180
|
+
or any text that follows ``SCORE:``/``NOTA:`` format.
|
|
181
|
+
"""
|
|
177
182
|
return GeminiOrchestrator.parse_rating(raw_response)
|
|
178
183
|
|
|
184
|
+
@keyword("Gemini Evaluate Text Rating Score")
|
|
185
|
+
def gemini_evaluate_text_rating_score(
|
|
186
|
+
self,
|
|
187
|
+
context: str,
|
|
188
|
+
evaluation: str,
|
|
189
|
+
extra_instructions: str | None = None,
|
|
190
|
+
) -> str:
|
|
191
|
+
"""Convenience: ``Gemini Evaluate Text Rating`` + ``Gemini Parse Rating`` in one call.
|
|
192
|
+
|
|
193
|
+
Returns only the integer score ``1``–``5`` as text. Prefer the two-step flow when you
|
|
194
|
+
need to log or assert on the full ``SCORE``/``REASON`` response from the model.
|
|
195
|
+
"""
|
|
196
|
+
model_response = self.gemini_evaluate_text_rating(
|
|
197
|
+
context,
|
|
198
|
+
evaluation,
|
|
199
|
+
extra_instructions=extra_instructions,
|
|
200
|
+
)
|
|
201
|
+
return self.gemini_parse_rating(model_response)
|
|
202
|
+
|
|
179
203
|
@keyword("Gemini Generate From Prompt")
|
|
180
204
|
def gemini_generate_from_prompt(self, prompt: str) -> str:
|
|
181
205
|
"""Send a single text prompt and return the model reply (no context/evaluation template)."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/src/robotframework_gemini/client.py
RENAMED
|
File without changes
|
{robotframework_gemini-0.2.0 → robotframework_gemini-0.3.0}/src/robotframework_gemini/legacy_env.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|