Compare commits

...
Author SHA1 Message Date
Nicolò Boschi 6d4051d347 fix(ui): timestamp is not considered in retain 2025-12-22 22:24:08 +01:00
5 changed files with 132 additions and 8 deletions
+19 -2
View File
@@ -29,7 +29,7 @@ def _parse_metadata(metadata: Any) -> dict[str, Any]:
return {}
from pydantic import BaseModel, ConfigDict, Field
from pydantic import BaseModel, ConfigDict, Field, field_validator
from hindsight_api import MemoryEngine
from hindsight_api.engine.db_utils import acquire_with_retry
@@ -291,7 +291,7 @@ class MemoryItem(BaseModel):
"metadata": {"source": "slack", "channel": "engineering"},
"document_id": "meeting_notes_2024_01_15",
}
}
},
)
content: str
@@ -300,6 +300,23 @@ class MemoryItem(BaseModel):
metadata: dict[str, str] | None = None
document_id: str | None = Field(default=None, description="Optional document ID for this memory item.")
@field_validator("timestamp", mode="before")
@classmethod
def validate_timestamp(cls, v):
if v is None or v == "":
return None
if isinstance(v, datetime):
return v
if isinstance(v, str):
try:
# Try parsing as ISO format
return datetime.fromisoformat(v.replace("Z", "+00:00"))
except ValueError as e:
raise ValueError(
f"Invalid timestamp/event_date format: '{v}'. Expected ISO format like '2024-01-15T10:30:00' or '2024-01-15T10:30:00Z'"
) from e
raise ValueError(f"timestamp must be a string or datetime, got {type(v).__name__}")
class RetainRequest(BaseModel):
"""Request model for retain endpoint."""
@@ -39,7 +39,8 @@ export function AddMemoryView() {
try {
const item: any = { content };
if (context) item.context = context;
if (eventDate) item.timestamp = eventDate;
// datetime-local gives "2024-01-15T10:30", add seconds for proper ISO format
if (eventDate) item.timestamp = eventDate + ":00";
const data: any = await client.retain({
bank_id: currentBank,
@@ -85,7 +85,8 @@ function BankSelectorInner() {
try {
const item: any = { content: docContent };
if (docContext) item.context = docContext;
if (docEventDate) item.event_date = docEventDate;
// datetime-local gives "2024-01-15T10:30", add seconds for proper ISO format
if (docEventDate) item.timestamp = docEventDate + ":00";
const params: any = {
bank_id: currentBank,
+105
View File
@@ -24202,6 +24202,111 @@
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "16.0.10",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.0.10.tgz",
"integrity": "sha512-spbEObMvRKkQ3CkYVOME+ocPDFo5UqHb8EMTS78/0mQ+O1nqE8toHJVioZo4TvebATxgA8XMTHHrScPrn68OGw==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "16.0.10",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.0.10.tgz",
"integrity": "sha512-uQtWE3X0iGB8apTIskOMi2w/MKONrPOUCi5yLO+v3O8Mb5c7K4Q5KD1jvTpTF5gJKa3VH/ijKjKUq9O9UhwOYw==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "16.0.10",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.0.10.tgz",
"integrity": "sha512-llA+hiDTrYvyWI21Z0L1GiXwjQaanPVQQwru5peOgtooeJ8qx3tlqRV2P7uH2pKQaUfHxI/WVarvI5oYgGxaTw==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-gnu": {
"version": "16.0.10",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.0.10.tgz",
"integrity": "sha512-AK2q5H0+a9nsXbeZ3FZdMtbtu9jxW4R/NgzZ6+lrTm3d6Zb7jYrWcgjcpM1k8uuqlSy4xIyPR2YiuUr+wXsavA==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-musl": {
"version": "16.0.10",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.0.10.tgz",
"integrity": "sha512-1TDG9PDKivNw5550S111gsO4RGennLVl9cipPhtkXIFVwo31YZ73nEbLjNC8qG3SgTz/QZyYyaFYMeY4BKZR/g==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
"version": "16.0.10",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.0.10.tgz",
"integrity": "sha512-aEZIS4Hh32xdJQbHz121pyuVZniSNoqDVx1yIr2hy+ZwJGipeqnMZBJHyMxv2tiuAXGx6/xpTcQJ6btIiBjgmg==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-x64-msvc": {
"version": "16.0.10",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.0.10.tgz",
"integrity": "sha512-E+njfCoFLb01RAFEnGZn6ERoOqhK1Gl3Lfz1Kjnj0Ulfu7oJbuMyvBKNj/bw8XZnenHDASlygTjZICQW+rYW1Q==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
}
}
}
Generated
+4 -4
View File
@@ -1292,7 +1292,7 @@ wheels = [
[[package]]
name = "hindsight-all"
version = "0.1.11"
version = "0.1.12"
source = { editable = "hindsight" }
dependencies = [
{ name = "hindsight-api" },
@@ -1316,7 +1316,7 @@ provides-extras = ["test"]
[[package]]
name = "hindsight-api"
version = "0.1.11"
version = "0.1.12"
source = { editable = "hindsight-api" }
dependencies = [
{ name = "alembic" },
@@ -1422,7 +1422,7 @@ dev = [
[[package]]
name = "hindsight-client"
version = "0.1.11"
version = "0.1.12"
source = { editable = "hindsight-clients/python" }
dependencies = [
{ name = "aiohttp" },
@@ -1456,7 +1456,7 @@ provides-extras = ["test"]
[[package]]
name = "hindsight-dev"
version = "0.1.11"
version = "0.1.12"
source = { editable = "hindsight-dev" }
dependencies = [
{ name = "hindsight-api" },