hindsight-api 0.1.6__tar.gz → 0.1.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. hindsight_api-0.1.8/PKG-INFO +178 -0
  2. hindsight_api-0.1.8/README.md +137 -0
  3. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/api/http.py +16 -12
  4. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/memory_engine.py +3 -3
  5. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/pyproject.toml +3 -3
  6. hindsight_api-0.1.6/PKG-INFO +0 -42
  7. hindsight_api-0.1.6/README.md +0 -1
  8. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/.gitignore +0 -0
  9. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/__init__.py +0 -0
  10. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/alembic/README +0 -0
  11. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/alembic/env.py +0 -0
  12. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/alembic/script.py.mako +0 -0
  13. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/alembic/versions/5a366d414dce_initial_schema.py +0 -0
  14. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/alembic/versions/b7c4d8e9f1a2_add_chunks_table.py +0 -0
  15. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/alembic/versions/c8e5f2a3b4d1_add_retain_params_to_documents.py +0 -0
  16. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/alembic/versions/d9f6a3b4c5e2_rename_bank_to_interactions.py +0 -0
  17. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/alembic/versions/e0a1b2c3d4e5_disposition_to_3_traits.py +0 -0
  18. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/alembic/versions/rename_personality_to_disposition.py +0 -0
  19. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/api/__init__.py +0 -0
  20. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/api/mcp.py +0 -0
  21. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/banner.py +0 -0
  22. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/config.py +0 -0
  23. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/__init__.py +0 -0
  24. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/cross_encoder.py +0 -0
  25. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/db_utils.py +0 -0
  26. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/embeddings.py +0 -0
  27. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/entity_resolver.py +0 -0
  28. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/llm_wrapper.py +0 -0
  29. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/query_analyzer.py +0 -0
  30. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/response_models.py +0 -0
  31. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/__init__.py +0 -0
  32. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/bank_utils.py +0 -0
  33. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/chunk_storage.py +0 -0
  34. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/deduplication.py +0 -0
  35. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/embedding_processing.py +0 -0
  36. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/embedding_utils.py +0 -0
  37. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/entity_processing.py +0 -0
  38. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/fact_extraction.py +0 -0
  39. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/fact_storage.py +0 -0
  40. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/link_creation.py +0 -0
  41. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/link_utils.py +0 -0
  42. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/observation_regeneration.py +0 -0
  43. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/orchestrator.py +0 -0
  44. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/retain/types.py +0 -0
  45. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/__init__.py +0 -0
  46. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/fusion.py +0 -0
  47. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/graph_retrieval.py +0 -0
  48. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/mpfp_retrieval.py +0 -0
  49. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/observation_utils.py +0 -0
  50. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/reranking.py +0 -0
  51. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/retrieval.py +0 -0
  52. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/scoring.py +0 -0
  53. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/temporal_extraction.py +0 -0
  54. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/think_utils.py +0 -0
  55. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/trace.py +0 -0
  56. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/tracer.py +0 -0
  57. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/search/types.py +0 -0
  58. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/task_backend.py +0 -0
  59. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/engine/utils.py +0 -0
  60. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/main.py +0 -0
  61. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/mcp_local.py +0 -0
  62. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/metrics.py +0 -0
  63. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/migrations.py +0 -0
  64. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/models.py +0 -0
  65. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/pg0.py +0 -0
  66. {hindsight_api-0.1.6 → hindsight_api-0.1.8}/hindsight_api/server.py +0 -0
