-
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.
Merge pull request #455 from julep-ai/f/chat-tests
fix(agents-api): Fix chat endpoint behavior
- Loading branch information
Showing
60 changed files
with
625 additions
and
1,242 deletions.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.embed import embed | ||
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 embed( | ||
|
||
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
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.