sapiopycommons 2025.6.30a571__py3-none-any.whl → 2025.6.30a572__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sapiopycommons might be problematic. Click here for more details.

@@ -7,14 +7,15 @@ from sapiopycommons.ai.api.fielddefinitions.proto.fields_pb2 import FieldValuePb
7
7
  from sapiopycommons.ai.api.plan.tool.proto.entry_pb2 import DataTypePbo, StepBinaryContainerPbo, StepCsvRowPbo, \
8
8
  StepCsvHeaderRowPbo, StepCsvContainerPbo, StepJsonContainerPbo, StepImageContainerPbo, StepTextContainerPbo, \
9
9
  StepItemContainerPbo, StepInputBatchPbo
10
- from sapiopycommons.ai.api.plan.tool.proto.tool_pb2 import ProcessStepResponsePbo, ProcessStepRequestPbo
10
+ from sapiopycommons.ai.api.plan.tool.proto.tool_pb2 import ProcessStepResponsePbo, ProcessStepRequestPbo, \
11
+ ToolDetailsRequestPbo, ToolDetailsResponsePbo
11
12
  from sapiopycommons.ai.api.plan.tool.proto.tool_pb2_grpc import ToolServiceStub
12
13
  from sapiopycommons.ai.api.session.proto.sapio_conn_info_pb2 import SapioConnectionInfoPbo, SapioUserSecretTypePbo
13
14
 
14
15
 
15
- class TestOutput:
16
+ class ToolOutput:
16
17
  """
17
- A class for holding the output of a TestClient that calls a ToolService. TestOutput objects an be
18
+ A class for holding the output of a TestClient that calls a ToolService. ToolOutput objects an be
18
19
  printed to show the output of the tool in a human-readable format.
19
20
  """
20
21
  binary_output: list[bytes]
@@ -72,19 +73,16 @@ class TestClient:
72
73
  responses.
73
74
  """
74
75
  server_url: str
75
- tool_name: str
76
76
  connection: SapioConnectionInfoPbo
77
- request_inputs: list[Any]
77
+ _request_inputs: list[Any]
78
78
 
79
- def __init__(self, server_url: str, tool_name: str):
79
+ def __init__(self, server_url: str):
80
80
  """
81
81
  :param server_url: The URL of the gRPC server to connect to.
82
- :param tool_name: The name of the tool to call on the server.
83
82
  """
84
83
  self.create_user()
85
84
  self.server_url = server_url
86
- self.tool_name = tool_name
87
- self.request_inputs = []
85
+ self._request_inputs = []
88
86
 
89
87
  def create_user(self):
90
88
  """
@@ -134,6 +132,13 @@ class TestClient:
134
132
  """
135
133
  self._add_input(DataTypePbo.TEXT, StepTextContainerPbo(items=input_data))
136
134
 
135
+ def clear_inputs(self) -> None:
136
+ """
137
+ Clear all inputs that have been added to the next request.
138
+ This is useful if you want to start a new request without the previous inputs.
139
+ """
140
+ self._request_inputs.clear()
141
+
137
142
  def _add_input(self, data_type: DataTypePbo, items: Any) -> None:
138
143
  """
139
144
  Helper method for adding inputs to the next request.
@@ -151,14 +156,25 @@ class TestClient:
151
156
  container = StepItemContainerPbo(dataType=data_type, text_container=items)
152
157
  case _:
153
158
  raise ValueError(f"Unsupported data type: {data_type}")
154
- self.request_inputs.append(container)
159
+ self._request_inputs.append(container)
160
+
161
+ def get_service_details(self) -> ToolDetailsResponsePbo:
162
+ """
163
+ Get the details of the tools from the server.
155
164
 
156
- def send_request(self) -> TestOutput:
165
+ :return: A ToolDetailsResponsePbo object containing the details of the tool service.
157
166
  """
158
- Send the request to the tool service. This will send all the inputs that have been added using the
159
- add_X_input functions.
167
+ with grpc.insecure_channel(self.server_url) as channel:
168
+ stub = ToolServiceStub(channel)
169
+ return stub.GetToolDetails(ToolDetailsRequestPbo(sapio_conn_info=self.connection))
170
+
171
+ def call_tool(self, tool_name: str) -> ToolOutput:
172
+ """
173
+ Send the request to the tool service for a particular tool name. This will send all the inputs that have been
174
+ added using the add_X_input functions.
160
175
 
161
- :return: A TestOutput object containing the results of the tool service call.
176
+ :param tool_name: The name of the tool to call on the server.
177
+ :return: A ToolOutput object containing the results of the tool service call.
162
178
  """
163
179
  with grpc.insecure_channel(self.server_url) as channel:
164
180
  stub = ToolServiceStub(channel)
@@ -166,16 +182,15 @@ class TestClient:
166
182
  response: ProcessStepResponsePbo = stub.ProcessData(
167
183
  ProcessStepRequestPbo(
168
184
  sapio_user=self.connection,
169
- tool_name=self.tool_name,
185
+ tool_name=tool_name,
170
186
  input=[
171
187
  StepInputBatchPbo(is_partial=False, item_container=item)
172
- for item in self.request_inputs
188
+ for item in self._request_inputs
173
189
  ]
174
190
  )
175
191
  )
176
192
 
177
- results = TestOutput()
178
-
193
+ results = ToolOutput()
179
194
  for item in response.output:
180
195
  container = item.item_container
181
196
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sapiopycommons
3
- Version: 2025.6.30a571
3
+ Version: 2025.6.30a572
4
4
  Summary: Official Sapio Python API Utilities Package
5
5
  Project-URL: Homepage, https://github.com/sapiosciences
6
6
  Author-email: Jonathan Steck <jsteck@sapiosciences.com>, Yechen Qiao <yqiao@sapiosciences.com>
@@ -1,7 +1,7 @@
1
1
  sapiopycommons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  sapiopycommons/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  sapiopycommons/ai/protobuf_utils.py,sha256=zILNSFEqkWFmpq23Gi1ik-NncGsDidWcWn1ly6YE0xU,22610
4
- sapiopycommons/ai/test_client.py,sha256=GiwZ7grDQqKj13GIdxVIumvSNededEOK5vzErJMMlEY,8195
4
+ sapiopycommons/ai/test_client.py,sha256=cEeDc7PmDduMixsvMzMoEyywfcEaI4kr8zZDj-BO8Gs,8905
5
5
  sapiopycommons/ai/tool_service_base.py,sha256=WatdDcKNmm5j9ExLuYhC14F9UQb89QXtJHTUJ5rhMtw,35394
6
6
  sapiopycommons/ai/api/fielddefinitions/proto/fields_pb2.py,sha256=YcZjb_YM-XeLErM8hEC_S7vGMVGvcXAMGs2b-u5zvOE,2377
7
7
  sapiopycommons/ai/api/fielddefinitions/proto/fields_pb2.pyi,sha256=FwtXmNAf7iYGEFm4kbqb04v77jNHbZg18ZmEDhle_bU,1444
@@ -86,7 +86,7 @@ sapiopycommons/webhook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
86
86
  sapiopycommons/webhook/webhook_context.py,sha256=D793uLsb1691SalaPnBUk3rOSxn_hYLhdvkaIxjNXss,1909
87
87
  sapiopycommons/webhook/webhook_handlers.py,sha256=L0HetSm43NvA5KyW3xbLpGFh2DbAaeZJVtXIEl2fvV8,39689
88
88
  sapiopycommons/webhook/webservice_handlers.py,sha256=Y5dHx_UFWFuSqaoPL6Re-fsKYRuxvCWZ8bj6KSZ3jfM,14285
89
- sapiopycommons-2025.6.30a571.dist-info/METADATA,sha256=_lyxmfdxZj2_F8HNT07erv2PrS4gERLEF4uPDSirzyQ,3143
90
- sapiopycommons-2025.6.30a571.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
91
- sapiopycommons-2025.6.30a571.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
92
- sapiopycommons-2025.6.30a571.dist-info/RECORD,,
89
+ sapiopycommons-2025.6.30a572.dist-info/METADATA,sha256=xQtNtqH1aIOtf2nSPPG96SY0CwNJDGD4JUNnjxhJ34A,3143
90
+ sapiopycommons-2025.6.30a572.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
91
+ sapiopycommons-2025.6.30a572.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
92
+ sapiopycommons-2025.6.30a572.dist-info/RECORD,,