@@ -0,0 +1,178 @@
1
+ Metadata-Version: 2.4
2
+ Name: hindsight-api
3
+ Version: 0.1.8
4
+ Summary: Hindsight: Agent Memory That Works Like Human Memory
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: alembic>=1.17.1
7
+ Requires-Dist: asyncpg>=0.29.0
8
+ Requires-Dist: dateparser>=1.2.2
9
+ Requires-Dist: fastapi[standard]>=0.120.3
10
+ Requires-Dist: fastmcp>=2.3.0
11
+ Requires-Dist: google-genai>=1.0.0
12
+ Requires-Dist: greenlet>=3.2.4
13
+ Requires-Dist: httpx>=0.27.0
14
+ Requires-Dist: langchain-text-splitters>=0.3.0
15
+ Requires-Dist: openai>=1.0.0
16
+ Requires-Dist: opentelemetry-api>=1.20.0
17
+ Requires-Dist: opentelemetry-exporter-prometheus>=0.41b0
18
+ Requires-Dist: opentelemetry-instrumentation-fastapi>=0.41b0
19
+ Requires-Dist: opentelemetry-sdk>=1.20.0
20
+ Requires-Dist: pg0-embedded>=0.11.0
21
+ Requires-Dist: pgvector>=0.4.1
22
+ Requires-Dist: psycopg2-binary>=2.9.11
23
+ Requires-Dist: pydantic>=2.0.0
24
+ Requires-Dist: python-dateutil>=2.8.0
25
+ Requires-Dist: python-dotenv>=1.0.0
26
+ Requires-Dist: rich>=13.0.0
27
+ Requires-Dist: sentence-transformers<3.3.0,>=3.0.0
28
+ Requires-Dist: sqlalchemy>=2.0.44
29
+ Requires-Dist: tiktoken>=0.12.0
30
+ Requires-Dist: torch>=2.0.0
31
+ Requires-Dist: transformers<4.46.0,>=4.30.0
32
+ Requires-Dist: uvicorn>=0.38.0
33
+ Requires-Dist: wsproto>=1.0.0
34
+ Provides-Extra: test
35
+ Requires-Dist: filelock>=3.0.0; extra == 'test'
36
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'test'
37
+ Requires-Dist: pytest-timeout>=2.4.0; extra == 'test'
38
+ Requires-Dist: pytest-xdist>=3.0.0; extra == 'test'
39
+ Requires-Dist: pytest>=7.0.0; extra == 'test'
40
+ Description-Content-Type: text/markdown
41
+
42
+ # Hindsight API
43
+
44
+ **Memory System for AI Agents** — Temporal + Semantic + Entity Memory Architecture using PostgreSQL with pgvector.
45
+
46
+ Hindsight gives AI agents persistent memory that works like human memory: it stores facts, tracks entities and relationships, handles temporal reasoning ("what happened last spring?"), and forms opinions based on configurable disposition traits.
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install hindsight-api
52
+ ```
53
+
54
+ ## Quick Start
55
+
56
+ ### Run the Server
57
+
58
+ ```bash
59
+ # Set your LLM provider
60
+ export HINDSIGHT_API_LLM_PROVIDER=openai
61
+ export HINDSIGHT_API_LLM_API_KEY=sk-xxxxxxxxxxxx
62
+
63
+ # Start the server (uses embedded PostgreSQL by default)
64
+ hindsight-api
65
+ ```
66
+
67
+ The server starts at http://localhost:8888 with:
68
+ - REST API for memory operations
69
+ - MCP server at `/mcp` for tool-use integration
70
+
71
+ ### Use the Python API
72
+
73
+ ```python
74
+ from hindsight_api import MemoryEngine
75
+
76
+ # Create and initialize the memory engine
77
+ memory = MemoryEngine()
78
+ await memory.initialize()
79
+
80
+ # Create a memory bank for your agent
81
+ bank = await memory.create_memory_bank(
82
+ name="my-assistant",
83
+ background="A helpful coding assistant"
84
+ )
85
+
86
+ # Store a memory
87
+ await memory.retain(
88
+ memory_bank_id=bank.id,
89
+ content="The user prefers Python for data science projects"
90
+ )
91
+
92
+ # Recall memories
93
+ results = await memory.recall(
94
+ memory_bank_id=bank.id,
95
+ query="What programming language does the user prefer?"
96
+ )
97
+
98
+ # Reflect with reasoning
99
+ response = await memory.reflect(
100
+ memory_bank_id=bank.id,
101
+ query="Should I recommend Python or R for this ML project?"
102
+ )
103
+ ```
104
+
105
+ ## CLI Options
106
+
107
+ ```bash
108
+ hindsight-api --help
109
+
110
+ # Common options
111
+ hindsight-api --port 9000 # Custom port (default: 8888)
112
+ hindsight-api --host 127.0.0.1 # Bind to localhost only
113
+ hindsight-api --workers 4 # Multiple worker processes
114
+ hindsight-api --log-level debug # Verbose logging
115
+ ```
116
+
117
+ ## Configuration
118
+
119
+ Configure via environment variables:
120
+
121
+ | Variable | Description | Default |
122
+ |----------|-------------|---------|
123
+ | `HINDSIGHT_API_DATABASE_URL` | PostgreSQL connection string | `pg0` (embedded) |
124
+ | `HINDSIGHT_API_LLM_PROVIDER` | `openai`, `groq`, `gemini`, `ollama` | `openai` |
125
+ | `HINDSIGHT_API_LLM_API_KEY` | API key for LLM provider | - |
126
+ | `HINDSIGHT_API_LLM_MODEL` | Model name | `gpt-4o-mini` |
127
+ | `HINDSIGHT_API_HOST` | Server bind address | `0.0.0.0` |
128
+ | `HINDSIGHT_API_PORT` | Server port | `8888` |
129
+
130
+ ### Example with External PostgreSQL
131
+
132
+ ```bash
133
+ export HINDSIGHT_API_DATABASE_URL=postgresql://user:pass@localhost:5432/hindsight
134
+ export HINDSIGHT_API_LLM_PROVIDER=groq
135
+ export HINDSIGHT_API_LLM_API_KEY=gsk_xxxxxxxxxxxx
136
+
137
+ hindsight-api
138
+ ```
139
+
140
+ ## Docker
141
+
142
+ ```bash
143
+ docker run --rm -it -p 8888:8888 \
144
+ -e HINDSIGHT_API_LLM_API_KEY=$OPENAI_API_KEY \
145
+ -v $HOME/.hindsight-docker:/home/hindsight/.pg0 \
146
+ ghcr.io/vectorize-io/hindsight:latest
147
+ ```
148
+
149
+ ## MCP Server
150
+
151
+ For local MCP integration without running the full API server:
152
+
153
+ ```bash
154
+ hindsight-local-mcp
155
+ ```
156
+
157
+ This runs a stdio-based MCP server that can be used directly with MCP-compatible clients.
158
+
159
+ ## Key Features
160
+
161
+ - **Multi-Strategy Retrieval (TEMPR)** — Semantic, keyword, graph, and temporal search combined with RRF fusion
162
+ - **Entity Graph** — Automatic entity extraction and relationship tracking
163
+ - **Temporal Reasoning** — Native support for time-based queries
164
+ - **Disposition Traits** — Configurable skepticism, literalism, and empathy influence opinion formation
165
+ - **Three Memory Types** — World facts, bank actions, and formed opinions with confidence scores
166
+
167
+ ## Documentation
168
+
169
+ Full documentation: [https://hindsight.vectorize.io](https://hindsight.vectorize.io)
170
+
171
+ - [Installation Guide](https://hindsight.vectorize.io/developer/installation)
172
+ - [Configuration Reference](https://hindsight.vectorize.io/developer/configuration)
173
+ - [API Reference](https://hindsight.vectorize.io/api-reference)
174
+ - [Python SDK](https://hindsight.vectorize.io/sdks/python)
175
+
176
+ ## License
177
+
178
+ Apache 2.0
@@ -0,0 +1,137 @@
1
+ # Hindsight API
2
+
3
+ **Memory System for AI Agents** — Temporal + Semantic + Entity Memory Architecture using PostgreSQL with pgvector.
4
+
5
+ Hindsight gives AI agents persistent memory that works like human memory: it stores facts, tracks entities and relationships, handles temporal reasoning ("what happened last spring?"), and forms opinions based on configurable disposition traits.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install hindsight-api
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ### Run the Server
16
+
17
+ ```bash
18
+ # Set your LLM provider
19
+ export HINDSIGHT_API_LLM_PROVIDER=openai
20
+ export HINDSIGHT_API_LLM_API_KEY=sk-xxxxxxxxxxxx
21
+
22
+ # Start the server (uses embedded PostgreSQL by default)
23
+ hindsight-api
24
+ ```
25
+
26
+ The server starts at http://localhost:8888 with:
27
+ - REST API for memory operations
28
+ - MCP server at `/mcp` for tool-use integration
29
+
30
+ ### Use the Python API
31
+
32
+ ```python
33
+ from hindsight_api import MemoryEngine
34
+
35
+ # Create and initialize the memory engine
36
+ memory = MemoryEngine()
37
+ await memory.initialize()
38
+
39
+ # Create a memory bank for your agent
40
+ bank = await memory.create_memory_bank(
41
+ name="my-assistant",
42
+ background="A helpful coding assistant"
43
+ )
44
+
45
+ # Store a memory
46
+ await memory.retain(
47
+ memory_bank_id=bank.id,
48
+ content="The user prefers Python for data science projects"
49
+ )
50
+
51
+ # Recall memories
52
+ results = await memory.recall(
53
+ memory_bank_id=bank.id,
54
+ query="What programming language does the user prefer?"
55
+ )
56
+
57
+ # Reflect with reasoning
58
+ response = await memory.reflect(
59
+ memory_bank_id=bank.id,
60
+ query="Should I recommend Python or R for this ML project?"
61
+ )
62
+ ```
63
+
64
+ ## CLI Options
65
+
66
+ ```bash
67
+ hindsight-api --help
68
+
69
+ # Common options
70
+ hindsight-api --port 9000 # Custom port (default: 8888)
71
+ hindsight-api --host 127.0.0.1 # Bind to localhost only
72
+ hindsight-api --workers 4 # Multiple worker processes
73
+ hindsight-api --log-level debug # Verbose logging
74
+ ```
75
+
76
+ ## Configuration
77
+
78
+ Configure via environment variables:
79
+
80
+ | Variable | Description | Default |
81
+ |----------|-------------|---------|
82
+ | `HINDSIGHT_API_DATABASE_URL` | PostgreSQL connection string | `pg0` (embedded) |
83
+ | `HINDSIGHT_API_LLM_PROVIDER` | `openai`, `groq`, `gemini`, `ollama` | `openai` |
84
+ | `HINDSIGHT_API_LLM_API_KEY` | API key for LLM provider | - |
85
+ | `HINDSIGHT_API_LLM_MODEL` | Model name | `gpt-4o-mini` |
86
+ | `HINDSIGHT_API_HOST` | Server bind address | `0.0.0.0` |
87
+ | `HINDSIGHT_API_PORT` | Server port | `8888` |
88
+
89
+ ### Example with External PostgreSQL
90
+
91
+ ```bash
92
+ export HINDSIGHT_API_DATABASE_URL=postgresql://user:pass@localhost:5432/hindsight
93
+ export HINDSIGHT_API_LLM_PROVIDER=groq
94
+ export HINDSIGHT_API_LLM_API_KEY=gsk_xxxxxxxxxxxx
95
+
96
+ hindsight-api
97
+ ```
98
+
99
+ ## Docker
100
+
101
+ ```bash
102
+ docker run --rm -it -p 8888:8888 \
103
+ -e HINDSIGHT_API_LLM_API_KEY=$OPENAI_API_KEY \
104
+ -v $HOME/.hindsight-docker:/home/hindsight/.pg0 \
105
+ ghcr.io/vectorize-io/hindsight:latest
106
+ ```
107
+
108
+ ## MCP Server
109
+
110
+ For local MCP integration without running the full API server:
111
+
112
+ ```bash
113
+ hindsight-local-mcp
114
+ ```
115
+
116
+ This runs a stdio-based MCP server that can be used directly with MCP-compatible clients.
117
+
118
+ ## Key Features
119
+
120
+ - **Multi-Strategy Retrieval (TEMPR)** — Semantic, keyword, graph, and temporal search combined with RRF fusion
121
+ - **Entity Graph** — Automatic entity extraction and relationship tracking
122
+ - **Temporal Reasoning** — Native support for time-based queries
123
+ - **Disposition Traits** — Configurable skepticism, literalism, and empathy influence opinion formation
124
+ - **Three Memory Types** — World facts, bank actions, and formed opinions with confidence scores
125
+
126
+ ## Documentation
127
+
128
+ Full documentation: [https://hindsight.vectorize.io](https://hindsight.vectorize.io)
129
+
130
+ - [Installation Guide](https://hindsight.vectorize.io/developer/installation)
131
+ - [Configuration Reference](https://hindsight.vectorize.io/developer/configuration)
132
+ - [API Reference](https://hindsight.vectorize.io/api-reference)
133
+ - [Python SDK](https://hindsight.vectorize.io/sdks/python)
134
+
135
+ ## License
136
+
137
+ Apache 2.0
@@ -506,9 +506,9 @@ class BankListItem(BaseModel):
506
506
  """Bank list item with profile summary."""
507
507
 
508
508
  bank_id: str
509
- name: str
509
+ name: str | None = None
510
510
  disposition: DispositionTraits
511
- background: str
511
+ background: str | None = None
512
512
  created_at: str | None = None
513
513
  updated_at: str | None = None
514
514
 
@@ -1452,18 +1452,22 @@ def _register_routes(app: FastAPI):
1452
1452
  bank_id,
1453
1453
  )
1454
1454
 
1455
+ def parse_metadata(metadata):
1456
+ """Parse result_metadata which may be a string or dict."""
1457
+ if metadata is None:
1458
+ return {}
1459
+ if isinstance(metadata, str):
1460
+ return json.loads(metadata)
1461
+ return metadata
1462
+
1455
1463
  return {
1456
1464
  "bank_id": bank_id,
1457
1465
  "operations": [
1458
1466
  {
1459
1467
  "id": str(row["operation_id"]),
1460
1468
  "task_type": row["operation_type"],
1461
- "items_count": row["result_metadata"].get("items_count", 0)
1462
- if row["result_metadata"]
1463
- else 0,
1464
- "document_id": row["result_metadata"].get("document_id")
1465
- if row["result_metadata"]
1466
- else None,
1469
+ "items_count": parse_metadata(row["result_metadata"]).get("items_count", 0),
1470
+ "document_id": parse_metadata(row["result_metadata"]).get("document_id"),
1467
1471
  "created_at": row["created_at"].isoformat(),
1468
1472
  "status": row["status"],
1469
1473
  "error_message": row["error_message"],
@@ -1499,7 +1503,7 @@ def _register_routes(app: FastAPI):
1499
1503
  async with acquire_with_retry(pool) as conn:
1500
1504
  # Check if operation exists and belongs to this memory bank
1501
1505
  result = await conn.fetchrow(
1502
- "SELECT bank_id FROM async_operations WHERE id = $1 AND bank_id = $2", op_uuid, bank_id
1506
+ "SELECT bank_id FROM async_operations WHERE operation_id = $1 AND bank_id = $2", op_uuid, bank_id
1503
1507
  )
1504
1508
 
1505
1509
  if not result:
@@ -1508,7 +1512,7 @@ def _register_routes(app: FastAPI):
1508
1512
  )
1509
1513
 
1510
1514
  # Delete the operation
1511
- await conn.execute("DELETE FROM async_operations WHERE id = $1", op_uuid)
1515
+ await conn.execute("DELETE FROM async_operations WHERE operation_id = $1", op_uuid)
1512
1516
 
1513
1517
  return {
1514
1518
  "success": True,
@@ -1769,13 +1773,13 @@ def _register_routes(app: FastAPI):
1769
1773
  async with acquire_with_retry(pool) as conn:
1770
1774
  await conn.execute(
1771
1775
  """
1772
- INSERT INTO async_operations (id, bank_id, task_type, items_count)
1776
+ INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata)
1773
1777
  VALUES ($1, $2, $3, $4)
1774
1778
  """,
1775
1779
  operation_id,
1776
1780
  bank_id,
1777
1781
  "retain",
1778
- len(contents),
1782
+ json.dumps({"items_count": len(contents)}),
1779
1783
  )
1780
1784
 
1781
1785
  # Submit task to background queue
@@ -311,7 +311,7 @@ class MemoryEngine:
311
311
  pool = await self._get_pool()
312
312
  async with acquire_with_retry(pool) as conn:
313
313
  result = await conn.fetchrow(
314
- "SELECT id FROM async_operations WHERE id = $1", uuid.UUID(operation_id)
314
+ "SELECT operation_id FROM async_operations WHERE operation_id = $1", uuid.UUID(operation_id)
315
315
  )
316
316
  if not result:
317
317
  # Operation was cancelled, skip processing
@@ -369,7 +369,7 @@ class MemoryEngine:
369
369
  try:
370
370
  pool = await self._get_pool()
371
371
  async with acquire_with_retry(pool) as conn:
372
- await conn.execute("DELETE FROM async_operations WHERE id = $1", uuid.UUID(operation_id))
372
+ await conn.execute("DELETE FROM async_operations WHERE operation_id = $1", uuid.UUID(operation_id))
373
373
  except Exception as e:
374
374
  logger.error(f"Failed to delete async operation record {operation_id}: {e}")
375
375
 
@@ -386,7 +386,7 @@ class MemoryEngine:
386
386
  """
387
387
  UPDATE async_operations
388
388
  SET status = 'failed', error_message = $2
389
- WHERE id = $1
389
+ WHERE operation_id = $1
390
390
  """,
391
391
  uuid.UUID(operation_id),
392
392
  truncated_error,
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "hindsight-api"
7
- version = "0.1.6"
8
- description = "Temporal + Semantic + Entity Memory System for AI agents using PostgreSQL"
7
+ version = "0.1.8"
8
+ description = "Hindsight: Agent Memory That Works Like Human Memory"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
11
11
  dependencies = [
@@ -25,7 +25,7 @@ dependencies = [
25
25
  "greenlet>=3.2.4",
26
26
  "psycopg2-binary>=2.9.11",
27
27
  "transformers>=4.30.0,<4.46.0",
28
- "torch>=2.0.0,<2.6.0",
28
+ "torch>=2.0.0",
29
29
  "tiktoken>=0.12.0",
30
30
  "httpx>=0.27.0",
31
31
  "fastmcp>=2.3.0",
@@ -1,42 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: hindsight-api
3
- Version: 0.1.6
4
- Summary: Temporal + Semantic + Entity Memory System for AI agents using PostgreSQL
5
- Requires-Python: >=3.11
6
- Requires-Dist: alembic>=1.17.1
7
- Requires-Dist: asyncpg>=0.29.0
8
- Requires-Dist: dateparser>=1.2.2
9
- Requires-Dist: fastapi[standard]>=0.120.3
10
- Requires-Dist: fastmcp>=2.3.0
11
- Requires-Dist: google-genai>=1.0.0
12
- Requires-Dist: greenlet>=3.2.4
13
- Requires-Dist: httpx>=0.27.0
14
- Requires-Dist: langchain-text-splitters>=0.3.0
15
- Requires-Dist: openai>=1.0.0
16
- Requires-Dist: opentelemetry-api>=1.20.0
17
- Requires-Dist: opentelemetry-exporter-prometheus>=0.41b0
18
- Requires-Dist: opentelemetry-instrumentation-fastapi>=0.41b0
19
- Requires-Dist: opentelemetry-sdk>=1.20.0
20
- Requires-Dist: pg0-embedded>=0.11.0
21
- Requires-Dist: pgvector>=0.4.1
22
- Requires-Dist: psycopg2-binary>=2.9.11
23
- Requires-Dist: pydantic>=2.0.0
24
- Requires-Dist: python-dateutil>=2.8.0
25
- Requires-Dist: python-dotenv>=1.0.0
26
- Requires-Dist: rich>=13.0.0
27
- Requires-Dist: sentence-transformers<3.3.0,>=3.0.0
28
- Requires-Dist: sqlalchemy>=2.0.44
29
- Requires-Dist: tiktoken>=0.12.0
30
- Requires-Dist: torch<2.6.0,>=2.0.0
31
- Requires-Dist: transformers<4.46.0,>=4.30.0
32
- Requires-Dist: uvicorn>=0.38.0
33
- Requires-Dist: wsproto>=1.0.0
34
- Provides-Extra: test
35
- Requires-Dist: filelock>=3.0.0; extra == 'test'
36
- Requires-Dist: pytest-asyncio>=0.21.0; extra == 'test'
37
- Requires-Dist: pytest-timeout>=2.4.0; extra == 'test'
38
- Requires-Dist: pytest-xdist>=3.0.0; extra == 'test'
39
- Requires-Dist: pytest>=7.0.0; extra == 'test'
40
- Description-Content-Type: text/markdown
41
-
42
- # Memory
@@ -1 +0,0 @@
1
- # Memory
File without changes