-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtool_call.py
More file actions
31 lines (20 loc) · 866 Bytes
/
tool_call.py
File metadata and controls
31 lines (20 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pydantic import RootModel
from pharia_skill import Csi, skill
class Input(RootModel[int]):
root: int
class Output(RootModel[int]):
root: int
@skill
def compute(csi: Csi, input: Input) -> Output:
"""A skill that computes the answer based on the provided number.
The Engine service offers two native tools (`add` and `subtract`) for developers to
test tool calling, without setting up MCP servers.
The native tools need to be enabled for each namespace, but the Engine service
offers the `test-beta` namespace with the tools enabled.
This skill demonstrates how to invoke the tools.
"""
add_output = csi.invoke_tool("add", a=input.root, b=100)
sum = int(add_output.text())
subtract_output = csi.invoke_tool("subtract", a=sum, b=60)
answer = int(subtract_output.text())
return Output(root=answer)