Skip to content

Commit 370699e

Browse files
ryoppippiglebedel
andauthored
fix: remove async method (#31)
Co-authored-by: Guillaume <[email protected]>
1 parent d94096b commit 370699e

File tree

2 files changed

+0
-50
lines changed

2 files changed

+0
-50
lines changed

stackone_ai/models.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# TODO: Remove when Python 3.9 support is dropped
22
from __future__ import annotations
33

4-
import asyncio
54
import base64
65
import json
76
from collections.abc import Sequence
87
from enum import Enum
9-
from functools import partial
108
from typing import Annotated, Any, cast
119
from urllib.parse import quote
1210

@@ -256,36 +254,6 @@ def call(self, *args: Any, **kwargs: Any) -> JsonDict:
256254

257255
return self.execute(kwargs if kwargs else None)
258256

259-
async def acall(self, *args: Any, **kwargs: Any) -> JsonDict:
260-
"""Async version of call method
261-
262-
Args:
263-
*args: If a single argument is provided, it's treated as the full arguments dict/string
264-
**kwargs: Keyword arguments to pass to the tool
265-
266-
Returns:
267-
API response as dict
268-
269-
Raises:
270-
StackOneAPIError: If the API request fails
271-
ValueError: If the arguments are invalid
272-
"""
273-
# For now, we'll use asyncio to run the sync version
274-
# In the future, this should use aiohttp for true async
275-
276-
# Create a partial function with the arguments
277-
if args and kwargs:
278-
raise ValueError("Cannot provide both positional and keyword arguments")
279-
280-
if args:
281-
if len(args) > 1:
282-
raise ValueError("Only one positional argument is allowed")
283-
func = partial(self.execute, args[0])
284-
else:
285-
func = partial(self.execute, kwargs if kwargs else None)
286-
287-
return await asyncio.get_event_loop().run_in_executor(None, func)
288-
289257
def to_openai_function(self) -> JsonDict:
290258
"""Convert this tool to OpenAI's function format
291259

tests/test_tool_calling.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,6 @@ def test_call_with_multiple_args_raises_error(self, mock_tool):
116116
with pytest.raises(ValueError, match="Only one positional argument is allowed"):
117117
mock_tool.call({"name": "test"}, {"value": 42})
118118

119-
@pytest.mark.asyncio
120-
@responses.activate
121-
async def test_acall_with_kwargs(self, mock_tool):
122-
"""Test async calling a tool with keyword arguments"""
123-
# Mock the API response
124-
responses.add(
125-
responses.POST,
126-
"https://api.example.com/test",
127-
json={"success": True, "result": "async_result"},
128-
status=200,
129-
)
130-
131-
# Call the tool asynchronously
132-
result = await mock_tool.acall(name="test", value=42)
133-
134-
# Verify the result
135-
assert result == {"success": True, "result": "async_result"}
136-
137119
@responses.activate
138120
def test_call_without_arguments(self, mock_tool):
139121
"""Test calling a tool without any arguments"""

0 commit comments

Comments
 (0)