Skip to content

Commit

Permalink
Merge branch 'dev' into f/litellm-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
alt-glitch authored May 1, 2024
2 parents 8e71121 + 1f5078a commit fc0d80c
Show file tree
Hide file tree
Showing 27 changed files with 396 additions and 294 deletions.
8 changes: 6 additions & 2 deletions agents-api/agents_api/autogen/openapi_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: openapi.yaml
# timestamp: 2024-04-26T08:42:42+00:00
# timestamp: 2024-04-30T17:38:56+00:00

from __future__ import annotations

Expand Down Expand Up @@ -632,12 +632,16 @@ class Doc(BaseModel):
"""


class ContentItem(RootModel[str]):
root: Annotated[str, Field(min_length=1)]


class CreateDoc(BaseModel):
title: str
"""
Title describing what this bit of information contains
"""
content: str
content: List[ContentItem] | str
"""
Information content
"""
Expand Down
3 changes: 2 additions & 1 deletion agents-api/agents_api/clients/embed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import httpx
from ..env import embedding_service_url, truncate_embed_text
from ..env import embedding_service_url, truncate_embed_text, embedding_model_id


async def embed(
Expand All @@ -17,6 +17,7 @@ async def embed(
"normalize": True,
# FIXME: We should control the truncation ourselves and truncate before sending
"truncate": truncate_embed_text,
"model_id": embedding_model_id,
},
)
resp.raise_for_status()
Expand Down
4 changes: 4 additions & 0 deletions agents-api/agents_api/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
"EMBEDDING_SERVICE_URL", default="http://0.0.0.0:8082/embed"
)

embedding_model_id: str = env.str(
"EMBEDDING_MODEL_ID", default="BAAI/bge-large-en-v1.5"
)

truncate_embed_text: bool = env.bool("TRUNCATE_EMBED_TEXT", default=False)

# Temporal
Expand Down
10 changes: 3 additions & 7 deletions agents-api/agents_api/models/docs/create_docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, Literal
from typing import Literal
from uuid import UUID


Expand All @@ -13,8 +13,7 @@ def create_docs_query(
owner_id: UUID,
id: UUID,
title: str,
content: str,
split_fn: Callable[[str], list[str]] = lambda x: x.split("\n\n"),
content: list[str],
metadata: dict = {},
) -> tuple[str, dict]:
"""
Expand All @@ -26,19 +25,16 @@ def create_docs_query(
- id (UUID): The UUID of the document to be created.
- title (str): The title of the document.
- content (str): The content of the document, which will be split into snippets.
- split_fn (Callable[[str], list[str]]): A function to split the content into snippets. Defaults to splitting by double newlines.
- metadata (dict): Metadata associated with the document. Defaults to an empty dictionary.
Returns:
pd.DataFrame: A DataFrame containing the results of the query execution.
"""
created_at: float = utcnow().timestamp()

snippets = split_fn(content)
snippet_cols, snippet_rows = "", []

# Process each content snippet and prepare data for the datalog query.
for snippet_idx, snippet in enumerate(snippets):
for snippet_idx, snippet in enumerate(content):
snippet_cols, new_snippet_rows = cozo_process_mutate_data(
dict(
doc_id=str(id),
Expand Down
5 changes: 3 additions & 2 deletions agents-api/agents_api/routers/agents/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,13 @@ async def list_agents(
@router.post("/agents/{agent_id}/docs", tags=["agents"])
async def create_docs(agent_id: UUID4, request: CreateDoc) -> ResourceCreatedResponse:
doc_id = uuid4()
content = [request.content] if isinstance(request.content, str) else request.content
resp: pd.DataFrame = create_docs_query(
owner_type="agent",
owner_id=agent_id,
id=doc_id,
title=request.title,
content=request.content,
content=content,
metadata=request.metadata or {},
)

Expand All @@ -317,7 +318,7 @@ async def create_docs(agent_id: UUID4, request: CreateDoc) -> ResourceCreatedRes
created_at=resp["created_at"][0],
)

indices, snippets = list(zip(*enumerate(request.content.split("\n\n"))))
indices, snippets = list(zip(*enumerate(content)))
embeddings = await embed(
[
snippet_embed_instruction + request.title + "\n\n" + snippet
Expand Down
5 changes: 3 additions & 2 deletions agents-api/agents_api/routers/users/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,13 @@ async def list_users(
@router.post("/users/{user_id}/docs", tags=["users"])
async def create_docs(user_id: UUID4, request: CreateDoc) -> ResourceCreatedResponse:
doc_id = uuid4()
content = [request.content] if isinstance(request.content, str) else request.content
resp: pd.DataFrame = create_docs_query(
owner_type="user",
owner_id=user_id,
id=doc_id,
title=request.title,
content=request.content,
content=content,
metadata=request.metadata or {},
)

Expand All @@ -253,7 +254,7 @@ async def create_docs(user_id: UUID4, request: CreateDoc) -> ResourceCreatedResp
created_at=resp["created_at"][0],
)

indices, snippets = list(zip(*enumerate(request.content.split("\n\n"))))
indices, snippets = list(zip(*enumerate(content)))
embeddings = await embed(
[
snippet_embed_instruction + request.title + "\n\n" + snippet
Expand Down
12 changes: 6 additions & 6 deletions docs/js-sdk-docs/classes/api.ApiError.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Error.constructor

#### Defined in

[src/api/core/ApiError.ts:15](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/ApiError.ts#L15)
[src/api/core/ApiError.ts:15](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/ApiError.ts#L15)

## Properties

Expand All @@ -67,7 +67,7 @@ Error.constructor

#### Defined in

[src/api/core/ApiError.ts:12](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/ApiError.ts#L12)
[src/api/core/ApiError.ts:12](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/ApiError.ts#L12)

___

Expand Down Expand Up @@ -105,7 +105,7 @@ ___

#### Defined in

[src/api/core/ApiError.ts:13](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/ApiError.ts#L13)
[src/api/core/ApiError.ts:13](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/ApiError.ts#L13)

___

Expand All @@ -129,7 +129,7 @@ ___

#### Defined in

[src/api/core/ApiError.ts:10](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/ApiError.ts#L10)
[src/api/core/ApiError.ts:10](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/ApiError.ts#L10)

___

Expand All @@ -139,7 +139,7 @@ ___

#### Defined in

[src/api/core/ApiError.ts:11](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/ApiError.ts#L11)
[src/api/core/ApiError.ts:11](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/ApiError.ts#L11)

___

Expand All @@ -149,7 +149,7 @@ ___

#### Defined in

[src/api/core/ApiError.ts:9](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/ApiError.ts#L9)
[src/api/core/ApiError.ts:9](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/ApiError.ts#L9)

___

Expand Down
6 changes: 3 additions & 3 deletions docs/js-sdk-docs/classes/api.BaseHttpRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#### Defined in

[src/api/core/BaseHttpRequest.ts:10](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/BaseHttpRequest.ts#L10)
[src/api/core/BaseHttpRequest.ts:10](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/BaseHttpRequest.ts#L10)

## Properties

Expand All @@ -46,7 +46,7 @@

#### Defined in

[src/api/core/BaseHttpRequest.ts:10](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/BaseHttpRequest.ts#L10)
[src/api/core/BaseHttpRequest.ts:10](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/BaseHttpRequest.ts#L10)

## Methods

Expand All @@ -72,4 +72,4 @@

#### Defined in

[src/api/core/BaseHttpRequest.ts:12](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/BaseHttpRequest.ts#L12)
[src/api/core/BaseHttpRequest.ts:12](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/BaseHttpRequest.ts#L12)
4 changes: 2 additions & 2 deletions docs/js-sdk-docs/classes/api.CancelError.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Error.constructor

#### Defined in

[src/api/core/CancelablePromise.ts:6](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L6)
[src/api/core/CancelablePromise.ts:6](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L6)

## Properties

Expand Down Expand Up @@ -159,7 +159,7 @@ node_modules/@types/node/globals.d.ts:30

#### Defined in

[src/api/core/CancelablePromise.ts:11](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L11)
[src/api/core/CancelablePromise.ts:11](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L11)

## Methods

Expand Down
28 changes: 14 additions & 14 deletions docs/js-sdk-docs/classes/api.CancelablePromise.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

#### Defined in

[src/api/core/CancelablePromise.ts:33](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L33)
[src/api/core/CancelablePromise.ts:33](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L33)

## Properties

Expand All @@ -76,7 +76,7 @@

#### Defined in

[src/api/core/CancelablePromise.ts:28](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L28)
[src/api/core/CancelablePromise.ts:28](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L28)

___

Expand All @@ -86,7 +86,7 @@ ___

#### Defined in

[src/api/core/CancelablePromise.ts:27](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L27)
[src/api/core/CancelablePromise.ts:27](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L27)

___

Expand All @@ -96,7 +96,7 @@ ___

#### Defined in

[src/api/core/CancelablePromise.ts:26](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L26)
[src/api/core/CancelablePromise.ts:26](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L26)

___

Expand All @@ -106,7 +106,7 @@ ___

#### Defined in

[src/api/core/CancelablePromise.ts:25](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L25)
[src/api/core/CancelablePromise.ts:25](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L25)

___

Expand All @@ -116,7 +116,7 @@ ___

#### Defined in

[src/api/core/CancelablePromise.ts:29](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L29)
[src/api/core/CancelablePromise.ts:29](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L29)

___

Expand All @@ -140,7 +140,7 @@ ___

#### Defined in

[src/api/core/CancelablePromise.ts:31](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L31)
[src/api/core/CancelablePromise.ts:31](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L31)

___

Expand All @@ -164,7 +164,7 @@ ___

#### Defined in

[src/api/core/CancelablePromise.ts:30](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L30)
[src/api/core/CancelablePromise.ts:30](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L30)

## Accessors

Expand All @@ -182,7 +182,7 @@ Promise.[toStringTag]

#### Defined in

[src/api/core/CancelablePromise.ts:87](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L87)
[src/api/core/CancelablePromise.ts:87](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L87)

___

Expand All @@ -196,7 +196,7 @@ ___

#### Defined in

[src/api/core/CancelablePromise.ts:127](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L127)
[src/api/core/CancelablePromise.ts:127](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L127)

## Methods

Expand All @@ -210,7 +210,7 @@ ___

#### Defined in

[src/api/core/CancelablePromise.ts:108](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L108)
[src/api/core/CancelablePromise.ts:108](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L108)

___

Expand Down Expand Up @@ -240,7 +240,7 @@ Promise.catch

#### Defined in

[src/api/core/CancelablePromise.ts:98](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L98)
[src/api/core/CancelablePromise.ts:98](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L98)

___

Expand All @@ -264,7 +264,7 @@ Promise.finally

#### Defined in

[src/api/core/CancelablePromise.ts:104](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L104)
[src/api/core/CancelablePromise.ts:104](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L104)

___

Expand Down Expand Up @@ -296,4 +296,4 @@ Promise.then

#### Defined in

[src/api/core/CancelablePromise.ts:91](https://github.com/julep-ai/julep/blob/2427a5e8467e0e6e24dfb9b44e47b5c6ab06feb8/sdks/ts/src/api/core/CancelablePromise.ts#L91)
[src/api/core/CancelablePromise.ts:91](https://github.com/julep-ai/julep/blob/9bcf5a9efc57368b7904f9648f3fe15e5bfc1b0d/sdks/ts/src/api/core/CancelablePromise.ts#L91)
Loading

0 comments on commit fc0d80c

Please sign in to comment.