Skip to content

Commit

Permalink
fix(agent-api): bug in the api_call tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedantsahai18 committed Oct 3, 2024
1 parent a6cb382 commit 040d774
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
13 changes: 11 additions & 2 deletions agents-api/agents_api/activities/excecute_api_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ async def execute_api_call(
# )

try:
return await httpx.request(
response = httpx.request(
method=api_call.method,
url=api_call.url,
url=str(api_call.url),
headers=api_call.headers,
content=content,
data=data,
Expand All @@ -51,6 +51,15 @@ async def execute_api_call(
follow_redirects=api_call.follow_redirects,
)

response_dict = {
"status_code": response.status_code,
# "headers": response.headers,
# "content": response.content,
"json": response.json(),
}

return response_dict

except BaseException as e:
if activity.in_activity():
activity.logger.error(f"Error in execute_api_call: {e}")
Expand Down
2 changes: 2 additions & 0 deletions agents-api/agents_api/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def create_worker(client: Client) -> Any:
from ..activities.demo import demo_activity
from ..activities.embed_docs import embed_docs
from ..activities.execute_integration import execute_integration
from ..activities. excecute_api_call import execute_api_call
from ..activities.mem_mgmt import mem_mgmt
from ..activities.mem_rating import mem_rating
from ..activities.summarization import summarization
Expand Down Expand Up @@ -52,6 +53,7 @@ def create_worker(client: Client) -> Any:
demo_activity,
embed_docs,
execute_integration,
execute_api_call,
mem_mgmt,
mem_rating,
summarization,
Expand Down
10 changes: 5 additions & 5 deletions agents-api/agents_api/workflows/task_execution/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,11 @@ async def run(
)

# Extract the optional arguments for `content`, `data`, `json`, `cookies`, and `params`
content = call["content"]
data = call["data"]
json_ = call["json"]
cookies = call["cookies"]
params = call["params"]
content = call.get("content", None)
data = call.get("data", None)
json_ = call.get("json", None)
cookies = call.get("cookies", None)
params = call.get("params", None)

# Execute the API call using the `execute_api_call` function
tool_call_response = await workflow.execute_activity(
Expand Down
2 changes: 1 addition & 1 deletion agents-api/tests/test_execution_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ async def _(
"params": {"test": "_.test"},
},
{
"evaluate": {"hello": "_.json()['args']['test']"},
"evaluate": {"hello": "_.json.args"},
}
],
}
Expand Down

0 comments on commit 040d774

Please sign in to comment.