MCPcopy Create free account
hub / github.com/Sophomoresty/gemini-web2api / build_tool_prompt

Function build_tool_prompt

gemini_web2api/tools.py:149–165  ·  view source on GitHub ↗

Build natural tool-use prompt for Gemini Web that avoids prompt-injection detection.

(tool_defs: list)

Source from the content-addressed store, hash-verified

147
148
149def build_tool_prompt(tool_defs: list) -> str:
150 """Build natural tool-use prompt for Gemini Web that avoids prompt-injection detection."""
151 tool_spec = json.dumps(tool_defs, indent=2, ensure_ascii=False)
152 return (
153 "# Tool Use\n\n"
154 "You can call the following tools to help accomplish tasks. "
155 "These tools connect to the user's local environment and will execute when called.\n\n"
156 "Call format (use this exact format):\n"
157 "```function_call\n"
158 '{"name": "<tool_name>", "args": {<arguments>}}\n'
159 "```\n\n"
160 "When calling tools:\n"
161 "- Output ONLY the function_call block(s), nothing else\n"
162 "- You may call multiple tools with multiple blocks\n"
163 "- After receiving a [Tool result for ...], use that data to answer the user\n\n"
164 f"Available tools:\n{tool_spec}"
165 )
166
167
168def _google_tool_choice_instruction(req: dict) -> str:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected