dex-connector-google-gemini 0.1.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.
Files changed (27) hide show
  1. dex_connector_google_gemini-0.1.0/.gitignore +6 -0
  2. dex_connector_google_gemini-0.1.0/LICENSE +21 -0
  3. dex_connector_google_gemini-0.1.0/PKG-INFO +63 -0
  4. dex_connector_google_gemini-0.1.0/README.md +51 -0
  5. dex_connector_google_gemini-0.1.0/examples/generate_summary/__init__.py +3 -0
  6. dex_connector_google_gemini-0.1.0/examples/generate_summary/flow.py +222 -0
  7. dex_connector_google_gemini-0.1.0/examples/generate_summary/worker.py +76 -0
  8. dex_connector_google_gemini-0.1.0/pyproject.toml +37 -0
  9. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/__init__.py +58 -0
  10. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/_generated/__init__.py +2 -0
  11. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/_generated/config.py +25 -0
  12. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/_generated/connection.py +129 -0
  13. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/_generated/definitions.py +43 -0
  14. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/_generated/mock.py +98 -0
  15. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/_generated/models.py +132 -0
  16. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/_generated/steps.py +84 -0
  17. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/client.py +586 -0
  18. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/connection.py +113 -0
  19. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/dex-connector.json +54 -0
  20. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/geminimock/__init__.py +131 -0
  21. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/models.py +82 -0
  22. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/py.typed +0 -0
  23. dex_connector_google_gemini-0.1.0/src/dex_connectors/google_gemini/steps.py +86 -0
  24. dex_connector_google_gemini-0.1.0/tests/test_conformance.py +63 -0
  25. dex_connector_google_gemini-0.1.0/tests/test_manifest_contract.py +141 -0
  26. dex_connector_google_gemini-0.1.0/tests/test_operations.py +381 -0
  27. dex_connector_google_gemini-0.1.0/uv.lock +932 -0
