2222 create_tool_call ,
2323)
2424from mistralai .client .models import (
25+ AgentTool ,
2526 CompletionArgs ,
2627 CompletionArgsTypedDict ,
2728 ConversationInputs ,
2829 ConversationInputsTypedDict ,
30+ ConversationRequestTool ,
31+ ConversationRequestToolTypedDict ,
2932 FunctionCallEntry ,
3033 FunctionResultEntry ,
3134 FunctionTool ,
3235 InputEntries ,
3336 MessageInputEntry ,
3437 ResponseFormat ,
35- Tools ,
36- ToolsTypedDict ,
3738)
3839from mistralai .client .types .basemodel import BaseModel , OptionalNullable , UNSET
3940
@@ -50,7 +51,7 @@ class AgentRequestKwargs(typing.TypedDict):
5051class ModelRequestKwargs (typing .TypedDict ):
5152 model : str
5253 instructions : OptionalNullable [str ]
53- tools : OptionalNullable [list [Tools ] | list [ToolsTypedDict ]]
54+ tools : OptionalNullable [list [ConversationRequestTool ] | list [ConversationRequestToolTypedDict ]]
5455 completion_args : OptionalNullable [CompletionArgs | CompletionArgsTypedDict ]
5556
5657
@@ -186,10 +187,9 @@ async def prepare_agent_request(self, beta_client: "Beta") -> AgentRequestKwargs
186187 )
187188 agent = await beta_client .agents .get_async (agent_id = self .agent_id )
188189 agent_tools = agent .tools or []
189- updated_tools = []
190- for i in range (len (agent_tools )):
191- tool = agent_tools [i ]
192- if tool .type != "function" :
190+ updated_tools : list [AgentTool ] = []
191+ for tool in agent_tools :
192+ if not isinstance (tool , FunctionTool ):
193193 updated_tools .append (tool )
194194 elif tool .function .name in self ._callable_tools :
195195 # function already exists in the agent, don't add it again
@@ -209,7 +209,7 @@ async def prepare_agent_request(self, beta_client: "Beta") -> AgentRequestKwargs
209209
210210 async def prepare_model_request (
211211 self ,
212- tools : OptionalNullable [list [Tools ] | list [ToolsTypedDict ]] = UNSET ,
212+ tools : OptionalNullable [list [ConversationRequestTool ] | list [ConversationRequestToolTypedDict ]] = UNSET ,
213213 completion_args : OptionalNullable [CompletionArgs | CompletionArgsTypedDict ] = UNSET ,
214214 instructions : OptionalNullable [str ] = None ,
215215 ) -> ModelRequestKwargs :
@@ -225,7 +225,7 @@ async def prepare_model_request(
225225 request_tools = []
226226 if isinstance (tools , list ):
227227 for tool in tools :
228- request_tools .append (typing .cast (Tools , tool ))
228+ request_tools .append (typing .cast (ConversationRequestTool , tool ))
229229 for tool in self .get_tools ():
230230 request_tools .append (tool )
231231 return ModelRequestKwargs (
@@ -248,7 +248,7 @@ async def _validate_run(
248248 run_ctx : RunContext ,
249249 inputs : ConversationInputs | ConversationInputsTypedDict ,
250250 instructions : OptionalNullable [str ] = UNSET ,
251- tools : OptionalNullable [list [Tools ] | list [ToolsTypedDict ]] = UNSET ,
251+ tools : OptionalNullable [list [ConversationRequestTool ] | list [ConversationRequestToolTypedDict ]] = UNSET ,
252252 completion_args : OptionalNullable [CompletionArgs | CompletionArgsTypedDict ] = UNSET ,
253253) -> tuple [
254254 AgentRequestKwargs | ModelRequestKwargs , RunResult , list [InputEntries ]
0 commit comments