Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

11.9 KB
Raw Blame
from collections.abc import Mapping
from typing import Final

from pydantic import JsonValue

GEMINI_GENERATE_CONTENT_REQUEST: Final[Mapping[str, JsonValue]] = {
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "The checkout rejects quantities of zero. Find the validation code and its tests.",
                },
            ],
        },
        {
            "role": "model",
            "parts": [
                {
                    "text": "I will locate the quantity validation and its tests.",
                },
                {
                    "function_call": {
                        "name": "search_files",
                        "args": {
                            "query": "quantity",
                            "paths": [
                                "shop/",
                                "tests/",
                            ],
                        },
                        "id": "toolu_synthetic_search_01",
                    },
                    "thoughtSignature": "c2tpcF90aG91Z2h0X3NpZ25hdHVyZV92YWxpZGF0b3I=",
                },
            ],
        },
        {
            "role": "user",
            "parts": [
                {
                    "function_response": {
                        "name": "search_files",
                        "response": {
                            "matches": [
                                {
                                    "path": "shop/validation.py",
                                    "line": 18,
                                    "text": "def validate_quantity(quantity):",
                                },
                                {
                                    "path": "tests/test_validation.py",
                                    "line": 7,
                                    "text": "def test_zero_quantity():",
                                },
                            ],
                        },
                        "id": "toolu_synthetic_search_01",
                    },
                },
            ],
        },
        {
            "role": "user",
            "parts": [
                {
                    "text": (
                        "Read the validation file first so we can understand how zero and negative quantities are handled"
                        "."
                    ),
                },
            ],
        },
    ],
    "system_instruction": {
        "parts": [
            {
                "text": (
                    "You help maintain a synthetic Python project. Read the relevant files before suggesting a fix. E"
                    "xplain which file you need next, then call a read-only tool. Never change files. Use the chat_co"
                    "mpletions client for this project review. Consider zero, negative and non-integer quantities bef"
                    "ore choosing the next file to inspect."
                ),
            },
        ],
    },
    "tools": [
        {
            "function_declarations": [
                {
                    "name": "search_files",
                    "description": "Search source and test files for a literal term.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "query": {
                                "type": "string",
                            },
                            "paths": {
                                "type": "array",
                                "items": {
                                    "type": "string",
                                },
                            },
                        },
                        "required": [
                            "query",
                            "paths",
                        ],
                    },
                },
                {
                    "name": "read_file",
                    "description": "Read a range of lines from a project file.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "path": {
                                "type": "string",
                            },
                            "start_line": {
                                "type": "integer",
                                "minimum": 1,
                            },
                            "end_line": {
                                "type": "integer",
                                "minimum": 1,
                            },
                        },
                        "required": [
                            "path",
                            "start_line",
                            "end_line",
                        ],
                    },
                },
            ],
        },
    ],
    "generationConfig": {
        "max_output_tokens": 1024,
        "thinkingConfig": {
            "thinkingLevel": "high",
            "includeThoughts": True,
        },
    },
}

GEMINI_3_8_FLASH_THOUGHT: Final = (
    "**My Thought Process: Initializing Validation File Inspection**\n\n"
    "Okay, let's break this down. The user's goal is to help maintain a Python project, but important"
    "ly, to *read* relevant files and *never* change them. The instructions explicitly direct me to u"
    "nderstand how zero and negative quantities are handled, and to *consider* these before choosing "
    "the *next* file. The user's explicit request to read the validation file first immediately trigg"
    "ers the appropriate response.\n\n"
    "Based on the instructions and the user's initial prompt, I need to focus on `shop/validation.py`"
    " which I know is at line 18 (`def validate_quantity(quantity):`). I need to check how the code h"
    "andles zero, negative, and potentially non-integer quantities. \n\n"
    "Before proceeding, it's essential to confirm the instructions: read the file, explain the choice"
    ", and use a read-only tool. I need to be precise. To avoid any ambiguity, I'll start by reading "
    "lines 1 to 50 of `shop/validation.py`. This range should allow me to see the context of the `val"
    "idate_quantity` function.\n\nNow, for the critical step: I'm going to follow the instructions and "
    "explain my reasoning, then I'll use the read-only tool.\n\nTherefore, my next step is:\n\n"
    "We want to see how `validate_quantity` verifies quantity inputs, specifically whether it properl"
    "y handles zero, negative values, and non-integer types (e.g. floats, strings, or None), before w"
    "e look at the test suite. Therefore, the next file we need to inspect is `shop/validation.py`.\n\n"
    "\n"
)