@@ -0,0 +1,6 @@
1
+ /.dex-local/dexcli
2
+ /.dex-local/dex-server-zd
3
+ /.dex-local/data/
4
+ /.dex-local/cli.log
5
+ /.dex-local/visualize.json
6
+ /.dex-local/visualize.err
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Super Durable
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.5
2
+ Name: dex-connector-google-gemini
3
+ Version: 0.1.0
4
+ Summary: Gemini connector for Dex Flows
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: dex-connectors-sdk==0.1.0
9
+ Requires-Dist: dex-python-sdk>=1.28.0
10
+ Requires-Dist: httpx>=0.27
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Gemini connector for Python
14
+
15
+ Install with `pip install dex-connector-google-gemini==0.1.0`. The package
16
+ requires `dex-connectors-sdk==0.1.0` and `dex-python-sdk>=1.28.0`, is imported as
17
+ `dex_connectors.google_gemini`, and implements the manifest Query
18
+ `generateContent` with the same branches, defaults, request checks, and failure
19
+ classification as the Go module.
20
+
21
+ ## Operation
22
+
23
+ | Operation | Factory | Happy branch | Optional branches |
24
+ | --- | --- | --- | --- |
25
+ | `generateContent` | `new_generate_content_step` | `generated` | `truncated`, `blocked`, `providerRejected`, `invalidResponse`, `defect` |
26
+
27
+ `generateContent` posts to `<endpoint>/models/<model>:generateContent`. A blank
28
+ request model uses the connection's model, and a `models/` prefix is accepted.
29
+ A response JSON Schema implies `application/json`. The first candidate's
30
+ non-thought text selects `generated` on `STOP`, `truncated` on `MAX_TOKENS`, and
31
+ `blocked` on a prompt block reason or a content-policy finish reason.
32
+
33
+ Generation is billed, so the operation uses sync durability, a 300-second
34
+ Execute and heartbeat timeout, and at most three attempts within ten minutes.
35
+ HTTP 408, 429, and 5xx other than 501 retry, honoring Google's `RetryInfo`
36
+ delay or `Retry-After` up to one hour; other statuses select
37
+ `providerRejected`, with authentication for 401 or `API_KEY_INVALID`.
38
+
39
+ `configuration_ui` accepts the `modelPicker` unit (`UI_UNIT_MODEL_PICKER`),
40
+ whose `model` port binds to the request's `/model`.
41
+
42
+ ## Authorization
43
+
44
+ Create a Dex Web connection named `gemini-api` as described in the
45
+ [connector README](../README.md#connection). The API key travels only in the
46
+ `x-goog-api-key` header and is resolved for every attempt.
47
+
48
+ ## Example
49
+
50
+ [`examples/generate_summary`](examples/generate_summary/flow.py) asks Gemini
51
+ for a structured JSON summary, honoring the Step's model pick. Run the Worker
52
+ with `uv run python -m examples.generate_summary.worker` after `dexcli dev`
53
+ has loaded a project containing the `gemini-api` connection.
54
+
55
+ ## Tests
56
+
57
+ `geminimock.Mock` scripts the operation and defaults to the manifest's
58
+ `launchSummary` answer; `validate_generate_content_mock_request` and
59
+ `validate_generate_content_mock_answer` apply the Go mock checks. Run
60
+ `uv run pytest tests` for provider parity and manifest contract checks.
61
+ The conformance test replays the Go-recorded provider exchanges in
62
+ [`conformance/connectors/google/gemini/scenarios.json`](../../../../conformance/connectors/google/gemini/scenarios.json),
63
+ including request headers, every branch, Retry, and transport failure.
@@ -0,0 +1,51 @@
1
+ # Gemini connector for Python
2
+
3
+ Install with `pip install dex-connector-google-gemini==0.1.0`. The package
4
+ requires `dex-connectors-sdk==0.1.0` and `dex-python-sdk>=1.28.0`, is imported as
5
+ `dex_connectors.google_gemini`, and implements the manifest Query
6
+ `generateContent` with the same branches, defaults, request checks, and failure
7
+ classification as the Go module.
8
+
9
+ ## Operation
10
+
11
+ | Operation | Factory | Happy branch | Optional branches |
12
+ | --- | --- | --- | --- |
13
+ | `generateContent` | `new_generate_content_step` | `generated` | `truncated`, `blocked`, `providerRejected`, `invalidResponse`, `defect` |
14
+
15
+ `generateContent` posts to `<endpoint>/models/<model>:generateContent`. A blank
16
+ request model uses the connection's model, and a `models/` prefix is accepted.
17
+ A response JSON Schema implies `application/json`. The first candidate's
18
+ non-thought text selects `generated` on `STOP`, `truncated` on `MAX_TOKENS`, and
19
+ `blocked` on a prompt block reason or a content-policy finish reason.
20
+
21
+ Generation is billed, so the operation uses sync durability, a 300-second
22
+ Execute and heartbeat timeout, and at most three attempts within ten minutes.
23
+ HTTP 408, 429, and 5xx other than 501 retry, honoring Google's `RetryInfo`
24
+ delay or `Retry-After` up to one hour; other statuses select
25
+ `providerRejected`, with authentication for 401 or `API_KEY_INVALID`.
26
+
27
+ `configuration_ui` accepts the `modelPicker` unit (`UI_UNIT_MODEL_PICKER`),
28
+ whose `model` port binds to the request's `/model`.
29
+
30
+ ## Authorization
31
+
32
+ Create a Dex Web connection named `gemini-api` as described in the
33
+ [connector README](../README.md#connection). The API key travels only in the
34
+ `x-goog-api-key` header and is resolved for every attempt.
35
+
36
+ ## Example
37
+
38
+ [`examples/generate_summary`](examples/generate_summary/flow.py) asks Gemini
39
+ for a structured JSON summary, honoring the Step's model pick. Run the Worker
40
+ with `uv run python -m examples.generate_summary.worker` after `dexcli dev`
41
+ has loaded a project containing the `gemini-api` connection.
42
+
43
+ ## Tests
44
+
45
+ `geminimock.Mock` scripts the operation and defaults to the manifest's
46
+ `launchSummary` answer; `validate_generate_content_mock_request` and
47
+ `validate_generate_content_mock_answer` apply the Go mock checks. Run
48
+ `uv run pytest tests` for provider parity and manifest contract checks.
49
+ The conformance test replays the Go-recorded provider exchanges in
50
+ [`conformance/connectors/google/gemini/scenarios.json`](../../../../conformance/connectors/google/gemini/scenarios.json),
51
+ including request headers, every branch, Retry, and transport failure.
@@ -0,0 +1,3 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Gemini generate summary example Flow."""
@@ -0,0 +1,222 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Runnable Flow that asks Gemini for a structured JSON summary through generateContent."""
4
+
5
+ import json
6
+ from dataclasses import dataclass, field, replace
7
+ from typing import Any
8
+
9
+ import dex
10
+ from dex_connectors.sdk import ConnectorConfigurationUI, ConnectorUIBinding, ConnectorUIUnit, QueryResult
11
+
12
+ from dex_connectors.google_gemini import (
13
+ GENERATE_CONTENT_DEFINITION,
14
+ UI_MODEL_PICKER_PORT_MODEL,
15
+ UI_UNIT_MODEL_PICKER,
16
+ Connection,
17
+ Content,
18
+ GenerateContentRequest,
19
+ GenerateContentResponse,
20
+ Part,
21
+ Usage,
22
+ new_generate_content_step,
23
+ )
24
+
25
+ FLOW_TYPE = "GeminiGenerateSummary"
26
+ CONNECTION_NAME = "gemini-api"
27
+ GENERATE_SUMMARY_STEP_TYPE = "GenerateSummary"
28
+ SUMMARY_OPERATION_ID = GENERATE_CONTENT_DEFINITION.operation.operation_id
29
+ STATUS_GENERATED = "generated"
30
+ _MAX_TITLE_CHARACTERS = 200
31
+ _MAX_TEXT_BYTES = 64 << 10
32
+ _MAX_SUMMARY_OUTPUT_TOKENS = 4096
33
+
34
+
35
+ @dataclass(frozen=True, slots=True)
36
+ class SummaryRequest:
37
+ """Title of at most 200 characters and text of at most 64 KiB."""
38
+
39
+ title: str = ""
40
+ text: str = ""
41
+
42
+
43
+ @dataclass(frozen=True, slots=True)
44
+ class Summary:
45
+ """The structured summary Gemini returns: headline, two-sentence summary, and up to five key points."""
46
+
47
+ headline: str = ""
48
+ summary: str = ""
49
+ key_points: tuple[str, ...] = field(default=(), metadata={"dex_json_name": "keyPoints"})
50
+
51
+
52
+ @dataclass(frozen=True, slots=True)
53
+ class SummaryOutcome:
54
+ """Status, title, the parsed summary, and Gemini's finish reason, model version, and usage."""
55
+
56
+ status: str = ""
57
+ title: str = ""
58
+ summary: Summary | None = field(default=None, metadata={"dex_json_omit_default": True})
59
+ finish_reason: str = field(
60
+ default="", metadata={"dex_json_name": "finishReason", "dex_json_omit_default": True}
61
+ )
62
+ block_reason: str = field(
63
+ default="", metadata={"dex_json_name": "blockReason", "dex_json_omit_default": True}
64
+ )
65
+ model_version: str = field(
66
+ default="", metadata={"dex_json_name": "modelVersion", "dex_json_omit_default": True}
67
+ )
68
+ usage: Usage = field(default_factory=Usage)
69
+
70
+
71
+ @dataclass(frozen=True, slots=True)
72
+ class SummaryModelConfiguration:
73
+ """Model chosen in Dex Web's model picker; blank uses the connection's model."""
74
+
75
+ model: str = ""
76
+
77
+
78
+ _REQUEST = dex.Attribute("gemini-summary-request", SummaryRequest)
79
+ _OUTCOME = dex.Attribute("gemini-summary-outcome", SummaryOutcome)
80
+
81
+
82
+ def summary_schema() -> dict[str, Any]:
83
+ """Return the JSON Schema Gemini must follow for the summary."""
84
+ return {
85
+ "type": "object",
86
+ "properties": {
87
+ "headline": {"type": "string", "description": "A headline of at most twelve words."},
88
+ "summary": {"type": "string", "description": "A two-sentence summary."},
89
+ "keyPoints": {"type": "array", "items": {"type": "string"}, "maxItems": 5},
90
+ },
91
+ "required": ["headline", "summary", "keyPoints"],
92
+ "additionalProperties": False,
93
+ }
94
+
95
+
96
+ def parse_summary(text: str) -> Summary | None:
97
+ """Parse Gemini's JSON text, or return None when it does not match the summary schema."""
98
+ try:
99
+ document = json.loads(text)
100
+ except ValueError:
101
+ return None
102
+ if not isinstance(document, dict):
103
+ return None
104
+ headline = document.get("headline") or ""
105
+ summary = document.get("summary") or ""
106
+ key_points = document.get("keyPoints") or []
107
+ if (
108
+ not isinstance(headline, str)
109
+ or not isinstance(summary, str)
110
+ or not isinstance(key_points, list)
111
+ or not all(isinstance(point, str) for point in key_points)
112
+ or not headline.strip()
113
+ or not summary.strip()
114
+ ):
115
+ return None
116
+ return Summary(headline, summary, tuple(key_points))
117
+
118
+
119
+ # dex:group group-id:summary group-label:"Summary"
120
+ # dex:explanation text:"Validate the submitted text and persist the request before calling Gemini."
121
+ class _RecordSummaryRequest(dex.Step[SummaryRequest]):
122
+ def get_step_type(self) -> str:
123
+ return "RecordSummaryRequest"
124
+
125
+ def execute(self, context: dex.Context, input: SummaryRequest) -> dex.StepDecision:
126
+ request = replace(input, title=input.title.strip())
127
+ if (
128
+ not request.text.strip()
129
+ or len(request.text.encode()) > _MAX_TEXT_BYTES
130
+ or len(request.title) > _MAX_TITLE_CHARACTERS
131
+ ):
132
+ return dex.force_fail(
133
+ "summary request requires text of at most 64 KiB and a title of at most 200 characters"
134
+ )
135
+ _REQUEST.set(context, request)
136
+ return dex.go_to(dex.StepRef(GENERATE_SUMMARY_STEP_TYPE), request)
137
+
138
+
139
+ # dex:group group-id:summary group-label:"Summary"
140
+ # dex:explanation text:"Decode the structured Gemini summary and complete the Flow."
141
+ class _SummaryGenerated(dex.Step[QueryResult[GenerateContentResponse]]):
142
+ def get_step_type(self) -> str:
143
+ return "SummaryGenerated"
144
+
145
+ def execute(self, context: dex.Context, input: QueryResult[GenerateContentResponse]) -> dex.StepDecision:
146
+ request = _REQUEST.get(context)
147
+ summary = parse_summary(input.value.text)
148
+ if summary is None:
149
+ return dex.force_fail("Gemini returned text that does not match the summary schema")
150
+ outcome = SummaryOutcome(
151
+ status=STATUS_GENERATED,
152
+ title=request.title,
153
+ summary=summary,
154
+ finish_reason=input.value.finish_reason,
155
+ model_version=input.value.model_version,
156
+ usage=input.value.usage,
157
+ )
158
+ _OUTCOME.set(context, outcome)
159
+ return dex.graceful_complete(outcome)
160
+
161
+
162
+ class GenerateSummaryFlow(dex.Flow[SummaryRequest]):
163
+ """Ask Gemini for a structured JSON summary through the static gemini-api connection."""
164
+
165
+ def __init__(self, connection: Connection, summary_model: SummaryModelConfiguration) -> None:
166
+ if connection.reference.name != CONNECTION_NAME:
167
+ raise ValueError("generate summary requires the static gemini-api connection")
168
+ self._summary_model = summary_model.model.strip()
169
+ self._record_request = _RecordSummaryRequest()
170
+ self._summary_generated = _SummaryGenerated()
171
+ self._generate = new_generate_content_step(
172
+ step_type=GENERATE_SUMMARY_STEP_TYPE,
173
+ step_input_type=SummaryRequest,
174
+ annotations={
175
+ "groupId": "gemini",
176
+ "groupLabel": "Gemini",
177
+ "explanation": "Ask Gemini for a structured JSON summary of the submitted text.",
178
+ },
179
+ configuration_ui=ConnectorConfigurationUI(
180
+ (
181
+ ConnectorUIUnit(
182
+ "summaryModel",
183
+ UI_UNIT_MODEL_PICKER,
184
+ "Summary model",
185
+ "Choose the Gemini model that writes the summary, or keep the connection's model.",
186
+ False,
187
+ (ConnectorUIBinding(UI_MODEL_PICKER_PORT_MODEL, "/model"),),
188
+ ),
189
+ )
190
+ ),
191
+ connection=connection,
192
+ connection_name=CONNECTION_NAME,
193
+ map_to_operation_input=self.map_to_generate_content_request,
194
+ generated=self._summary_generated,
195
+ )
196
+
197
+ def map_to_generate_content_request(self, request: SummaryRequest) -> GenerateContentRequest:
198
+ """Ask for a faithful structured summary with the configured model."""
199
+ return GenerateContentRequest(
200
+ model=self._summary_model,
201
+ system_instruction=(
202
+ "You write concise newsletter summaries. Use only facts stated in the provided text. "
203
+ "Return a headline, a two-sentence summary, and up to five key points."
204
+ ),
205
+ contents=(Content("user", (Part(f"Title: {request.title}\n\n{request.text}"),)),),
206
+ response_json_schema=summary_schema(),
207
+ max_output_tokens=_MAX_SUMMARY_OUTPUT_TOKENS,
208
+ )
209
+
210
+ def get_flow_type(self) -> str:
211
+ """Return the stable Flow identity used in Dex Web."""
212
+ return FLOW_TYPE
213
+
214
+ def get_steps(self) -> dex.StepList[SummaryRequest]:
215
+ """Register request recording, the Gemini generation, and outcome recording."""
216
+ return dex.StepList.start_step(self._record_request).other_steps(
217
+ self._generate, self._summary_generated
218
+ )
219
+
220
+ def get_persistence_schema(self) -> dex.PersistenceSchema:
221
+ """Persist the request and outcome."""
222
+ return dex.PersistenceSchema.of(_REQUEST, _OUTCOME)
@@ -0,0 +1,76 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Worker entrypoint for the Gemini generate summary Flow."""
4
+
5
+ import asyncio
6
+ import os
7
+ import tempfile
8
+ from pathlib import Path
9
+
10
+ import dex
11
+ from dex_connectors.sdk.projectconfig import LoadedProject, load_from_environment
12
+
13
+ from dex_connectors.google_gemini import CONNECTOR_ID, new_project_connection
14
+
15
+ from .flow import (
16
+ CONNECTION_NAME,
17
+ FLOW_TYPE,
18
+ GENERATE_SUMMARY_STEP_TYPE,
19
+ SUMMARY_OPERATION_ID,
20
+ GenerateSummaryFlow,
21
+ SummaryModelConfiguration,
22
+ )
23
+
24
+
25
+ def load_summary_model_configuration(project: LoadedProject) -> SummaryModelConfiguration:
26
+ """Read the summary Step's model pick; no saved pick uses the connection's model."""
27
+ for entry in project.configuration.operation_configurations:
28
+ if (
29
+ entry.get("connectorId") == CONNECTOR_ID
30
+ and entry.get("connectionName") == CONNECTION_NAME
31
+ and entry.get("operationId") == SUMMARY_OPERATION_ID
32
+ and entry.get("flowType") == FLOW_TYPE
33
+ and entry.get("stepType") == GENERATE_SUMMARY_STEP_TYPE
34
+ ):
35
+ configuration = entry["configuration"]
36
+ if set(configuration) - {"model"} or not isinstance(configuration.get("model", ""), str):
37
+ raise ValueError("summary model configuration accepts only a model string")
38
+ return SummaryModelConfiguration(configuration.get("model", ""))
39
+ return SummaryModelConfiguration()
40
+
41
+
42
+ async def run_worker() -> None:
43
+ """Load the named Dex Web connection and serve structured summaries."""
44
+ project = await load_from_environment()
45
+ connection = None
46
+ cache = None
47
+ try:
48
+ connection = new_project_connection(project, CONNECTION_NAME)
49
+ flow = GenerateSummaryFlow(connection, load_summary_model_configuration(project))
50
+ registry = dex.Registry([flow], allow_async_handlers=True)
51
+ cache_directory = os.environ.get(
52
+ "DEX_BLOB_CACHE_DIR", str(Path(tempfile.gettempdir()) / "dex-gemini-generate-summary-blobs")
53
+ )
54
+ cache = dex.open_blob_cache(dex.BlobCacheConfig(cache_directory, 1 << 30))
55
+ worker = dex.AsyncWorker(
56
+ registry,
57
+ cache,
58
+ dex.WorkerOptions(server_address=os.environ.get("DEX_FLOW_SERVICE_ADDRESS", "localhost:8801")),
59
+ )
60
+ async with worker:
61
+ await worker.start()
62
+ finally:
63
+ if connection is not None:
64
+ await connection.aclose()
65
+ if cache is not None:
66
+ cache.close()
67
+ await project.close()
68
+
69
+
70
+ def main() -> None:
71
+ """Run until the Worker stops or the process receives an interrupt."""
72
+ asyncio.run(run_worker())
73
+
74
+
75
+ if __name__ == "__main__":
76
+ main()
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "dex-connector-google-gemini"
7
+ version = "0.1.0"
8
+ description = "Gemini connector for Dex Flows"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ dependencies = ["dex-connectors-sdk==0.1.0", "dex-python-sdk>=1.28.0", "httpx>=0.27"]
13
+
14
+ [dependency-groups]
15
+ dev = ["pytest>=8", "pytest-asyncio>=0.24", "mypy>=1.13", "ruff>=0.7", "pyyaml>=6", "types-PyYAML>=6"]
16
+
17
+ [tool.hatch.build.targets.wheel]
18
+ packages = ["src/dex_connectors"]
19
+
20
+ [tool.pytest.ini_options]
21
+ testpaths = ["tests"]
22
+ pythonpath = [".", "src"]
23
+ asyncio_mode = "auto"
24
+ asyncio_default_fixture_loop_scope = "function"
25
+
26
+ [tool.mypy]
27
+ python_version = "3.11"
28
+ strict = true
29
+ mypy_path = "src"
30
+ explicit_package_bases = true
31
+
32
+ [tool.ruff]
33
+ target-version = "py311"
34
+ line-length = 110
35
+
36
+ [tool.ruff.lint]
37
+ select = ["E", "F", "I", "UP", "B"]
@@ -0,0 +1,58 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Gemini models.generateContent for Dex connector Steps."""
4
+
5
+ from .client import (
6
+ BLOCKED,
7
+ CONNECTOR_ID,
8
+ DEFAULT_ENDPOINT,
9
+ DEFAULT_MAX_RESPONSE_BYTES,
10
+ DEFAULT_MODEL,
11
+ DEFECT,
12
+ GENERATE_CONTENT_DEFINITION,
13
+ GENERATED,
14
+ INVALID_RESPONSE,
15
+ PROVIDER,
16
+ PROVIDER_REJECTED,
17
+ TRUNCATED,
18
+ UI_MODEL_PICKER_PORT_MODEL,
19
+ UI_UNIT_MODEL_PICKER,
20
+ Client,
21
+ Config,
22
+ Credentials,
23
+ GenerateContentOperation,
24
+ )
25
+ from .connection import Connection, new_connection, new_connection_with_operations, new_project_connection
26
+ from .models import Content, GenerateContentRequest, GenerateContentResponse, Part, Usage
27
+ from .steps import new_generate_content_step
28
+
29
+ __all__ = [
30
+ "Client",
31
+ "Config",
32
+ "Connection",
33
+ "Content",
34
+ "Credentials",
35
+ "GenerateContentOperation",
36
+ "GenerateContentRequest",
37
+ "GenerateContentResponse",
38
+ "Part",
39
+ "Usage",
40
+ "new_connection",
41
+ "new_connection_with_operations",
42
+ "new_generate_content_step",
43
+ "new_project_connection",
44
+ "BLOCKED",
45
+ "CONNECTOR_ID",
46
+ "DEFAULT_ENDPOINT",
47
+ "DEFAULT_MAX_RESPONSE_BYTES",
48
+ "DEFAULT_MODEL",
49
+ "DEFECT",
50
+ "GENERATE_CONTENT_DEFINITION",
51
+ "GENERATED",
52
+ "INVALID_RESPONSE",
53
+ "PROVIDER",
54
+ "PROVIDER_REJECTED",
55
+ "TRUNCATED",
56
+ "UI_MODEL_PICKER_PORT_MODEL",
57
+ "UI_UNIT_MODEL_PICKER",
58
+ ]
@@ -0,0 +1,2 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,25 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from dataclasses import dataclass
6
+
7
+ from dex_connectors.sdk import SecretString
8
+
9
+
10
+ @dataclass(frozen=True, slots=True)
11
+ class Config:
12
+
13
+ model: str = "gemini-3.5-flash-lite"
14
+ endpoint: str = "https://generativelanguage.googleapis.com/v1beta"
15
+ max_response_bytes: int = 8388608
16
+
17
+ setattr(Config, '__module__', 'dex_connectors.google_gemini.client')
18
+
19
+
20
+ @dataclass(frozen=True, slots=True)
21
+ class Credentials:
22
+
23
+ api_key: SecretString
24
+
25
+ setattr(Credentials, '__module__', 'dex_connectors.google_gemini.client')