Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/openserv_sdk/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,10 @@ async def get_tasks(self, workspace_id: Union[int, GetTasksParams]) -> Dict[str,
async def mark_task_as_errored(self, workspace_id: int, task_id: int, error: str) -> Dict[str, Any]:
"""Mark a task as errored with the given error message."""
try:
response = await self._api_client.post(f"/workspaces/{workspace_id}/tasks/{task_id}/error", {
"error": error
})

response = await self._api_client.post(
f"/workspaces/{workspace_id}/task/{task_id}/error",
{"error": error}
)
return response

except Exception as e:
Expand All @@ -626,8 +626,8 @@ async def mark_task_as_errored(self, workspace_id: int, task_id: int, error: str

async def complete_task(self, workspace_id: int, task_id: int, output: str) -> Dict[str, Any]:
"""Complete a task."""
response = await self._api_client.put(
f"/workspaces/{workspace_id}/tasks/{task_id}/complete",
response = await self._api_client.post(
f"/workspaces/{workspace_id}/task/{task_id}/complete",
{"output": output}
)
return response["data"]
Expand Down Expand Up @@ -695,7 +695,7 @@ async def update_task_status(self, params: UpdateTaskStatusParams) -> Dict[str,
"""Update a task's status."""
try:
response = await self._api_client.post(
f"/workspaces/{params.workspace_id}/tasks/{params.task_id}/status",
f"/workspaces/{params.workspace_id}/task/{params.task_id}/status",
{"status": params.status.value if isinstance(params.status, TaskStatus) else params.status}
)
return response["data"]
Expand All @@ -719,12 +719,18 @@ def convert_to_openai_tools(self, tools: List[Dict[str, Any]]) -> List[Dict[str,
"""Convert tools to OpenAI format."""
openai_tools = []
for tool in tools:
# Create a copy of the parameters to avoid modifying the original
parameters = tool["parameters"].copy()
# Remove title field if present
if "title" in parameters:
del parameters["title"]

openai_tool = {
"type": "function",
"function": {
"name": tool["name"],
"description": tool["description"],
"parameters": tool["parameters"]
"parameters": parameters
}
}
openai_tools.append(openai_tool)
Expand Down