Skip to content

fix: define model literal and add types prefix in URL Context example#36

Closed
xiaolai wants to merge 1 commit intogoogle-gemini:mainfrom
xiaolai:fix/nlpm-url-context-undefined-model-id
Closed

fix: define model literal and add types prefix in URL Context example#36
xiaolai wants to merge 1 commit intogoogle-gemini:mainfrom
xiaolai:fix/nlpm-url-context-undefined-model-id

Conversation

@xiaolai
Copy link
Copy Markdown
Contributor

@xiaolai xiaolai commented Apr 27, 2026

Automated audit: This PR was generated by NLPM, a natural language programming linter. Please evaluate the diff on its merits.

The Url Context code sample in skills/vertex-ai-api-dev/references/structured_and_tools.md (the block under ## Url Context) has two issues that prevent it from running as written:

  1. model=model_idmodel_id is never defined in the snippet (every other code block in the same file uses a literal model string). Copy-pasting this example raises NameError: name 'model_id' is not defined.
  2. config=GenerateContentConfig(...) — the file imports the SDK as from google.genai import types, so the constructor must be qualified as types.GenerateContentConfig(...). The four sibling examples in the same file (Structured Output, Function Calling, Search Grounding, Code Execution) all use the qualified form.

The fix matches the rest of the file:

response = client.models.generate_content(
    model="gemini-3-flash-preview",
    contents="Compare recipes from http://example.com and http://example2.com",
    config=types.GenerateContentConfig(
        tools=[types.Tool(url_context=types.UrlContext)],
    )
)

The other code blocks in the same file already use gemini-3-flash-preview, so it's the conservative pick for consistency.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 27, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates a Python code example in the documentation for Vertex AI. Specifically, it replaces a generic model variable with a specific model ID ('gemini-3-flash-preview') and corrects the reference to 'GenerateContentConfig' by adding the 'types' prefix. I have no feedback to provide.

@xiaolai
Copy link
Copy Markdown
Contributor Author

xiaolai commented Apr 27, 2026

@googlebot I signed it!

The Url Context code sample in `references/structured_and_tools.md`
referenced an undefined `model_id` variable and used a bare
`GenerateContentConfig(...)` call. Reproducing the snippet raises
`NameError: name 'model_id' is not defined`, and even after defining
that variable a `NameError` on `GenerateContentConfig` follows because
the file only imports it as `types.GenerateContentConfig`.

Aligns this code block with the four other examples in the same file
(Structured Output, Function Calling, Search Grounding, Code Execution),
all of which use `model="gemini-3-flash-preview"` and
`types.GenerateContentConfig(...)`.
@xiaolai xiaolai force-pushed the fix/nlpm-url-context-undefined-model-id branch from b58e438 to 944243b Compare April 27, 2026 03:48
@markmcd
Copy link
Copy Markdown
Member

markmcd commented Apr 28, 2026

No longer needed.

@markmcd markmcd closed this Apr 28, 2026
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