Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Threshold for Search Retrieval isn't working. #288

Open
anonymousx97 opened this issue Feb 9, 2025 · 0 comments
Open

Dynamic Threshold for Search Retrieval isn't working. #288

anonymousx97 opened this issue Feb 9, 2025 · 0 comments
Assignees
Labels
api: gemini-api priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@anonymousx97
Copy link

Environment details

  • Programming language: Python
  • OS: Linux
  • Language runtime version: 3.12.9
  • Package version: 1.0.0

Steps to reproduce

import asyncio

from google.genai.client import AsyncClient, Client
from google.genai.types import (
    DynamicRetrievalConfig,
    GenerateContentConfig,
    GoogleSearchRetrieval,
    Tool,
)


async def test(model: str, threshold: int | float, use_search: bool):

    client: Client = Client(api_key=your key)
    async_client: AsyncClient = client.aio

    config = GenerateContentConfig(
        tools=[
            Tool(
                google_search=GoogleSearchRetrieval(
                    dynamic_retrieval_config=DynamicRetrievalConfig(
                        dynamic_threshold=threshold
                    )
                )
            )
        ],
    )

    response = await async_client.models.generate_content(
        contents=[
            "is gemini 2.0 flash released?\nJust answer yes or not with the release date if any."
        ],
        model=model,
        config=config if use_search else None,
    )

    print(response.candidates[0].content.parts[0].text)


asyncio.run(test(model="gemini-2.0-flash", threshold=1, use_search=False))

asyncio.run(test(model="gemini-2.0-flash", threshold=1, use_search=True))

asyncio.run(test(model="gemini-2.0-flash", threshold=0, use_search=True))

Output:

Without search tool:
No. 

Search set to disabled:
Yes, Gemini 2.0 Flash was released on December 11, 2024, as an experimental model. It was made available to all users on the web on January 28, 2025, and developers can now build production applications with it as of February 5, 2025.

Search Set to enabled:
Yes, Gemini 2.0 Flash was released on December 11, 2024, as an experimental model. It is now generally available since February 5, 2025.
@anonymousx97 anonymousx97 added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Feb 9, 2025
@sararob sararob self-assigned this Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: gemini-api priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants