Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(agents-api): Minor fix to tests #457

Merged
merged 7 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 "",
creatorrr marked this conversation as resolved.
Show resolved Hide resolved
creatorrr marked this conversation as resolved.
Show resolved Hide resolved
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=[]
)
28 changes: 16 additions & 12 deletions agents-api/tests/test_task_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
def _(client=client, agent=test_agent):
data = dict(
name="test user",
main={
"kind_": "evaluate",
"evaluate": {
"additionalProp1": "value1",
},
},
main=[
{
"kind_": "evaluate",
"evaluate": {
"additionalProp1": "value1",
},
}
],
)

response = client.request(
Expand All @@ -31,12 +33,14 @@ def _(client=client, agent=test_agent):
def _(make_request=make_request, agent=test_agent):
data = dict(
name="test user",
main={
"kind_": "evaluate",
"evaluate": {
"additionalProp1": "value1",
},
},
main=[
{
"kind_": "evaluate",
"evaluate": {
"additionalProp1": "value1",
},
}
],
)

response = make_request(
Expand Down
Loading