Skip to content

Commit

Permalink
fix(agents-api): Minor fix to tests
Browse files Browse the repository at this point in the history
Signed-off-by: Diwank Tomer <[email protected]>
  • Loading branch information
Diwank Tomer committed Aug 14, 2024
1 parent 3a38e70 commit aba5421
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
3 changes: 1 addition & 2 deletions agents-api/agents_api/models/entry/create_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ def create_entries(
verify_developer_owns_resource_query(
developer_id, "sessions", session_id=session_id
),
mark_session_as_updated
and mark_session_updated_query(developer_id, session_id),
mark_session_updated_query(developer_id, session_id) if mark_session_as_updated else "",
create_query,
]

Expand Down
24 changes: 6 additions & 18 deletions agents-api/agents_api/routers/tasks/create_task.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from typing import Annotated
from uuid import uuid4

import pandas as pd
from fastapi import Depends
from pydantic import UUID4
from starlette.status import HTTP_201_CREATED

from agents_api.autogen.openapi_model import (
CreateTaskRequest,
ResourceCreatedResponse,
Task,
)
from agents_api.dependencies.developer_id import get_developer_id
from agents_api.models.task.create_task import create_task as create_task_query
Expand All @@ -18,29 +17,18 @@

@router.post("/agents/{agent_id}/tasks", status_code=HTTP_201_CREATED, tags=["tasks"])
async def create_task(
request: CreateTaskRequest,
data: CreateTaskRequest,
agent_id: UUID4,
x_developer_id: Annotated[UUID4, Depends(get_developer_id)],
) -> ResourceCreatedResponse:
task_id = uuid4()

# TODO: Do thorough validation of the task spec

workflows = [
{"name": "main", "steps": [w.model_dump() for w in request.main]},
] + [{"name": name, "steps": steps} for name, steps in request.model_extra.items()]

resp: pd.DataFrame = create_task_query(
agent_id=agent_id,
task_id=task_id,
task: Task = create_task_query(
developer_id=x_developer_id,
name=request.name,
description=request.description,
input_schema=request.input_schema or {},
tools_available=request.tools or [],
workflows=workflows,
agent_id=agent_id,
data=data,
)

return ResourceCreatedResponse(
id=resp["task_id"][0], created_at=resp["created_at"][0]
id=task.id, created_at=task.created_at, jobs=[]
)

0 comments on commit aba5421

Please sign in to comment.