-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00a7f02
commit c72546e
Showing
4 changed files
with
319 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import uuid | ||
from typing import List | ||
from ward import test | ||
from tests.fixtures import client, async_client, task, agent | ||
from julep.api.types import Task, Execution | ||
|
||
|
||
@test("create task") | ||
def _(client=client, agent=agent): | ||
task = client.tasks.create( | ||
agent_id=agent.id, | ||
name="task1", | ||
description="task 1", | ||
tools_available=["tool1"], | ||
input_schema={}, | ||
main=[], | ||
) | ||
|
||
assert isinstance(task, Task) | ||
assert task.created_at | ||
assert bool(uuid.UUID(str(task.id), version=4)) | ||
|
||
assert task.agent_id == agent.id | ||
assert task.name == "task1" | ||
assert task.description == "task 1" | ||
assert task.tools_available == ["tool1"] | ||
assert task.input_schema == {} | ||
assert task.main == [] | ||
|
||
|
||
@test("get task") | ||
def _(client=client, agent=agent, task=task): | ||
task = client.tasks.get( | ||
agent_id=agent.id, | ||
task_id=task.id, | ||
) | ||
|
||
assert isinstance(task, Task) | ||
assert task.created_at | ||
assert bool(uuid.UUID(str(task.id), version=4)) | ||
|
||
assert task.agent_id == agent.id | ||
assert task.name == "task1" | ||
assert task.description == "task 1" | ||
assert task.tools_available == ["tool1"] | ||
assert task.input_schema == {} | ||
assert task.main == [] | ||
|
||
|
||
@test("list task") | ||
def _(client=client, agent=agent): | ||
tasks = client.tasks.list( | ||
agent_id=agent.id, | ||
) | ||
|
||
assert isinstance(tasks, List[Task]) | ||
assert len(tasks) > 0 | ||
|
||
task = tasks[0] | ||
|
||
assert task.created_at | ||
assert bool(uuid.UUID(str(task.id), version=4)) | ||
|
||
assert task.agent_id == agent.id | ||
assert task.name == "task1" | ||
assert task.description == "task 1" | ||
assert task.tools_available == ["tool1"] | ||
assert task.input_schema == {} | ||
assert task.main == [] | ||
|
||
|
||
@test("start task execution") | ||
def _(client=client, agent=agent, task=task): | ||
execution = client.tasks.start_task_execution( | ||
agent_id=agent.id, | ||
task_id=task.id, | ||
arguments={}, | ||
status="enqueued", | ||
) | ||
|
||
assert isinstance(execution, Execution) | ||
|
||
|
||
@test("create task") | ||
async def _(client=async_client, agent=agent): | ||
task = await client.tasks.create( | ||
agent_id=agent.id, | ||
name="task1", | ||
description="task 1", | ||
tools_available=["tool1"], | ||
input_schema={}, | ||
main=[], | ||
) | ||
|
||
assert isinstance(task, Task) | ||
assert task.created_at | ||
assert bool(uuid.UUID(str(task.id), version=4)) | ||
|
||
assert task.agent_id == agent.id | ||
assert task.name == "task1" | ||
assert task.description == "task 1" | ||
assert task.tools_available == ["tool1"] | ||
assert task.input_schema == {} | ||
assert task.main == [] | ||
|
||
|
||
@test("get task") | ||
async def _(client=async_client, agent=agent, task=task): | ||
task = await client.tasks.get( | ||
agent_id=agent.id, | ||
task_id=task.id, | ||
) | ||
|
||
assert isinstance(task, Task) | ||
assert task.created_at | ||
assert bool(uuid.UUID(str(task.id), version=4)) | ||
|
||
assert task.agent_id == agent.id | ||
assert task.name == "task1" | ||
assert task.description == "task 1" | ||
assert task.tools_available == ["tool1"] | ||
assert task.input_schema == {} | ||
assert task.main == [] | ||
|
||
|
||
@test("list task") | ||
async def _(client=async_client, agent=agent): | ||
tasks = await client.tasks.list( | ||
agent_id=agent.id, | ||
) | ||
|
||
assert isinstance(tasks, List[Task]) | ||
assert len(tasks) > 0 | ||
|
||
task = tasks[0] | ||
|
||
assert task.created_at | ||
assert bool(uuid.UUID(str(task.id), version=4)) | ||
|
||
assert task.agent_id == agent.id | ||
assert task.name == "task1" | ||
assert task.description == "task 1" | ||
assert task.tools_available == ["tool1"] | ||
assert task.input_schema == {} | ||
assert task.main == [] | ||
|
||
|
||
@test("start task execution") | ||
async def _(client=async_client, agent=agent, task=task): | ||
execution = await client.tasks.start_task_execution( | ||
agent_id=agent.id, | ||
task_id=task.id, | ||
arguments={}, | ||
status="enqueued", | ||
) | ||
|
||
assert isinstance(execution, Execution) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
from ward import test | ||
from uuid import uuid4 | ||
from typing import List | ||
|
||
from julep.api.types import ( | ||
Task, | ||
Execution, | ||
) | ||
|
||
from .fixtures import ( | ||
client, | ||
async_client, | ||
test_task, | ||
test_task_async, | ||
mock_task, | ||
) | ||
|
||
|
||
@test("tasks: tasks.create") | ||
def _(task=test_task): | ||
assert isinstance(task, Task) | ||
assert hasattr(task, "created_at") | ||
|
||
assert task.name == mock_task["name"] | ||
assert task.description == mock_task["description"] | ||
assert task.tools_available == mock_task["tools_available"] | ||
assert task.input_schema == mock_task["input_schema"] | ||
assert task.main == mock_task["main"] | ||
assert task.agent_id == mock_task["agent_id"] | ||
|
||
|
||
@test("tasks: tasks.get") | ||
def _(client=client, task=test_task): | ||
response = client.tasks.get(task.id) | ||
assert isinstance(response, Task) | ||
|
||
assert task.name == response.name | ||
assert task.description == response.description | ||
assert task.tools_available == response.tools_available | ||
assert task.input_schema == response.input_schema | ||
assert task.main == response.main | ||
assert task.agent_id == response.agent_id | ||
|
||
|
||
@test("tasks: tasks.list") | ||
def _(client=client, _=test_task): | ||
response = client.tasks.list() | ||
assert len(response) > 0 | ||
assert isinstance(response[0], Task) | ||
|
||
|
||
@test("tasks: tasks.start_task_execution") | ||
def _(client=client, _=test_task): | ||
response = client.tasks.start_task_execution( | ||
agent_id=uuid4(), | ||
task_id=uuid4(), | ||
arguments={}, | ||
status="enqueued", | ||
) | ||
assert isinstance(response[0], Execution) | ||
|
||
|
||
@test("tasks: tasks.get_task_execution") | ||
def _(client=client, _=test_task): | ||
response = client.tasks.get_task_execution( | ||
task_id=uuid4(), | ||
execution_id=uuid4(), | ||
) | ||
assert isinstance(response[0], List[Execution]) | ||
|
||
|
||
@test("async tasks: tasks.create") | ||
async def _(task=test_task_async): | ||
assert isinstance(task, Task) | ||
assert hasattr(task, "created_at") | ||
|
||
assert task.name == mock_task["name"] | ||
assert task.description == mock_task["description"] | ||
assert task.tools_available == mock_task["tools_available"] | ||
assert task.input_schema == mock_task["input_schema"] | ||
assert task.main == mock_task["main"] | ||
assert task.agent_id == mock_task["agent_id"] | ||
|
||
|
||
@test("async tasks: tasks.get") | ||
async def _(client=async_client, task=test_task_async): | ||
response = await client.tasks.get(task.id) | ||
assert isinstance(response, Task) | ||
|
||
assert task.name == response.name | ||
assert task.description == response.description | ||
assert task.tools_available == response.tools_available | ||
assert task.input_schema == response.input_schema | ||
assert task.main == response.main | ||
assert task.agent_id == response.agent_id | ||
|
||
|
||
@test("async tasks: tasks.list") | ||
async def _(client=async_client, _=test_task_async): | ||
response = await client.tasks.list() | ||
assert len(response) > 0 | ||
assert isinstance(response[0], Task) | ||
|
||
|
||
@test("async tasks: tasks.start_task_execution") | ||
async def _(client=async_client, _=test_task_async): | ||
response = await client.tasks.start_task_execution( | ||
agent_id=uuid4(), | ||
task_id=uuid4(), | ||
arguments={}, | ||
status="enqueued", | ||
) | ||
assert isinstance(response[0], Execution) | ||
|
||
|
||
@test("async tasks: tasks.get_task_execution") | ||
async def _(client=async_client, _=test_task_async): | ||
response = await client.tasks.get_task_execution( | ||
task_id=uuid4(), | ||
execution_id=uuid4(), | ||
) | ||
assert isinstance(response[0], List[Execution]) |