hindsight-api 0.0.21__tar.gz → 0.1.1__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 (88) hide show
  1. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/PKG-INFO +2 -3
  2. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/__init__.py +10 -2
  3. hindsight_api-0.1.1/hindsight_api/alembic/versions/e0a1b2c3d4e5_disposition_to_3_traits.py +62 -0
  4. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/api/__init__.py +2 -4
  5. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/api/http.py +112 -164
  6. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/api/mcp.py +2 -1
  7. hindsight_api-0.1.1/hindsight_api/config.py +154 -0
  8. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/__init__.py +7 -2
  9. hindsight_api-0.1.1/hindsight_api/engine/cross_encoder.py +306 -0
  10. hindsight_api-0.1.1/hindsight_api/engine/embeddings.py +292 -0
  11. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/entity_resolver.py +56 -29
  12. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/llm_wrapper.py +147 -106
  13. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/memory_engine.py +337 -192
  14. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/response_models.py +15 -17
  15. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/bank_utils.py +25 -35
  16. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/entity_processing.py +5 -5
  17. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/fact_extraction.py +86 -24
  18. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/fact_storage.py +1 -1
  19. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/link_creation.py +12 -6
  20. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/link_utils.py +50 -56
  21. hindsight_api-0.1.1/hindsight_api/engine/retain/observation_regeneration.py +264 -0
  22. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/orchestrator.py +31 -44
  23. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/types.py +14 -0
  24. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/reranking.py +6 -10
  25. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/retrieval.py +2 -2
  26. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/think_utils.py +59 -30
  27. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/tracer.py +1 -1
  28. hindsight_api-0.1.1/hindsight_api/main.py +201 -0
  29. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/migrations.py +61 -39
  30. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/models.py +1 -2
  31. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/pg0.py +17 -36
  32. hindsight_api-0.1.1/hindsight_api/server.py +43 -0
  33. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/pyproject.toml +20 -8
  34. hindsight_api-0.0.21/hindsight_api/cli.py +0 -128
  35. hindsight_api-0.0.21/hindsight_api/engine/cross_encoder.py +0 -97
  36. hindsight_api-0.0.21/hindsight_api/engine/embeddings.py +0 -113
  37. hindsight_api-0.0.21/hindsight_api/web/__init__.py +0 -12
  38. hindsight_api-0.0.21/hindsight_api/web/server.py +0 -109
  39. hindsight_api-0.0.21/test_chunks_debug.py +0 -46
  40. hindsight_api-0.0.21/test_mentioned_at.py +0 -69
  41. hindsight_api-0.0.21/tests/RETAIN_TEST_COVERAGE_PLAN.md +0 -302
  42. hindsight_api-0.0.21/tests/__init__.py +0 -1
  43. hindsight_api-0.0.21/tests/conftest.py +0 -130
  44. hindsight_api-0.0.21/tests/fixtures/README.md +0 -19
  45. hindsight_api-0.0.21/tests/fixtures/locomo_conversation_sample.json +0 -5271
  46. hindsight_api-0.0.21/tests/test_agents_api.py +0 -260
  47. hindsight_api-0.0.21/tests/test_batch_chunking.py +0 -58
  48. hindsight_api-0.0.21/tests/test_chunking.py +0 -60
  49. hindsight_api-0.0.21/tests/test_document_tracking.py +0 -131
  50. hindsight_api-0.0.21/tests/test_fact_extraction_quality.py +0 -1168
  51. hindsight_api-0.0.21/tests/test_fact_ordering.py +0 -183
  52. hindsight_api-0.0.21/tests/test_http_api_integration.py +0 -460
  53. hindsight_api-0.0.21/tests/test_link_utils.py +0 -256
  54. hindsight_api-0.0.21/tests/test_mcp_api_integration.py +0 -178
  55. hindsight_api-0.0.21/tests/test_mcp_routing.py +0 -98
  56. hindsight_api-0.0.21/tests/test_observations.py +0 -339
  57. hindsight_api-0.0.21/tests/test_query_analyzer.py +0 -285
  58. hindsight_api-0.0.21/tests/test_retain.py +0 -1597
  59. hindsight_api-0.0.21/tests/test_search_trace.py +0 -140
  60. hindsight_api-0.0.21/tests/test_temporal_ranges.py +0 -146
  61. hindsight_api-0.0.21/tests/test_think.py +0 -150
  62. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/.gitignore +0 -0
  63. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/README.md +0 -0
  64. {hindsight_api-0.0.21 → hindsight_api-0.1.1/hindsight_api}/alembic/README +0 -0
  65. {hindsight_api-0.0.21 → hindsight_api-0.1.1/hindsight_api}/alembic/env.py +0 -0
  66. {hindsight_api-0.0.21 → hindsight_api-0.1.1/hindsight_api}/alembic/script.py.mako +0 -0
  67. {hindsight_api-0.0.21 → hindsight_api-0.1.1/hindsight_api}/alembic/versions/5a366d414dce_initial_schema.py +0 -0
  68. {hindsight_api-0.0.21 → hindsight_api-0.1.1/hindsight_api}/alembic/versions/b7c4d8e9f1a2_add_chunks_table.py +0 -0
  69. {hindsight_api-0.0.21 → hindsight_api-0.1.1/hindsight_api}/alembic/versions/c8e5f2a3b4d1_add_retain_params_to_documents.py +0 -0
  70. {hindsight_api-0.0.21 → hindsight_api-0.1.1/hindsight_api}/alembic/versions/d9f6a3b4c5e2_rename_bank_to_interactions.py +0 -0
  71. {hindsight_api-0.0.21 → hindsight_api-0.1.1/hindsight_api}/alembic/versions/rename_personality_to_disposition.py +0 -0
  72. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/db_utils.py +0 -0
  73. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/query_analyzer.py +0 -0
  74. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/__init__.py +0 -0
  75. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/chunk_storage.py +0 -0
  76. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/deduplication.py +0 -0
  77. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/embedding_processing.py +0 -0
  78. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/retain/embedding_utils.py +0 -0
  79. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/__init__.py +0 -0
  80. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/fusion.py +0 -0
  81. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/observation_utils.py +0 -0
  82. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/scoring.py +0 -0
  83. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/temporal_extraction.py +0 -0
  84. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/trace.py +0 -0
  85. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/search/types.py +0 -0
  86. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/task_backend.py +0 -0
  87. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/engine/utils.py +0 -0
  88. {hindsight_api-0.0.21 → hindsight_api-0.1.1}/hindsight_api/metrics.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hindsight-api
3
- Version: 0.0.21
3
+ Version: 0.1.1
4
4
  Summary: Temporal + Semantic + Entity Memory System for AI agents using PostgreSQL
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: alembic>=1.17.1
@@ -23,7 +23,7 @@ Requires-Dist: pydantic>=2.0.0
23
23
  Requires-Dist: python-dateutil>=2.8.0
24
24
  Requires-Dist: python-dotenv>=1.0.0
25
25
  Requires-Dist: rich>=13.0.0
26
- Requires-Dist: sentence-transformers>=2.2.0
26
+ Requires-Dist: sentence-transformers>=3.0.0
27
27
  Requires-Dist: sqlalchemy>=2.0.44
28
28
  Requires-Dist: tiktoken>=0.12.0
29
29
  Requires-Dist: torch>=2.0.0
@@ -36,7 +36,6 @@ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'test'
36
36
  Requires-Dist: pytest-timeout>=2.4.0; extra == 'test'
37
37
  Requires-Dist: pytest-xdist>=3.0.0; extra == 'test'
38
38
  Requires-Dist: pytest>=7.0.0; extra == 'test'
39
- Requires-Dist: testcontainers[postgres]>=4.0.0; extra == 'test'
40
39
  Description-Content-Type: text/markdown
41
40
 
42
41
  # Memory
@@ -16,11 +16,15 @@ from .engine.search.trace import (
16
16
  SearchPhaseMetrics,
17
17
  )
18
18
  from .engine.search.tracer import SearchTracer
19
- from .engine.embeddings import Embeddings, SentenceTransformersEmbeddings
19
+ from .engine.embeddings import Embeddings, LocalSTEmbeddings, RemoteTEIEmbeddings
20
+ from .engine.cross_encoder import CrossEncoderModel, LocalSTCrossEncoder, RemoteTEICrossEncoder
20
21
  from .engine.llm_wrapper import LLMConfig
22
+ from .config import HindsightConfig, get_config
21
23
 
22
24
  __all__ = [
23
25
  "MemoryEngine",
26
+ "HindsightConfig",
27
+ "get_config",
24
28
  "SearchTrace",
25
29
  "SearchTracer",
26
30
  "QueryInfo",
@@ -32,7 +36,11 @@ __all__ = [
32
36
  "SearchSummary",
33
37
  "SearchPhaseMetrics",
34
38
  "Embeddings",
35
- "SentenceTransformersEmbeddings",
39
+ "LocalSTEmbeddings",
40
+ "RemoteTEIEmbeddings",
41
+ "CrossEncoderModel",
42
+ "LocalSTCrossEncoder",
43
+ "RemoteTEICrossEncoder",
36
44
  "LLMConfig",
37
45
  ]
38
46
  __version__ = "0.1.0"
@@ -0,0 +1,62 @@
1
+ """disposition_to_3_traits
2
+
3
+ Revision ID: e0a1b2c3d4e5
4
+ Revises: rename_personality
5
+ Create Date: 2024-12-08
6
+
7
+ Migrate disposition traits from Big Five (openness, conscientiousness, extraversion,
8
+ agreeableness, neuroticism, bias_strength with 0-1 float values) to the new 3-trait
9
+ system (skepticism, literalism, empathy with 1-5 integer values).
10
+ """
11
+ from typing import Sequence, Union
12
+
13
+ from alembic import op
14
+ import sqlalchemy as sa
15
+
16
+
17
+ # revision identifiers, used by Alembic.
18
+ revision: str = 'e0a1b2c3d4e5'
19
+ down_revision: Union[str, Sequence[str], None] = 'rename_personality'
20
+ branch_labels: Union[str, Sequence[str], None] = None
21
+ depends_on: Union[str, Sequence[str], None] = None
22
+
23
+
24
+ def upgrade() -> None:
25
+ """Convert Big Five disposition to 3-trait disposition."""
26
+ conn = op.get_bind()
27
+
28
+ # Update all existing banks to use the new disposition format
29
+ # Convert from old format to new format with reasonable mappings:
30
+ # - skepticism: derived from inverse of agreeableness (skeptical people are less agreeable)
31
+ # - literalism: derived from conscientiousness (detail-oriented people are more literal)
32
+ # - empathy: derived from agreeableness + inverse of neuroticism
33
+ # Default all to 3 (neutral) for simplicity
34
+ conn.execute(sa.text("""
35
+ UPDATE banks
36
+ SET disposition = '{"skepticism": 3, "literalism": 3, "empathy": 3}'::jsonb
37
+ WHERE disposition IS NOT NULL
38
+ """))
39
+
40
+ # Update the default for new banks
41
+ conn.execute(sa.text("""
42
+ ALTER TABLE banks
43
+ ALTER COLUMN disposition SET DEFAULT '{"skepticism": 3, "literalism": 3, "empathy": 3}'::jsonb
44
+ """))
45
+
46
+
47
+ def downgrade() -> None:
48
+ """Convert back to Big Five disposition."""
49
+ conn = op.get_bind()
50
+
51
+ # Revert to Big Five format with default values
52
+ conn.execute(sa.text("""
53
+ UPDATE banks
54
+ SET disposition = '{"openness": 0.5, "conscientiousness": 0.5, "extraversion": 0.5, "agreeableness": 0.5, "neuroticism": 0.5, "bias_strength": 0.5}'::jsonb
55
+ WHERE disposition IS NOT NULL
56
+ """))
57
+
58
+ # Update the default for new banks
59
+ conn.execute(sa.text("""
60
+ ALTER TABLE banks
61
+ ALTER COLUMN disposition SET DEFAULT '{"openness": 0.5, "conscientiousness": 0.5, "extraversion": 0.5, "agreeableness": 0.5, "neuroticism": 0.5, "bias_strength": 0.5}'::jsonb
62
+ """))
@@ -17,18 +17,17 @@ def create_app(
17
17
  http_api_enabled: bool = True,
18
18
  mcp_api_enabled: bool = False,
19
19
  mcp_mount_path: str = "/mcp",
20
- run_migrations: bool = True,
21
20
  initialize_memory: bool = True
22
21
  ) -> FastAPI:
23
22
  """
24
23
  Create and configure the unified Hindsight API application.
25
24
 
26
25
  Args:
27
- memory: MemoryEngine instance (already initialized with required parameters)
26
+ memory: MemoryEngine instance (already initialized with required parameters).
27
+ Migrations are controlled by the MemoryEngine's run_migrations parameter.
28
28
  http_api_enabled: Whether to enable HTTP REST API endpoints (default: True)
29
29
  mcp_api_enabled: Whether to enable MCP server (default: False)
30
30
  mcp_mount_path: Path to mount MCP server (default: /mcp)
31
- run_migrations: Whether to run database migrations on startup (default: True)
32
31
  initialize_memory: Whether to initialize memory system on startup (default: True)
33
32
 
34
33
  Returns:
@@ -50,7 +49,6 @@ def create_app(
50
49
  from .http import create_app as create_http_app
51
50
  app = create_http_app(
52
51
  memory=memory,
53
- run_migrations=run_migrations,
54
52
  initialize_memory=initialize_memory
55
53
  )
56
54
  logger.info("HTTP REST API enabled")