Skip to content

Commit

Permalink
fix: Fix queries calls
Browse files Browse the repository at this point in the history
  • Loading branch information
whiterabbit1983 committed Apr 19, 2024
1 parent 7000518 commit 4e3ca77
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
15 changes: 5 additions & 10 deletions agents-api/agents_api/activities/summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import Callable
from textwrap import dedent
from temporalio import activity
from agents_api.clients.cozo import client
from agents_api.models.entry.entries_summarization import (
get_toplevel_entries_query,
entries_summarization_query,
Expand Down Expand Up @@ -154,9 +153,7 @@ async def summarization(session_id: str) -> None:
session_id = UUID(session_id)
entries = [
Entry(**row)
for _, row in client.run(
get_toplevel_entries_query(session_id=session_id)
).iterrows()
for _, row in get_toplevel_entries_query(session_id=session_id).iterrows()
]

assert len(entries) > 0, "no need to summarize on empty entries list"
Expand All @@ -172,10 +169,8 @@ async def summarization(session_id: str) -> None:
timestamp=entries[-1].timestamp + 0.01,
)

client.run(
entries_summarization_query(
session_id=session_id,
new_entry=new_entry,
old_entry_ids=[e.id for e in entries],
)
entries_summarization_query(
session_id=session_id,
new_entry=new_entry,
old_entry_ids=[e.id for e in entries],
)
6 changes: 4 additions & 2 deletions agents-api/agents_api/activities/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ class ChatML(BaseModel):
token_count: Optional[int] = None


class BaseTask(BaseModel): ...
class BaseTask(BaseModel):
...


class BaseTaskArgs(BaseModel): ...
class BaseTaskArgs(BaseModel):
...


class AddPrinciplesTaskArgs(BaseTaskArgs):
Expand Down
6 changes: 4 additions & 2 deletions agents-api/agents_api/clients/worker/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ class ChatML(BaseModel):
token_count: Optional[int] = None


class BaseTask(BaseModel): ...
class BaseTask(BaseModel):
...


class BaseTaskArgs(BaseModel): ...
class BaseTaskArgs(BaseModel):
...


class MemoryManagementTaskArgs(BaseTaskArgs):
Expand Down
13 changes: 5 additions & 8 deletions agents-api/agents_api/models/entry/entries_summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,15 @@ def entries_summarization_query(
# Create a list of relations indicating which entries the new entry summarizes.

# Convert the new entry's source information into JSON format for storage.
source = json.dumps(new_entry.source)
role = json.dumps(new_entry.role)
content = json.dumps(new_entry.content)

entries = [
[
new_entry.id,
session_id,
source,
role,
str(new_entry.id),
str(session_id),
new_entry.source,
new_entry.role,
new_entry.name or "",
content,
new_entry.content,
new_entry.token_count,
new_entry.tokenizer,
new_entry.created_at,
Expand Down
1 change: 0 additions & 1 deletion agents-api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ services:
build:
context: .
dockerfile: Dockerfile.worker
entrypoint: ["tail", "-f", "/dev/null"]
depends_on:
text-embeddings-inference:
condition: service_started
Expand Down

0 comments on commit 4e3ca77

Please sign in to comment.