Skip to content

Commit ab9747f

Browse files
fix: update extra module and docs for new speakeasy types
- Update type references: Tools -> ConversationRequestTool - Remove type= parameter from FunctionTool constructor (now a constant) - Use isinstance() check instead of .type attribute access - Document type name changes in MIGRATION.md
1 parent fab4064 commit ab9747f

4 files changed

Lines changed: 23 additions & 13 deletions

File tree

MIGRATION.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,22 @@ from mistralai.client.types import BaseModel
3535

3636
### What Stays the Same
3737

38-
- All method names and signatures remain identical
3938
- The `Mistral` client API is unchanged
4039
- All models (`UserMessage`, `AssistantMessage`, etc.) work the same way
4140

41+
### Type Name Changes
42+
43+
Some type names have been updated for clarity and consistency:
44+
45+
| Old Name | New Name |
46+
|---|---|
47+
| `Tools` | `ConversationRequestTool` |
48+
| `ToolsTypedDict` | `ConversationRequestToolTypedDict` |
49+
| `HandoffExecution` | `ConversationRequestHandoffExecution` |
50+
| `AgentVersion` | `ConversationRequestAgentVersion` |
51+
52+
Enums now accept unknown values for forward compatibility with API changes.
53+
4254
---
4355

4456
## Migrating from v0.x to v1.x

src/mistralai/extra/mcp/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ async def get_tools(self) -> list[FunctionTool]:
8484
for mcp_tool in mcp_tools.tools:
8585
tools.append(
8686
FunctionTool(
87-
type="function",
8887
function=Function(
8988
name=mcp_tool.name,
9089
description=mcp_tool.description,

src/mistralai/extra/run/context.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@
2222
create_tool_call,
2323
)
2424
from 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
)
3839
from mistralai.client.types.basemodel import BaseModel, OptionalNullable, UNSET
3940

@@ -50,7 +51,7 @@ class AgentRequestKwargs(typing.TypedDict):
5051
class 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]

src/mistralai/extra/run/tools.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ def create_tool_call(func: Callable) -> FunctionTool:
168168
type_hints = get_type_hints(func, include_extras=True, localns=None, globalns=None)
169169

170170
return FunctionTool(
171-
type="function",
172171
function=Function(
173172
name=name,
174173
description=_get_function_description(docstring_sections),

0 commit comments

Comments
 (0)