Compare commits

...

2 Commits

Author SHA1 Message Date
Daniel O'Connell
489265fe31 fix session id for observations 2025-06-04 16:21:49 +02:00
Daniel O'Connell
81c9ea9ed5 tweaks 2025-06-04 15:23:02 +02:00
6 changed files with 49 additions and 8 deletions

View File

@ -0,0 +1,39 @@
"""observation session as string
Revision ID: 58439dd3088b
Revises: 77cdbfc882e2
Create Date: 2025-06-04 16:21:13.610668
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = "58439dd3088b"
down_revision: Union[str, None] = "77cdbfc882e2"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.alter_column(
"agent_observation",
"session_id",
existing_type=sa.UUID(),
type_=sa.Text(),
existing_nullable=True,
)
def downgrade() -> None:
op.alter_column(
"agent_observation",
"session_id",
existing_type=sa.Text(),
type_=sa.UUID(),
existing_nullable=True,
)

View File

@ -81,7 +81,7 @@ def handle_duplicate_sha256(session, flush_context, instances):
def clean_filename(filename: str) -> str:
return re.sub(r"[^a-zA-Z0-9_]", "_", filename).strip("_")
return re.sub(r"[^a-zA-Z0-9_]", "_", filename).strip("_")[:30]
def image_filenames(chunk_id: str, images: list[Image.Image]) -> list[str]:

View File

@ -564,9 +564,7 @@ class AgentObservation(SourceItem):
id = Column(
BigInteger, ForeignKey("source_item.id", ondelete="CASCADE"), primary_key=True
)
session_id = Column(
UUID(as_uuid=True)
) # Groups observations from same conversation
session_id = Column(Text, nullable=True)
observation_type = Column(
Text, nullable=False
) # belief, preference, pattern, contradiction, behavior

View File

@ -99,7 +99,7 @@ QDRANT_TIMEOUT = int(os.getenv("QDRANT_TIMEOUT", "60"))
# Worker settings
# Intervals are in seconds
EMAIL_SYNC_INTERVAL = int(os.getenv("EMAIL_SYNC_INTERVAL", 60 * 60))
COMIC_SYNC_INTERVAL = int(os.getenv("COMIC_SYNC_INTERVAL", 60 * 60))
COMIC_SYNC_INTERVAL = int(os.getenv("COMIC_SYNC_INTERVAL", 60 * 60 * 24))
ARTICLE_FEED_SYNC_INTERVAL = int(os.getenv("ARTICLE_FEED_SYNC_INTERVAL", 30 * 60))
CLEAN_COLLECTION_INTERVAL = int(os.getenv("CLEAN_COLLECTION_INTERVAL", 24 * 60 * 60))
CHUNK_REINGEST_INTERVAL = int(os.getenv("CHUNK_REINGEST_INTERVAL", 60 * 60))

View File

@ -5,6 +5,8 @@ from memory.common.celery_app import (
app,
CLEAN_ALL_COLLECTIONS,
REINGEST_MISSING_CHUNKS,
SYNC_ALL_COMICS,
SYNC_ALL_ARTICLE_FEEDS,
)
logger = logging.getLogger(__name__)
@ -24,11 +26,11 @@ app.conf.beat_schedule = {
"schedule": settings.EMAIL_SYNC_INTERVAL,
},
"sync-all-comics": {
"task": "memory.workers.tasks.comic.sync_all_comics",
"task": SYNC_ALL_COMICS,
"schedule": settings.COMIC_SYNC_INTERVAL,
},
"sync-all-article-feeds": {
"task": "memory.workers.tasks.blogs.sync_all_article_feeds",
"task": SYNC_ALL_ARTICLE_FEEDS,
"schedule": settings.ARTICLE_FEED_SYNC_INTERVAL,
},
}

View File

@ -91,7 +91,9 @@ def sync_comic(
file_type = image_url.split(".")[-1]
mime_type = f"image/{file_type}"
filename = (
settings.COMIC_STORAGE_DIR / clean_filename(author) / f"{title}.{file_type}"
settings.COMIC_STORAGE_DIR
/ clean_filename(author)
/ f"{clean_filename(title)}.{file_type}"
)
filename.parent.mkdir(parents=True, exist_ok=True)