Skip to content

Commit

Permalink
fix: Add missing fields for entry
Browse files Browse the repository at this point in the history
  • Loading branch information
whiterabbit1983 committed Sep 19, 2024
1 parent 9574110 commit dd517e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
8 changes: 7 additions & 1 deletion agents-api/agents_api/activities/summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@


import asyncio
from uuid import UUID
from uuid import UUID, uuid4

from beartype import beartype
from temporalio import activity

from agents_api.autogen.openapi_model import Entry
from agents_api.common.utils.datetime import utcnow
from agents_api.env import summarization_model_name
from agents_api.models.entry.entries_summarization import (
entries_summarization_query,
Expand Down Expand Up @@ -38,13 +39,18 @@ async def summarization(session_id: str) -> None:
)
trimmed_messages = await trim_messages(summarized, model=summarization_model_name)
ts_delta = (entries[1]["timestamp"] - entries[0]["timestamp"]) / 2
# TODO: set tokenizer, double check token_count calculation
new_entities_entry = Entry(
id=uuid4(),
session_id=session_id,
source="summarizer",
role="system",
name="entities",
content=entities["content"],
timestamp=entries[0]["timestamp"] + ts_delta,
token_count=sum([len(c) // 3.5 for c in entities["content"]]),
created_at=utcnow(),
tokenizer="",
)

entries_summarization_query(
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/routers/sessions/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def chat(
new_messages = await render_template(new_raw_messages, variables=env)
else:
new_messages = new_raw_messages

for m in past_messages:
with suppress(KeyError):
del m["created_at"]
Expand Down
1 change: 0 additions & 1 deletion agents-api/agents_api/routers/tasks/update_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ async def update_execution(
await wf_handle.cancel()

case ResumeExecutionRequest():

token_data = get_paused_execution_token(
developer_id=x_developer_id, execution_id=execution_id
)
Expand Down

0 comments on commit dd517e3

Please sign in to comment.