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

Dev tasks #447

Merged
merged 133 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
10d3600
feat(agents-api): Implement doc* models (#442)
creatorrr Aug 4, 2024
919b9e9
feat(agents-api): Reimplement agents routes
Aug 4, 2024
65a0b99
wip(agents-api): Session routes
Aug 4, 2024
50c898e
Reimplement tests for queries and operations (#443)
creatorrr Aug 5, 2024
33e86a2
feat(agents-api): Hybrid docs search (#444)
creatorrr Aug 5, 2024
41e5df8
feat(agents-api): Add temporal workflow lookup relation and queries (…
creatorrr Aug 5, 2024
1dc4ed3
feat: Resume workflow execution
whiterabbit1983 Aug 5, 2024
051a172
Merge branch 'dev-tasks-disable-routes' into f/new-routes
Aug 5, 2024
160c76f
feat(agents-api): Add user routes
Aug 5, 2024
c9c9a06
feat(agents-api): Add docs routes
Aug 5, 2024
3b6e81d
feat(agents-api): Add doc search routes
Aug 5, 2024
2cf9af5
Merge pull request #445 from julep-ai/f/new-routes
whiterabbit1983 Aug 6, 2024
6483fbe
fix: Fix update execution route
whiterabbit1983 Aug 6, 2024
781c7ab
feat(agents-api): Add litellm proxy to docker compose
Aug 8, 2024
31a485e
Merge pull request #448 from julep-ai/f/litellm
creatorrr Aug 9, 2024
10fee9d
refactor(agents-api): Move tests to root dir
Aug 9, 2024
d37965f
Update test files to reflect new location of model functions
creatorrr Aug 9, 2024
7bfab9a
creatorrr Aug 9, 2024
d5b08b9
Remove `DeleteDocRequest` import and related tests from `test_docs_qu…
creatorrr Aug 9, 2024
ad27ec0
fix(agents-api): Fixed tests
Aug 9, 2024
db58349
Merge pull request #449 from julep-ai/x/agents-api-tests
creatorrr Aug 9, 2024
440b5f7
Add tests for various queries in `agents-api`
creatorrr Aug 9, 2024
d305468
fix(agents-api): Fixed tests
Aug 9, 2024
c9b28e9
Merge pull request #450 from julep-ai/creatorrr/f-add-missing-tests
creatorrr Aug 9, 2024
afe3be8
feat(agents-api): Add route tests
Aug 9, 2024
dd52045
creatorrr Aug 9, 2024
d0b3e6b
fix(agents-api): Fixed tests
Aug 9, 2024
0ee50d4
Merge pull request #451 from julep-ai/f/route-tests
whiterabbit1983 Aug 10, 2024
4e6656c
fix: Apply fixes
whiterabbit1983 Aug 10, 2024
128f074
Add tests for docs routes
creatorrr Aug 10, 2024
e0c3140
feat(agents-api): Add docs tests
Aug 10, 2024
28afb53
feat: Implement error step
whiterabbit1983 Aug 10, 2024
f0111d8
Merge pull request #452 from julep-ai/creatorrr/add-docs-routes-tests
whiterabbit1983 Aug 10, 2024
2d379b8
feat(agents-api): Fix prepare_chat_context
Aug 10, 2024
e4c7827
feat(agents-api): Make session.render_templates true by default
Aug 10, 2024
8428659
wip(agents-api): Implementing chat
Aug 11, 2024
a107221
feat(agents-api,typespec): Re-org some of the endpoint models for pro…
Aug 11, 2024
b813353
feat(agents-api): Add litellm client
Aug 11, 2024
7043cdd
feat(model-serving): Remove model-serving container
Aug 11, 2024
068cef0
feat: Remove support for presets
Aug 11, 2024
aefe3ab
feat(agents-api): Add settings to developers relation
Aug 11, 2024
892226d
feat(agents-api): Preliminary implementation of session.chat
Aug 11, 2024
a3377dd
Merge pull request #453 from julep-ai/f/session-chat
whiterabbit1983 Aug 12, 2024
7ab4075
fix(agents-api): Minor fix to fastapi dependency
Aug 12, 2024
5f91ac3
feat(agents-api): Make chat route tests pass
Aug 12, 2024
dcc54c4
fix(agents-api): Fixed chat route and tests
Aug 13, 2024
6279937
feat(agents-api): Add /embed route
Aug 13, 2024
95dfa18
fix: Fix generation
whiterabbit1983 Aug 12, 2024
67db1fd
Merge pull request #454 from julep-ai/f/chat-tests
whiterabbit1983 Aug 13, 2024
9f8e6d6
feat(agents-api): Bump python version to 3.11
Aug 13, 2024
0f6e061
chore: Refactor tasks routes and add unit tests
whiterabbit1983 Aug 13, 2024
83a02cf
feat: Fix type checks
Aug 13, 2024
853da78
fix(agents-api): Fix chat endpoint behavior
Aug 13, 2024
afc3546
refactor(agents-api): Remove unnecessary stuff
Aug 13, 2024
be18ec6
feat(agents-api): Add fixtures for testing workflows
Aug 14, 2024
3a38e70
feat(agents-api): Add some workflow tests
Aug 14, 2024
9e4b707
Merge pull request #456 from julep-ai/f/workflow-tests
whiterabbit1983 Aug 14, 2024
82c8af2
fix(agents-api): Minor fix to tests
Aug 14, 2024
b1fc2a4
fix(agents-api): Fix tests and fixtures
Aug 14, 2024
3ab7758
refactor(agents-api): Move gather_messages to its own model
Aug 14, 2024
313a312
feat(agents-api): Add token count support using litellm
Aug 14, 2024
152c29a
feat(agents-api): Minor modifier to models
Aug 14, 2024
14544b9
Merge branch 'dev-tasks-disable-routes' into f/workflow-tests
Aug 14, 2024
e97b6fb
fix(agents-api): Minor fixes
Aug 15, 2024
9dca03e
Merge pull request #457 from julep-ai/f/workflow-tests
creatorrr Aug 15, 2024
adb2d9f
fix: Fix tasks routes and tests
whiterabbit1983 Aug 15, 2024
93a5fda
fix: Split create execution query
whiterabbit1983 Aug 16, 2024
cceae91
fix: Apply various small fixes
whiterabbit1983 Aug 16, 2024
0610f86
fix(agents-api): Minor fixes
Aug 15, 2024
939569b
wip
Aug 16, 2024
abb6e9a
wip
Aug 16, 2024
ebd3640
wip
Aug 16, 2024
00edef7
wip
Aug 16, 2024
a4e49a0
wip
Aug 16, 2024
be7471b
wip
Aug 16, 2024
d13a46f
Merge pull request #458 from julep-ai/f/task-tests
whiterabbit1983 Aug 16, 2024
cc43f38
fix(agents-api): Fix update_execution model
Aug 16, 2024
a22a65e
feat(agents-api): Add demo workflow for testing
Aug 16, 2024
2d3effe
fix(agents-api): Use a contextmanager instead of fixture for creating…
Aug 16, 2024
655d222
wip
Aug 16, 2024
0194c73
feat(agents-api): ALL TESTS PASS!! :D
Aug 17, 2024
729a0aa
Merge pull request #459 from julep-ai/f/task-tests
whiterabbit1983 Aug 17, 2024
ae112cb
feat: Add test for evaluate step
Aug 17, 2024
2fbd877
feat(agents-api): Add more tests for the task execution
Aug 17, 2024
010660b
refactor(agents-api): Add more types
Aug 17, 2024
8e0c9c0
feat(agents-api): Add lots of new steps
Aug 17, 2024
ae03634
feat(agents-api): Implement sleep step
Aug 17, 2024
b600eaf
feat(agents-api): Add return step
Aug 17, 2024
bbc7117
feat(agents-api): Add log step
Aug 17, 2024
d954077
feat(agents-api): Make evaluate_step, log_step, etc local activities
Aug 18, 2024
6cd98ae
feat(agents-api): Add wait_for_input step
Aug 18, 2024
2c6dada
refactor(agents-api): Minor refactors
Aug 18, 2024
9fdafaf
feat(agents-api): Add if-else step
Aug 19, 2024
aead2ab
wip(agents-api): Add stub for switch step
Aug 19, 2024
72da581
Merge pull request #460 from julep-ai/f/workflow-tests
whiterabbit1983 Aug 19, 2024
9c01928
fix(agents-api): Fix typespec for foreach step and regenerate
Aug 19, 2024
633c4f7
Merge pull request #461 from julep-ai/x/fix-typespec-foreach
whiterabbit1983 Aug 19, 2024
f8111ea
fix(agents-api): Fix the typespec bug and regenerate
Aug 20, 2024
5b97ce7
refactor(agents-api): Minor refactors
Aug 20, 2024
bd83b5c
fix(agents-api): Temporal local activities are too unreliable
Aug 20, 2024
b2fb5a9
fix(agents-api): Fix the codec, which was causing a lot of bugs
Aug 20, 2024
d92b054
refactor(agents-api): Minor refactors
Aug 20, 2024
9962356
feat(agents-api): Add YAML support
Aug 20, 2024
95a8889
Merge pull request #462 from julep-ai/x/fix-typespec-foreach
whiterabbit1983 Aug 20, 2024
b355113
Merge pull request #463 from julep-ai/x/fix-codec
whiterabbit1983 Aug 20, 2024
8263aea
Merge pull request #464 from julep-ai/f/yaml-task-create
whiterabbit1983 Aug 20, 2024
a63fb4a
feat: Add "switch" and "for each" activities
whiterabbit1983 Aug 20, 2024
744e2ef
refactor(agents-api): Minor refactors to typespec types
Aug 20, 2024
d2ab540
test: Test for each step, add small fixes
whiterabbit1983 Aug 20, 2024
1866a79
feat: Add map reduce step (WIP)
whiterabbit1983 Aug 20, 2024
8ab6dea
refactor(agents-api): MAJOR refactors to MAP-REDUCE and some typespec…
Aug 21, 2024
1c071ec
Merge pull request #465 from julep-ai/r/typespec-refactors
whiterabbit1983 Aug 21, 2024
3482bd4
feat: Add map reduce step
whiterabbit1983 Aug 21, 2024
30814b5
feat(agents-api): Switch step test passes!
Aug 21, 2024
a84cfcd
fix: Update map reduce logic
whiterabbit1983 Aug 22, 2024
14c8258
fix: Fix map reduce test
whiterabbit1983 Aug 22, 2024
81af536
chore: Enable prompt step
whiterabbit1983 Aug 22, 2024
c3d9ce7
fix: Fix prompt step test
whiterabbit1983 Aug 22, 2024
2a12e3c
fix(agents-api): Fix map reduce step and activity
Aug 23, 2024
93a32bf
Merge pull request #466 from julep-ai/x/map-reduce-step
whiterabbit1983 Aug 23, 2024
4c936b0
test: Add task yaml test
whiterabbit1983 Aug 23, 2024
e3bde88
chore: Rename accumulator value
whiterabbit1983 Aug 23, 2024
0a4708c
fix: Fix task file formatting
whiterabbit1983 Aug 23, 2024
effc4dd
feat(agents-api): Successfully create the sample task find_selector.yaml
Aug 23, 2024
47358c1
fix(agents-api): Fix agent/create-or-update route and YAML handling
Aug 23, 2024
80dd3f1
fix(agents-api): Fix tests and routes for sample
Aug 23, 2024
936ffbe
Merge branch 'x/map-reduce-step' into dev-tasks-disable-routes
Aug 23, 2024
3183267
feat(agents-api): Make the sample work (more or less)
Aug 24, 2024
8ec70ae
Add files via upload
creatorrr Aug 24, 2024
af121a2
fix: Fix templates rendering for different kind of messages
whiterabbit1983 Aug 24, 2024
abb36ba
fix(agents-api): Make the sample work
Aug 26, 2024
3457252
Merge pull request #467 from julep-ai/x/sample-test-fix
whiterabbit1983 Aug 26, 2024
9feb981
fix: Fix execute yaml task test
whiterabbit1983 Aug 26, 2024
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
14 changes: 14 additions & 0 deletions agents-api/agents_api/activities/task_steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
from temporalio import activity

from ...autogen.openapi_model import (
CreateTransitionRequest,
EvaluateStep,
# ErrorWorkflowStep,
IfElseWorkflowStep,
InputChatMLMessage,
PromptStep,
ToolCallStep,
UpdateExecutionRequest,
YieldStep,
)
from ...clients.worker.types import ChatML
Expand All @@ -23,6 +25,9 @@
from ...models.execution.create_execution_transition import (
create_execution_transition as create_execution_transition_query,
)
from ...models.execution.update_execution import (
update_execution as update_execution_query,
)
from ...routers.sessions.protocol import Settings
from ...routers.sessions.session import llm_generate

Expand Down Expand Up @@ -142,6 +147,15 @@ async def transition_step(
**transition_data,
)

update_execution_query(
developer_id=context.developer_id,
task_id=context.task.id,
execution_id=context.execution.id,
data=UpdateExecutionRequest(
status="awaiting_input",
),
)

# Raise if it's a waiting step
if transition_info.type == "awaiting_input":
activity.raise_complete_async()
84 changes: 64 additions & 20 deletions agents-api/agents_api/autogen/Docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,34 @@ class BaseDocSearchRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
confidence: Annotated[float, Field(0.5, ge=0.0, le=1.0)]
limit: Annotated[int, Field(10, ge=1, le=100)]
lang: Literal["en-US"] = "en-US"
"""
The confidence cutoff level
The language to be used for text-only search. Support for other languages coming soon.
"""
alpha: Annotated[float, Field(0.75, ge=0.0, le=1.0)]


class CreateDocRequest(BaseModel):
"""
The weight to apply to BM25 vs Vector search results. 0 => pure BM25; 1 => pure vector;
Payload for creating a doc
"""
mmr: bool = False

model_config = ConfigDict(
populate_by_name=True,
)
metadata: dict[str, Any] | None = None
title: Annotated[
str,
Field(
pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$"
),
]
"""
Whether to include the MMR algorithm in the search. Optimizes for diversity in search results.
Title describing what this document contains
"""
lang: Literal["en-US"] = "en-US"
content: str | list[str]
"""
The language to be used for text-only search. Support for other languages coming soon.
Contents of the document
"""


Expand Down Expand Up @@ -76,12 +89,23 @@ class DocReference(BaseModel):
"""
ID of the document
"""
snippet_index: list[int]
title: str | None = None
snippets: Annotated[list[Snippet], Field(min_length=1)]
distance: float | None = None


class DocSearchResponse(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
docs: list[DocReference]
"""
The documents that were found
"""
Snippets referred to of the document
time: Annotated[float, Field(gt=0.0)]
"""
The time taken to search in seconds
"""
title: str | None = None
snippet: str | None = None


class EmbedQueryRequest(BaseModel):
Expand All @@ -108,31 +132,51 @@ class HybridDocSearchRequest(BaseDocSearchRequest):
model_config = ConfigDict(
populate_by_name=True,
)
text: str | list[str]
confidence: Annotated[float, Field(0.5, ge=0.0, le=1.0)]
"""
The confidence cutoff level
"""
alpha: Annotated[float, Field(0.75, ge=0.0, le=1.0)]
"""
Text or texts to use in the search. In `hybrid` search mode, either `text` or both `text` and `vector` fields are required.
The weight to apply to BM25 vs Vector search results. 0 => pure BM25; 1 => pure vector;
"""
text: str
"""
vector: list[float] | list[list[float]]
Text to use in the search. In `hybrid` search mode, either `text` or both `text` and `vector` fields are required.
"""
Vector or vectors to use in the search. Must be the same dimensions as the embedding model or else an error will be thrown.
vector: list[float]
"""
Vector to use in the search. Must be the same dimensions as the embedding model or else an error will be thrown.
"""


class Snippet(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
index: int
content: str


class TextOnlyDocSearchRequest(BaseDocSearchRequest):
model_config = ConfigDict(
populate_by_name=True,
)
text: str | list[str]
text: str
"""
Text or texts to use in the search.
Text to use in the search.
"""


class VectorDocSearchRequest(BaseDocSearchRequest):
model_config = ConfigDict(
populate_by_name=True,
)
vector: list[float] | list[list[float]]
confidence: Annotated[float, Field(0.5, ge=0.0, le=1.0)]
"""
The confidence cutoff level
"""
vector: list[float]
"""
Vector or vectors to use in the search. Must be the same dimensions as the embedding model or else an error will be thrown.
Vector to use in the search. Must be the same dimensions as the embedding model or else an error will be thrown.
"""
4 changes: 0 additions & 4 deletions agents-api/agents_api/autogen/Executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class TaskTokenResumeExecutionRequest(BaseModel):
populate_by_name=True,
)
status: Literal["running"] = "running"
task_token: str
"""
A Task Token is a unique identifier for a specific Task Execution.
"""
input: dict[str, Any] | None = None
"""
The input to resume the execution with
Expand Down
9 changes: 8 additions & 1 deletion agents-api/agents_api/autogen/openapi_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ruff: noqa: F401, F403, F405
from typing import Annotated
from typing import Annotated, Generic, TypeVar
from uuid import UUID

from pydantic import AwareDatetime, Field
Expand Down Expand Up @@ -158,3 +158,10 @@ class UpdateTaskRequest(_UpdateTaskRequest):
"extra": "allow",
}
)


DataT = TypeVar("DataT", bound=BaseModel)


class ListResponse(BaseModel, Generic[DataT]):
items: list[DataT]
2 changes: 1 addition & 1 deletion agents-api/agents_api/clients/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def run_task_execution_workflow(
):
client = await get_client()

await client.execute_workflow(
return await client.start_workflow(
"TaskExecutionWorkflow",
args=[execution_input, start, previous_inputs],
task_queue="memory-task-queue",
Expand Down
22 changes: 22 additions & 0 deletions agents-api/agents_api/common/utils/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from typing import Type

from beartype.vale import Is
from beartype.vale._core._valecore import BeartypeValidator
from pydantic import BaseModel


def dict_like(pydantic_model_class: Type[BaseModel]) -> BeartypeValidator:
required_fields_set: set[str] = set(
[
field
for field, info in pydantic_model_class.model_fields.items()
if info.is_required()
]
)

validator = Is[
lambda x: isinstance(x, pydantic_model_class)
or required_fields_set.issubset(set(x.keys()))
]

return validator
11 changes: 11 additions & 0 deletions agents-api/agents_api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@

This module also integrates with the `common` module for exception handling and utility functions, ensuring robust error management and providing reusable components for data processing and query construction.
"""

# ruff: noqa: F401, F403, F405

import agents_api.models.agent as agent
import agents_api.models.docs as docs
import agents_api.models.entry as entry
import agents_api.models.execution as execution
import agents_api.models.session as session
import agents_api.models.task as task
import agents_api.models.tools as tools
import agents_api.models.user as user
10 changes: 10 additions & 0 deletions agents-api/agents_api/models/agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@

This module serves as the backbone for agent management within the CozoDB ecosystem, facilitating a wide range of operations necessary for the effective handling of agent data.
"""

# ruff: noqa: F401, F403, F405

from .create_agent import create_agent
from .create_or_update_agent import create_or_update_agent
from .delete_agent import delete_agent
from .get_agent import get_agent
from .list_agents import list_agents
from .patch_agent import patch_agent
from .update_agent import update_agent
12 changes: 3 additions & 9 deletions agents-api/agents_api/models/agent/create_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,12 @@ def create_agent(
Constructs and executes a datalog query to create a new agent in the database.

Parameters:
- agent_id (UUID): The unique identifier for the agent.
- agent_id (UUID | None): The unique identifier for the agent.
- developer_id (UUID): The unique identifier for the developer creating the agent.
- name (str): The name of the agent.
- about (str): A description of the agent.
- instructions (list[str], optional): A list of instructions for using the agent. Defaults to an empty list.
- model (str, optional): The model identifier for the agent. Defaults to "julep-ai/samantha-1-turbo".
- metadata (dict, optional): A dictionary of metadata for the agent. Defaults to an empty dict.
- default_settings (dict, optional): A dictionary of default settings for the agent. Defaults to an empty dict.
- client (CozoClient, optional): The CozoDB client instance to use for the query. Defaults to a preconfigured client instance.
- data (CreateAgentRequest): The data for the new agent.

Returns:
Agent: The newly created agent record.
- Agent: The newly created agent record.
"""

agent_id = agent_id or uuid4()
Expand Down
Loading
Loading