Skip to content

Commit

Permalink
fix: Fix queries calls (#283)
Browse files Browse the repository at this point in the history
* fix: Fix queries calls

* refactor: Lint agents-api (CI)

---------

Co-authored-by: whiterabbit1983 <[email protected]>
Co-authored-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
3 people authored Apr 20, 2024
1 parent 9795f39 commit 2fd82a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 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],
)
14 changes: 5 additions & 9 deletions agents-api/agents_api/models/entry/entries_summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from ...common.protocol.entries import Entry
from ..utils import cozo_query
from ...common.utils import json


@cozo_query
Expand Down Expand Up @@ -83,18 +82,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 2fd82a4

Please sign in to comment.