GEMINI_3_8_FLASH_THOUGHT_SIGNATURE: Final = (
    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sQcjrxcNu6dvH+O8v9RWvD"
    "A87rM2rikA/oJc0IBRDvFNehMtnu3yR5969Q13ORotFWvYLOwAdSYP5H8TIvpEleHQsYGnPUclZqTI51+dbydYBXnqTDtRer"
    "7zq4Ul/cuF3LYLRcr4zfkNrOgZK+U3Rfk60WPEi5AyWQ2IO74B7FQqIHKw5mXjlV0Krfn4e2bYJXBRS82xgfK6pYtHWgIbY/"
    "18quckh1T4bF9JfRi0JTPYp2sU2FossIjbT98rpd76OBHBnWl2BUcd+0BiZ91DNErQVVaAmsfGA4li2upU0E0QnN87tctY43"
    "DLL9YH133uCTV8YQh8hfbh4j30GcongmSd5L30stAv+AGQRFqK8fi/vJdgTXZXWWYSjTlhetY5ar3FnaulztywTqjLbBUxK1"
    "jicit6aonk217FYXDzSRy3BcGx5TN879JkvQ22zpsxy41Brxw8MhYT92UduPTXcQwNkh09+Rn7+lP8/u1ppEtE/vttmHGuxe"
    "QEyOk8isAtoErC3xdA2fYh16dA2on1HPXlX81/dF4Og1PQdZp3GIS3ftuKMlinGuRyFBaHV5IZYji16r+afCWnz3dh9eKnrs"
    "OrdjxyLk1wcsQRzig6nurhBkoOi1p73QyzVyx2hzMkKoNAkV2YM/33kPrwM8mXQYEpQVL0r6P3wgXFP4ep5dYQ+HGZCan5i4"
    "QWum9+1FOFAIFUbxp5ePAybhzOhLkOn+2EPwKumY7hR56sVsAyJFp5cy7JlaxPfI/n1Ez9xyOlWimU6mTrzM9VW7J9XvEPGe"
    "Nf9DRRMWSTopkGQSwdRVzcoNv2DyGi/7p+pXoI7iEZyvVwe/ascmsE1J/GKnJ8niLmCIJCT0oVyZCnEQIDuCzZ/CBYePfbhx"
    "dNFrZWka7k3/mc2+sFo83qatJE3f0twjTwVzrDg6AQ896S2JlGASIpjTkJVo07H2mSyQJheQnA3Y2OpAnWWBtbmDbB0kH/fF"
    "WISHelg4DopTdf3WyM18ONMgTiFCH+U7w2qe+PV10bD0jED6P/mN7LMvYr4sNRoBKekpnS71wNzH0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LRq1l77VUEe/xPo1jrR5LhShIWGht2R1ZJGykwtP5GwZMkmqTkLN"
    "uvyRFOKiWZf265aXW89HuHX5SREcOcp5YuFmQGn0vQroptxyIEk9fGZPVfIaoxGxcgP9vzgG43JCdRc="
)

GEMINI_GENERATE_CONTENT_RESPONSE: Final[Mapping[str, JsonValue]] = {
    "candidates": [
        {
            "content": {
                "parts": [
                    {
                        "text": GEMINI_3_8_FLASH_THOUGHT,
                        "thought": True,
                    },
                    {
                        "text": (
                            "To check how zero, negative, and non-integer quantities (such as floats, non-numeric values, or "
                            "values less than or equal to zero) are validated, I need to inspect `shop/validation.py` next."
                        ),
                    },
                    {
                        "functionCall": {
                            "name": "read_file",
                            "args": {
                                "path": "shop/validation.py",
                                "end_line": 50,
                                "start_line": 1,
                            },
                            "id": "call_7668",
                        },
                        "thoughtSignature": GEMINI_3_8_FLASH_THOUGHT_SIGNATURE,
                    },
                ],
                "role": "model",
            },
            "finishReason": "STOP",
            "index": 0,
            "finishMessage": "Model generated function call(s).",
        },
    ],
    "usageMetadata": {
        "promptTokenCount": 358,
        "candidatesTokenCount": 80,
        "totalTokenCount": 1013,
        "promptTokensDetails": [
            {
                "modality": "TEXT",
                "tokenCount": 358,
            },
        ],
        "thoughtsTokenCount": 575,
        "serviceTier": "standard",
    },
    "modelVersion": "gemini-3.8-flash",
    "responseId": "1CbQat_JEK-jqtsPtf-QoQU",
}