MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / demo_tool_schemas

Function demo_tool_schemas

examples/06_tool_schema_demo.py:153–200  ·  view source on GitHub ↗

Demonstrate using Tool objects with LLM.

()

Source from the content-addressed store, hash-verified

151
152
153async def demo_tool_schemas():
154 """Demonstrate using Tool objects with LLM."""
155 config = load_config()
156
157 print("=" * 60)
158 print("Method 1: Using Tool Objects with LLM")
159 print("=" * 60)
160
161 # Create tool instances
162 weather_tool = WeatherTool()
163 search_tool = SearchTool()
164
165 # Create client
166 client = LLMClient(
167 api_key=config["api_key"],
168 provider=LLMProvider.ANTHROPIC,
169 model="MiniMax-M2.5",
170 )
171
172 # Test with a query that should trigger weather tool
173 messages = [
174 Message(
175 role="user",
176 content="What's the weather like in Tokyo? I want it in celsius.",
177 )
178 ]
179
180 print("\nQuery: What's the weather like in Tokyo? I want it in celsius.")
181 print("\nAvailable tools:")
182 print(f" 1. {weather_tool.name}: {weather_tool.description}")
183 print(f" 2. {search_tool.name}: {search_tool.description}")
184
185 # Pass Tool objects directly to generate
186 response = await client.generate(
187 messages,
188 tools=[weather_tool, search_tool], # Using Tool objects
189 )
190
191 print(f"\nResponse content: {response.content}")
192
193 if response.thinking:
194 print(f"\nThinking: {response.thinking}")
195
196 if response.tool_calls:
197 print(f"\nTool calls made: {len(response.tool_calls)}")
198 for tool_call in response.tool_calls:
199 print(f" - Function: {tool_call.function.name}")
200 print(f" Arguments: {tool_call.function.arguments}")
201
202
203async def demo_multiple_tools():

Callers 1

mainFunction · 0.85

Calls 6

generateMethod · 0.95
LLMClientClass · 0.90
MessageClass · 0.90
WeatherToolClass · 0.85
SearchToolClass · 0.85
load_configFunction · 0.70

Tested by

no test coverage detected