Skip to content

feat: configurable image generation model and timeout#66

Merged
giswqs merged 2 commits into
mainfrom
feat/configurable-image-generation
May 1, 2026
Merged

feat: configurable image generation model and timeout#66
giswqs merged 2 commits into
mainfrom
feat/configurable-image-generation

Conversation

@giswqs

@giswqs giswqs commented May 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Honor GEOAGENT_IMAGE_MODEL and GEOAGENT_IMAGE_TIMEOUT so the generate_image tool can be steered without code changes, and surface the timeout in error messages and the success payload.
  • Add a YouTube walkthrough link to the README, docs landing page, and QGIS plugin guide.

Test plan

  • pre-commit run --all-files
  • pytest tests/test_image_tools.py -q

giswqs added 2 commits May 1, 2026 11:36
Allow GEOAGENT_IMAGE_MODEL and GEOAGENT_IMAGE_TIMEOUT to override the
defaults so QGIS settings and slower networks can steer the
generate_image tool without code changes.
Embed the YouTube walkthrough in the README, the docs landing page, and
the QGIS plugin guide so new users have a guided introduction.
Copilot AI review requested due to automatic review settings May 1, 2026 15:36
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request May 1, 2026 15:37 Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the generate_image tool configurable at runtime via environment variables (model + request timeout) and adds a YouTube walkthrough link to user-facing docs.

Changes:

  • Add GEOAGENT_IMAGE_MODEL and GEOAGENT_IMAGE_TIMEOUT support in generate_image, including surfacing the timeout in tool outputs.
  • Extend image tool tests to validate timeout propagation and env-driven defaults.
  • Add a YouTube walkthrough thumbnail/link to the README and docs pages.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
geoagent/tools/images.py Adds env-configured model selection and OpenAI client timeout handling; includes timeout in results/errors.
tests/test_image_tools.py Updates existing tests for timeout passing and adds a new test for env-configured model/timeout.
README.md Adds YouTube walkthrough thumbnail/link near the top.
docs/index.md Adds YouTube walkthrough thumbnail/link on the docs landing page.
docs/qgis-plugin.md Adds a “Video Tutorial” section with the YouTube thumbnail/link.
Comments suppressed due to low confidence (2)

tests/test_image_tools.py:90

  • This test assumes the default model selection path; if GEOAGENT_IMAGE_MODEL is set in the environment, requested_model/model assertions can change. Consider clearing GEOAGENT_IMAGE_MODEL (and GEOAGENT_IMAGE_TIMEOUT if needed) via monkeypatch.delenv to make the test hermetic.
        def __init__(self, **kwargs) -> None:
            self.images = _Images()

    monkeypatch.setenv("OPENAI_API_KEY", "test-key")
    monkeypatch.setitem(sys.modules, "openai", types.SimpleNamespace(OpenAI=_Client))

tests/test_image_tools.py:33

  • These assertions depend on GEOAGENT_IMAGE_MODEL / GEOAGENT_IMAGE_TIMEOUT not being set in the outer test environment. Since generate_image now reads those env vars, explicitly clear them (monkeypatch.delenv(..., raising=False)) in this test to avoid CI/local flakiness.
            calls["timeout"] = kwargs.get("timeout")
            self.images = _Images()

    monkeypatch.setenv("OPENAI_API_KEY", "test-key")
    monkeypatch.setitem(sys.modules, "openai", types.SimpleNamespace(OpenAI=_Client))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread geoagent/tools/images.py
Comment on lines +80 to +84
try:
timeout = float(raw)
except ValueError:
return DEFAULT_IMAGE_TIMEOUT
return timeout if timeout > 0 else DEFAULT_IMAGE_TIMEOUT

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_image_timeout() accepts any float; values like 'inf' parse successfully and would effectively disable timeouts (or may cause downstream client errors). Consider rejecting non-finite values (e.g., using math.isfinite) and falling back to DEFAULT_IMAGE_TIMEOUT.

Copilot uses AI. Check for mistakes.
Comment thread geoagent/tools/images.py
Comment on lines +190 to 196
"error": (
f"Image generation failed with {model} "
f"within {timeout:g}s: {exc}"
),
"model": model,
"timeout": timeout,
}

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failure response includes a "timeout" field here, but other error paths in generate_image return "model" without "timeout" (e.g., when the API returns no images). Consider making the error payload schema consistent by including "timeout" on all model-related failures.

Copilot uses AI. Check for mistakes.
Comment thread README.md
adapters, provider configuration, and confirmation hooks for operations that
should not run silently.

[![](https://img.youtube.com/vi/5zkXQlHUsu8/maxresdefault.jpg)](https://youtu.be/5zkXQlHUsu8)

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linked thumbnail uses an empty alt text ("![]"); add descriptive alt text for screen readers (e.g., "Video walkthrough") to improve accessibility.

Suggested change
[![](https://img.youtube.com/vi/5zkXQlHUsu8/maxresdefault.jpg)](https://youtu.be/5zkXQlHUsu8)
[![GeoAgent video walkthrough](https://img.youtube.com/vi/5zkXQlHUsu8/maxresdefault.jpg)](https://youtu.be/5zkXQlHUsu8)

Copilot uses AI. Check for mistakes.
Comment thread docs/index.md
while packages contribute focused tool adapters for their own objects and
workflows.

[![](https://img.youtube.com/vi/5zkXQlHUsu8/maxresdefault.jpg)](https://youtu.be/5zkXQlHUsu8)

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linked thumbnail uses an empty alt text ("![]"); add descriptive alt text for screen readers (e.g., "Video walkthrough") to improve accessibility.

Suggested change
[![](https://img.youtube.com/vi/5zkXQlHUsu8/maxresdefault.jpg)](https://youtu.be/5zkXQlHUsu8)
[![GeoAgent video walkthrough](https://img.youtube.com/vi/5zkXQlHUsu8/maxresdefault.jpg)](https://youtu.be/5zkXQlHUsu8)

Copilot uses AI. Check for mistakes.
Comment thread docs/qgis-plugin.md

## Video Tutorial

[![](https://img.youtube.com/vi/5zkXQlHUsu8/maxresdefault.jpg)](https://youtu.be/5zkXQlHUsu8)

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linked thumbnail uses an empty alt text ("![]"); add descriptive alt text for screen readers (e.g., "Video tutorial") to improve accessibility.

Suggested change
[![](https://img.youtube.com/vi/5zkXQlHUsu8/maxresdefault.jpg)](https://youtu.be/5zkXQlHUsu8)
[![OpenGeoAgent QGIS plugin video tutorial](https://img.youtube.com/vi/5zkXQlHUsu8/maxresdefault.jpg)](https://youtu.be/5zkXQlHUsu8)

Copilot uses AI. Check for mistakes.
@giswqs giswqs merged commit f0f543a into main May 1, 2026
13 checks passed
@giswqs giswqs deleted the feat/configurable-image-generation branch May 1, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants