-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agents-api): Add fixtures for testing workflows
Signed-off-by: Diwank Tomer <[email protected]>
- Loading branch information
Diwank Tomer
committed
Aug 14, 2024
1 parent
31e0728
commit dbb1b32
Showing
20 changed files
with
333 additions
and
578 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,27 +1,39 @@ | ||
from pydantic import UUID4 | ||
from uuid import UUID | ||
|
||
from temporalio import activity | ||
|
||
from agents_api.clients import embed as embedder | ||
from agents_api.clients.cozo import get_cozo_client | ||
from agents_api.models.docs.embed_snippets import embed_snippets as embed_snippets_query | ||
|
||
snippet_embed_instruction = "Encode this passage for retrieval: " | ||
|
||
|
||
@activity.defn | ||
async def embed_docs(doc_id: UUID4, title: str, content: list[str]) -> None: | ||
async def embed_docs( | ||
developer_id: UUID, | ||
doc_id: UUID, | ||
title: str, | ||
content: list[str], | ||
include_title: bool = True, | ||
cozo_client=None, | ||
) -> None: | ||
indices, snippets = list(zip(*enumerate(content))) | ||
|
||
embeddings = await embedder.embed( | ||
[ | ||
{ | ||
"instruction": snippet_embed_instruction, | ||
"text": title + "\n\n" + snippet, | ||
"text": (title + "\n\n" + snippet) if include_title else snippet, | ||
} | ||
for snippet in snippets | ||
] | ||
) | ||
|
||
embed_snippets_query( | ||
developer_id=developer_id, | ||
doc_id=doc_id, | ||
snippet_indices=indices, | ||
embeddings=embeddings, | ||
client=cozo_client or get_cozo_client(), | ||
) |
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
Oops, something went wrong.