remdb 0.3.242__py3-none-any.whl
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.
Potentially problematic release.
This version of remdb might be problematic. Click here for more details.
- rem/__init__.py +129 -0
- rem/agentic/README.md +760 -0
- rem/agentic/__init__.py +54 -0
- rem/agentic/agents/README.md +155 -0
- rem/agentic/agents/__init__.py +38 -0
- rem/agentic/agents/agent_manager.py +311 -0
- rem/agentic/agents/sse_simulator.py +502 -0
- rem/agentic/context.py +425 -0
- rem/agentic/context_builder.py +360 -0
- rem/agentic/llm_provider_models.py +301 -0
- rem/agentic/mcp/__init__.py +0 -0
- rem/agentic/mcp/tool_wrapper.py +273 -0
- rem/agentic/otel/__init__.py +5 -0
- rem/agentic/otel/setup.py +240 -0
- rem/agentic/providers/phoenix.py +926 -0
- rem/agentic/providers/pydantic_ai.py +854 -0
- rem/agentic/query.py +117 -0
- rem/agentic/query_helper.py +89 -0
- rem/agentic/schema.py +737 -0
- rem/agentic/serialization.py +245 -0
- rem/agentic/tools/__init__.py +5 -0
- rem/agentic/tools/rem_tools.py +242 -0
- rem/api/README.md +657 -0
- rem/api/deps.py +253 -0
- rem/api/main.py +460 -0
- rem/api/mcp_router/prompts.py +182 -0
- rem/api/mcp_router/resources.py +820 -0
- rem/api/mcp_router/server.py +243 -0
- rem/api/mcp_router/tools.py +1605 -0
- rem/api/middleware/tracking.py +172 -0
- rem/api/routers/admin.py +520 -0
- rem/api/routers/auth.py +898 -0
- rem/api/routers/chat/__init__.py +5 -0
- rem/api/routers/chat/child_streaming.py +394 -0
- rem/api/routers/chat/completions.py +702 -0
- rem/api/routers/chat/json_utils.py +76 -0
- rem/api/routers/chat/models.py +202 -0
- rem/api/routers/chat/otel_utils.py +33 -0
- rem/api/routers/chat/sse_events.py +546 -0
- rem/api/routers/chat/streaming.py +950 -0
- rem/api/routers/chat/streaming_utils.py +327 -0
- rem/api/routers/common.py +18 -0
- rem/api/routers/dev.py +87 -0
- rem/api/routers/feedback.py +276 -0
- rem/api/routers/messages.py +620 -0
- rem/api/routers/models.py +86 -0
- rem/api/routers/query.py +362 -0
- rem/api/routers/shared_sessions.py +422 -0
- rem/auth/README.md +258 -0
- rem/auth/__init__.py +36 -0
- rem/auth/jwt.py +367 -0
- rem/auth/middleware.py +318 -0
- rem/auth/providers/__init__.py +16 -0
- rem/auth/providers/base.py +376 -0
- rem/auth/providers/email.py +215 -0
- rem/auth/providers/google.py +163 -0
- rem/auth/providers/microsoft.py +237 -0
- rem/cli/README.md +517 -0
- rem/cli/__init__.py +8 -0
- rem/cli/commands/README.md +299 -0
- rem/cli/commands/__init__.py +3 -0
- rem/cli/commands/ask.py +549 -0
- rem/cli/commands/cluster.py +1808 -0
- rem/cli/commands/configure.py +495 -0
- rem/cli/commands/db.py +828 -0
- rem/cli/commands/dreaming.py +324 -0
- rem/cli/commands/experiments.py +1698 -0
- rem/cli/commands/mcp.py +66 -0
- rem/cli/commands/process.py +388 -0
- rem/cli/commands/query.py +109 -0
- rem/cli/commands/scaffold.py +47 -0
- rem/cli/commands/schema.py +230 -0
- rem/cli/commands/serve.py +106 -0
- rem/cli/commands/session.py +453 -0
- rem/cli/dreaming.py +363 -0
- rem/cli/main.py +123 -0
- rem/config.py +244 -0
- rem/mcp_server.py +41 -0
- rem/models/core/__init__.py +49 -0
- rem/models/core/core_model.py +70 -0
- rem/models/core/engram.py +333 -0
- rem/models/core/experiment.py +672 -0
- rem/models/core/inline_edge.py +132 -0
- rem/models/core/rem_query.py +246 -0
- rem/models/entities/__init__.py +68 -0
- rem/models/entities/domain_resource.py +38 -0
- rem/models/entities/feedback.py +123 -0
- rem/models/entities/file.py +57 -0
- rem/models/entities/image_resource.py +88 -0
- rem/models/entities/message.py +64 -0
- rem/models/entities/moment.py +123 -0
- rem/models/entities/ontology.py +181 -0
- rem/models/entities/ontology_config.py +131 -0
- rem/models/entities/resource.py +95 -0
- rem/models/entities/schema.py +87 -0
- rem/models/entities/session.py +84 -0
- rem/models/entities/shared_session.py +180 -0
- rem/models/entities/subscriber.py +175 -0
- rem/models/entities/user.py +93 -0
- rem/py.typed +0 -0
- rem/registry.py +373 -0
- rem/schemas/README.md +507 -0
- rem/schemas/__init__.py +6 -0
- rem/schemas/agents/README.md +92 -0
- rem/schemas/agents/core/agent-builder.yaml +235 -0
- rem/schemas/agents/core/moment-builder.yaml +178 -0
- rem/schemas/agents/core/rem-query-agent.yaml +226 -0
- rem/schemas/agents/core/resource-affinity-assessor.yaml +99 -0
- rem/schemas/agents/core/simple-assistant.yaml +19 -0
- rem/schemas/agents/core/user-profile-builder.yaml +163 -0
- rem/schemas/agents/examples/contract-analyzer.yaml +317 -0
- rem/schemas/agents/examples/contract-extractor.yaml +134 -0
- rem/schemas/agents/examples/cv-parser.yaml +263 -0
- rem/schemas/agents/examples/hello-world.yaml +37 -0
- rem/schemas/agents/examples/query.yaml +54 -0
- rem/schemas/agents/examples/simple.yaml +21 -0
- rem/schemas/agents/examples/test.yaml +29 -0
- rem/schemas/agents/rem.yaml +132 -0
- rem/schemas/evaluators/hello-world/default.yaml +77 -0
- rem/schemas/evaluators/rem/faithfulness.yaml +219 -0
- rem/schemas/evaluators/rem/lookup-correctness.yaml +182 -0
- rem/schemas/evaluators/rem/retrieval-precision.yaml +199 -0
- rem/schemas/evaluators/rem/retrieval-recall.yaml +211 -0
- rem/schemas/evaluators/rem/search-correctness.yaml +192 -0
- rem/services/__init__.py +18 -0
- rem/services/audio/INTEGRATION.md +308 -0
- rem/services/audio/README.md +376 -0
- rem/services/audio/__init__.py +15 -0
- rem/services/audio/chunker.py +354 -0
- rem/services/audio/transcriber.py +259 -0
- rem/services/content/README.md +1269 -0
- rem/services/content/__init__.py +5 -0
- rem/services/content/providers.py +760 -0
- rem/services/content/service.py +762 -0
- rem/services/dreaming/README.md +230 -0
- rem/services/dreaming/__init__.py +53 -0
- rem/services/dreaming/affinity_service.py +322 -0
- rem/services/dreaming/moment_service.py +251 -0
- rem/services/dreaming/ontology_service.py +54 -0
- rem/services/dreaming/user_model_service.py +297 -0
- rem/services/dreaming/utils.py +39 -0
- rem/services/email/__init__.py +10 -0
- rem/services/email/service.py +522 -0
- rem/services/email/templates.py +360 -0
- rem/services/embeddings/__init__.py +11 -0
- rem/services/embeddings/api.py +127 -0
- rem/services/embeddings/worker.py +435 -0
- rem/services/fs/README.md +662 -0
- rem/services/fs/__init__.py +62 -0
- rem/services/fs/examples.py +206 -0
- rem/services/fs/examples_paths.py +204 -0
- rem/services/fs/git_provider.py +935 -0
- rem/services/fs/local_provider.py +760 -0
- rem/services/fs/parsing-hooks-examples.md +172 -0
- rem/services/fs/paths.py +276 -0
- rem/services/fs/provider.py +460 -0
- rem/services/fs/s3_provider.py +1042 -0
- rem/services/fs/service.py +186 -0
- rem/services/git/README.md +1075 -0
- rem/services/git/__init__.py +17 -0
- rem/services/git/service.py +469 -0
- rem/services/phoenix/EXPERIMENT_DESIGN.md +1146 -0
- rem/services/phoenix/README.md +453 -0
- rem/services/phoenix/__init__.py +46 -0
- rem/services/phoenix/client.py +960 -0
- rem/services/phoenix/config.py +88 -0
- rem/services/phoenix/prompt_labels.py +477 -0
- rem/services/postgres/README.md +757 -0
- rem/services/postgres/__init__.py +49 -0
- rem/services/postgres/diff_service.py +599 -0
- rem/services/postgres/migration_service.py +427 -0
- rem/services/postgres/programmable_diff_service.py +635 -0
- rem/services/postgres/pydantic_to_sqlalchemy.py +562 -0
- rem/services/postgres/register_type.py +353 -0
- rem/services/postgres/repository.py +481 -0
- rem/services/postgres/schema_generator.py +661 -0
- rem/services/postgres/service.py +802 -0
- rem/services/postgres/sql_builder.py +355 -0
- rem/services/rate_limit.py +113 -0
- rem/services/rem/README.md +318 -0
- rem/services/rem/__init__.py +23 -0
- rem/services/rem/exceptions.py +71 -0
- rem/services/rem/executor.py +293 -0
- rem/services/rem/parser.py +180 -0
- rem/services/rem/queries.py +196 -0
- rem/services/rem/query.py +371 -0
- rem/services/rem/service.py +608 -0
- rem/services/session/README.md +374 -0
- rem/services/session/__init__.py +13 -0
- rem/services/session/compression.py +488 -0
- rem/services/session/pydantic_messages.py +310 -0
- rem/services/session/reload.py +85 -0
- rem/services/user_service.py +130 -0
- rem/settings.py +1877 -0
- rem/sql/background_indexes.sql +52 -0
- rem/sql/migrations/001_install.sql +983 -0
- rem/sql/migrations/002_install_models.sql +3157 -0
- rem/sql/migrations/003_optional_extensions.sql +326 -0
- rem/sql/migrations/004_cache_system.sql +282 -0
- rem/sql/migrations/005_schema_update.sql +145 -0
- rem/sql/migrations/migrate_session_id_to_uuid.sql +45 -0
- rem/utils/AGENTIC_CHUNKING.md +597 -0
- rem/utils/README.md +628 -0
- rem/utils/__init__.py +61 -0
- rem/utils/agentic_chunking.py +622 -0
- rem/utils/batch_ops.py +343 -0
- rem/utils/chunking.py +108 -0
- rem/utils/clip_embeddings.py +276 -0
- rem/utils/constants.py +97 -0
- rem/utils/date_utils.py +228 -0
- rem/utils/dict_utils.py +98 -0
- rem/utils/embeddings.py +436 -0
- rem/utils/examples/embeddings_example.py +305 -0
- rem/utils/examples/sql_types_example.py +202 -0
- rem/utils/files.py +323 -0
- rem/utils/markdown.py +16 -0
- rem/utils/mime_types.py +158 -0
- rem/utils/model_helpers.py +492 -0
- rem/utils/schema_loader.py +649 -0
- rem/utils/sql_paths.py +146 -0
- rem/utils/sql_types.py +350 -0
- rem/utils/user_id.py +81 -0
- rem/utils/vision.py +325 -0
- rem/workers/README.md +506 -0
- rem/workers/__init__.py +7 -0
- rem/workers/db_listener.py +579 -0
- rem/workers/db_maintainer.py +74 -0
- rem/workers/dreaming.py +502 -0
- rem/workers/engram_processor.py +312 -0
- rem/workers/sqs_file_processor.py +193 -0
- rem/workers/unlogged_maintainer.py +463 -0
- remdb-0.3.242.dist-info/METADATA +1632 -0
- remdb-0.3.242.dist-info/RECORD +235 -0
- remdb-0.3.242.dist-info/WHEEL +4 -0
- remdb-0.3.242.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
-- Migration: schema_update
|
|
2
|
+
-- Generated by: rem db diff --generate
|
|
3
|
+
-- Changes detected: 139
|
|
4
|
+
--
|
|
5
|
+
-- Review this file before applying!
|
|
6
|
+
-- Apply with: rem db migrate
|
|
7
|
+
--
|
|
8
|
+
|
|
9
|
+
CREATE TABLE IF NOT EXISTS patient_profiles (
|
|
10
|
+
id UUID NOT NULL,
|
|
11
|
+
tenant_id VARCHAR(100) NOT NULL,
|
|
12
|
+
user_id VARCHAR(256),
|
|
13
|
+
patient_ref VARCHAR(256) NOT NULL,
|
|
14
|
+
clinician_ref VARCHAR(256),
|
|
15
|
+
evaluation_type TEXT,
|
|
16
|
+
evaluation_date DATE,
|
|
17
|
+
session_ref VARCHAR(256),
|
|
18
|
+
risk_level TEXT,
|
|
19
|
+
suicidality TEXT,
|
|
20
|
+
suicidality_details VARCHAR(256),
|
|
21
|
+
homicidal_ideation BOOLEAN,
|
|
22
|
+
homicidal_details VARCHAR(256),
|
|
23
|
+
self_harm_current BOOLEAN,
|
|
24
|
+
self_harm_history BOOLEAN,
|
|
25
|
+
suicide_attempts_lifetime INTEGER,
|
|
26
|
+
suicide_attempt_most_recent VARCHAR(256),
|
|
27
|
+
safety_plan_in_place BOOLEAN,
|
|
28
|
+
safety_plan_date DATE,
|
|
29
|
+
appearance VARCHAR(256),
|
|
30
|
+
behavior VARCHAR(256),
|
|
31
|
+
speech VARCHAR(256),
|
|
32
|
+
mood_states JSONB,
|
|
33
|
+
mood_description TEXT,
|
|
34
|
+
affect_quality TEXT,
|
|
35
|
+
affect_congruent BOOLEAN,
|
|
36
|
+
thought_process TEXT,
|
|
37
|
+
delusions_present BOOLEAN,
|
|
38
|
+
delusion_types TEXT[],
|
|
39
|
+
hallucinations_present BOOLEAN,
|
|
40
|
+
hallucination_types TEXT[],
|
|
41
|
+
command_hallucinations BOOLEAN,
|
|
42
|
+
oriented BOOLEAN,
|
|
43
|
+
orientation_deficits TEXT[],
|
|
44
|
+
memory_intact BOOLEAN,
|
|
45
|
+
attention_intact BOOLEAN,
|
|
46
|
+
insight TEXT,
|
|
47
|
+
judgment TEXT,
|
|
48
|
+
symptoms JSONB,
|
|
49
|
+
chief_complaint VARCHAR(256),
|
|
50
|
+
symptom_duration VARCHAR(256),
|
|
51
|
+
symptom_trajectory VARCHAR(256),
|
|
52
|
+
precipitating_factors TEXT[],
|
|
53
|
+
substance_use_profiles JSONB,
|
|
54
|
+
substance_use_summary TEXT,
|
|
55
|
+
in_recovery BOOLEAN,
|
|
56
|
+
recovery_duration VARCHAR(256),
|
|
57
|
+
mat_current BOOLEAN,
|
|
58
|
+
diagnoses_current TEXT[],
|
|
59
|
+
diagnoses_historical TEXT[],
|
|
60
|
+
first_psychiatric_contact_age INTEGER,
|
|
61
|
+
hospitalizations_psychiatric INTEGER,
|
|
62
|
+
last_hospitalization VARCHAR(256),
|
|
63
|
+
ect_history BOOLEAN,
|
|
64
|
+
therapy_history VARCHAR(256),
|
|
65
|
+
family_psychiatric_history VARCHAR(256),
|
|
66
|
+
current_medications JSONB,
|
|
67
|
+
other_medications TEXT[],
|
|
68
|
+
allergies TEXT[],
|
|
69
|
+
current_therapist BOOLEAN,
|
|
70
|
+
therapy_type VARCHAR(256),
|
|
71
|
+
therapy_frequency VARCHAR(256),
|
|
72
|
+
other_providers TEXT[],
|
|
73
|
+
functioning JSONB,
|
|
74
|
+
social_determinants JSONB,
|
|
75
|
+
cgi_severity TEXT,
|
|
76
|
+
cgi_improvement TEXT,
|
|
77
|
+
gaf_equivalent INTEGER,
|
|
78
|
+
clinical_impression VARCHAR(256),
|
|
79
|
+
differential_diagnoses TEXT[],
|
|
80
|
+
treatment_plan VARCHAR(256),
|
|
81
|
+
treatment_goals TEXT[],
|
|
82
|
+
barriers_to_treatment TEXT[],
|
|
83
|
+
strengths TEXT[],
|
|
84
|
+
follow_up_recommended BOOLEAN,
|
|
85
|
+
follow_up_urgency VARCHAR(256),
|
|
86
|
+
follow_up_interval VARCHAR(256),
|
|
87
|
+
referrals TEXT[],
|
|
88
|
+
labs_ordered TEXT[],
|
|
89
|
+
data_source VARCHAR(256),
|
|
90
|
+
confidence_score FLOAT,
|
|
91
|
+
reviewed_by_clinician BOOLEAN,
|
|
92
|
+
notes VARCHAR(256),
|
|
93
|
+
created_at TIMESTAMP WITHOUT TIME ZONE,
|
|
94
|
+
updated_at TIMESTAMP WITHOUT TIME ZONE,
|
|
95
|
+
deleted_at TIMESTAMP WITHOUT TIME ZONE,
|
|
96
|
+
graph_edges JSONB,
|
|
97
|
+
metadata JSONB,
|
|
98
|
+
tags TEXT[]
|
|
99
|
+
);
|
|
100
|
+
-- Changes to table: patient_profiles
|
|
101
|
+
CREATE INDEX IF NOT EXISTS idx_patient_profiles_graph_edges ON patient_profiles (graph_edges);
|
|
102
|
+
CREATE INDEX IF NOT EXISTS idx_patient_profiles_metadata ON patient_profiles (metadata);
|
|
103
|
+
CREATE INDEX IF NOT EXISTS idx_patient_profiles_tags ON patient_profiles (tags);
|
|
104
|
+
CREATE INDEX IF NOT EXISTS idx_patient_profiles_tenant ON patient_profiles (tenant_id);
|
|
105
|
+
CREATE INDEX IF NOT EXISTS idx_patient_profiles_user ON patient_profiles (user_id);
|
|
106
|
+
CREATE TABLE IF NOT EXISTS subscribers (
|
|
107
|
+
id UUID NOT NULL,
|
|
108
|
+
tenant_id VARCHAR(100) NOT NULL,
|
|
109
|
+
user_id VARCHAR(256),
|
|
110
|
+
email TEXT NOT NULL,
|
|
111
|
+
name VARCHAR(256),
|
|
112
|
+
comment TEXT,
|
|
113
|
+
status TEXT,
|
|
114
|
+
origin TEXT,
|
|
115
|
+
origin_detail VARCHAR(256),
|
|
116
|
+
subscribed_at TIMESTAMP WITHOUT TIME ZONE,
|
|
117
|
+
unsubscribed_at TIMESTAMP WITHOUT TIME ZONE,
|
|
118
|
+
ip_address VARCHAR(256),
|
|
119
|
+
user_agent VARCHAR(256),
|
|
120
|
+
created_at TIMESTAMP WITHOUT TIME ZONE,
|
|
121
|
+
updated_at TIMESTAMP WITHOUT TIME ZONE,
|
|
122
|
+
deleted_at TIMESTAMP WITHOUT TIME ZONE,
|
|
123
|
+
graph_edges JSONB,
|
|
124
|
+
metadata JSONB,
|
|
125
|
+
tags TEXT[]
|
|
126
|
+
);
|
|
127
|
+
-- Changes to table: subscribers
|
|
128
|
+
CREATE INDEX IF NOT EXISTS idx_subscribers_graph_edges ON subscribers (graph_edges);
|
|
129
|
+
CREATE INDEX IF NOT EXISTS idx_subscribers_metadata ON subscribers (metadata);
|
|
130
|
+
CREATE INDEX IF NOT EXISTS idx_subscribers_tags ON subscribers (tags);
|
|
131
|
+
CREATE INDEX IF NOT EXISTS idx_subscribers_tenant ON subscribers (tenant_id);
|
|
132
|
+
CREATE INDEX IF NOT EXISTS idx_subscribers_user ON subscribers (user_id);
|
|
133
|
+
CREATE TABLE IF NOT EXISTS embeddings_patient_profiles (
|
|
134
|
+
id UUID NOT NULL,
|
|
135
|
+
entity_id UUID NOT NULL,
|
|
136
|
+
field_name VARCHAR(100) NOT NULL,
|
|
137
|
+
provider VARCHAR(50) NOT NULL,
|
|
138
|
+
model VARCHAR(100) NOT NULL,
|
|
139
|
+
embedding FLOAT[] NOT NULL,
|
|
140
|
+
created_at TIMESTAMP WITHOUT TIME ZONE,
|
|
141
|
+
updated_at TIMESTAMP WITHOUT TIME ZONE
|
|
142
|
+
);
|
|
143
|
+
-- Changes to table: embeddings_patient_profiles
|
|
144
|
+
CREATE INDEX IF NOT EXISTS idx_embeddings_patient_profiles_entity ON embeddings_patient_profiles (entity_id);
|
|
145
|
+
CREATE INDEX IF NOT EXISTS idx_embeddings_patient_profiles_field_provider ON embeddings_patient_profiles (field_name, provider);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
-- Migration: Update messages.session_id from session name to session UUID
|
|
2
|
+
-- This fixes the bug where messages were stored with session.name instead of session.id
|
|
3
|
+
--
|
|
4
|
+
-- Run this migration AFTER deploying the code fixes in remdb 0.3.204+
|
|
5
|
+
-- The code now correctly stores session.id (UUID), but existing data needs migration.
|
|
6
|
+
|
|
7
|
+
BEGIN;
|
|
8
|
+
|
|
9
|
+
-- First, count how many messages need to be updated
|
|
10
|
+
DO $$
|
|
11
|
+
DECLARE
|
|
12
|
+
count_to_migrate INTEGER;
|
|
13
|
+
BEGIN
|
|
14
|
+
SELECT COUNT(*) INTO count_to_migrate
|
|
15
|
+
FROM messages m
|
|
16
|
+
JOIN sessions s ON m.session_id = s.name
|
|
17
|
+
WHERE m.session_id != s.id::text;
|
|
18
|
+
|
|
19
|
+
RAISE NOTICE 'Messages needing migration: %', count_to_migrate;
|
|
20
|
+
END $$;
|
|
21
|
+
|
|
22
|
+
-- Update messages.session_id from session name to session UUID
|
|
23
|
+
UPDATE messages m
|
|
24
|
+
SET session_id = s.id::text
|
|
25
|
+
FROM sessions s
|
|
26
|
+
WHERE m.session_id = s.name
|
|
27
|
+
AND m.session_id != s.id::text;
|
|
28
|
+
|
|
29
|
+
-- Report how many were updated
|
|
30
|
+
DO $$
|
|
31
|
+
DECLARE
|
|
32
|
+
updated_count INTEGER;
|
|
33
|
+
BEGIN
|
|
34
|
+
GET DIAGNOSTICS updated_count = ROW_COUNT;
|
|
35
|
+
RAISE NOTICE 'Messages updated: %', updated_count;
|
|
36
|
+
END $$;
|
|
37
|
+
|
|
38
|
+
COMMIT;
|
|
39
|
+
|
|
40
|
+
-- Verify the fix - all messages should now join by UUID
|
|
41
|
+
SELECT
|
|
42
|
+
'Messages matching sessions by UUID' as status,
|
|
43
|
+
COUNT(*) as count
|
|
44
|
+
FROM messages m
|
|
45
|
+
JOIN sessions s ON m.session_id = s.id::text;
|