prism-models 0.1.8__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.
Files changed (44) hide show
  1. prism_models/__init__.py +46 -0
  2. prism_models/agent_profile.py +128 -0
  3. prism_models/base.py +75 -0
  4. prism_models/chat.py +355 -0
  5. prism_models/config.py +37 -0
  6. prism_models/content.py +240 -0
  7. prism_models/feedback.py +145 -0
  8. prism_models/migration/README +1 -0
  9. prism_models/migration/__init__.py +0 -0
  10. prism_models/migration/env.py +131 -0
  11. prism_models/migration/script.py.mako +28 -0
  12. prism_models/migration/versions/2025_09_11_1516_161f8829d93f_initial_schema.py +492 -0
  13. prism_models/migration/versions/2025_09_11_1558_5e011849ea76_changes_for_feedback.py +79 -0
  14. prism_models/migration/versions/2025_09_14_2243_059af231c2b2_profile_entities.py +108 -0
  15. prism_models/migration/versions/2025_09_15_1646_3219fec0bb10_agent_changes.py +32 -0
  16. prism_models/migration/versions/2025_09_16_1627_f2013b08daac_rename_metadata_to_additional_data.py +37 -0
  17. prism_models/migration/versions/2025_09_17_1147_327febbf555f_display_name_added.py +34 -0
  18. prism_models/migration/versions/2025_09_18_1106_b0bcb7ca1dc9_add_support_for_profile_on_create_convo.py +41 -0
  19. prism_models/migration/versions/2025_09_18_1511_bbc1955191e6_preview_mode.py +36 -0
  20. prism_models/migration/versions/2025_09_26_1115_6eb70e848451_added_publish_status_to_document.py +38 -0
  21. prism_models/migration/versions/2025_09_26_1240_f8b0ea2e743c_drop_unique_title_version_on_document.py +40 -0
  22. prism_models/migration/versions/2025_09_26_1505_07dc8c2589e0_added_chunk_id_and_vector_embeddings_to_.py +44 -0
  23. prism_models/migration/versions/2025_09_29_1220_46ba2693b883_add_markdown_markdown_file_path_s3_.py +32 -0
  24. prism_models/migration/versions/2025_10_02_1520_bf1472a9b021_removed_doc_id_from_config_table_and_.py +34 -0
  25. prism_models/migration/versions/2025_10_02_1525_6c0e63e0fef8_removed_doc_id_from_config_table_.py +34 -0
  26. prism_models/migration/versions/2025_10_02_1608_1b3eb48f5017_config_id_on_delete_will_be_set_to_null.py +34 -0
  27. prism_models/migration/versions/2025_10_03_1109_ac85b606d8a4_added_docling_hybrid_to_chunkstrategy.py +32 -0
  28. prism_models/migration/versions/2025_10_03_1204_7d1cb343a63f_added_s3_bucket_and_s3_dir_in_source_.py +42 -0
  29. prism_models/migration/versions/2025_10_03_1452_f9c750ec2a0b_1_to_1_relationship_between_collection_.py +52 -0
  30. prism_models/migration/versions/2025_10_07_1722_5cfa0c462948_added_travel_advisory_enum.py +38 -0
  31. prism_models/migration/versions/2025_10_08_1304_c91eb8e38cc7_added_destination_report_and_event_.py +38 -0
  32. prism_models/migration/versions/2025_10_09_1308_796b720ea35f_added_qa_id_to_vovetor.py +42 -0
  33. prism_models/migration/versions/2025_10_16_1611_663c66268631_added_sharepoint_drive_item_id_as_an_.py +32 -0
  34. prism_models/migration/versions/2025_10_23_1228_919d07a93f83_added_sharepoint_directory_in_source.py +32 -0
  35. prism_models/migration/versions/2025_10_27_1331_ff3be2c4311f_added_agentcollectionaccess_table.py +50 -0
  36. prism_models/migration/versions/2025_10_28_1333_b789e61df26a_ad_enum_and_field_added.py +46 -0
  37. prism_models/migration/versions/2025_11_03_1633_cc27b20a106e_removed_collection_from_source_.py +34 -0
  38. prism_models/migration/versions/2025_11_03_1653_bf5c2ce928e3_removed_collection_from_source_.py +36 -0
  39. prism_models/migration/versions/2025_11_03_1738_b733b48d78b5_remove_source.py +32 -0
  40. prism_models/qdrant.py +102 -0
  41. prism_models-0.1.8.dist-info/METADATA +10 -0
  42. prism_models-0.1.8.dist-info/RECORD +44 -0
  43. prism_models-0.1.8.dist-info/WHEEL +5 -0
  44. prism_models-0.1.8.dist-info/top_level.txt +1 -0
@@ -0,0 +1,52 @@
1
+ """1 to 1 relationship between collection and source
2
+
3
+ Revision ID: f9c750ec2a0b
4
+ Revises: 7d1cb343a63f
5
+ Create Date: 2025-10-03 14:52:06.699081
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = 'f9c750ec2a0b'
16
+ down_revision: Union[str, Sequence[str], None] = '7d1cb343a63f'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.add_column('source', sa.Column('type', sa.Enum('S3', 'SHARE_POINT', 'GRID', 'CRM', 'CONFLUENCE', 'CUSTOM', name='sourcename', native_enum=False), nullable=True))
25
+ op.add_column('source', sa.Column('collection_id', sa.Integer(), nullable=False))
26
+ op.alter_column('source', 'name',
27
+ existing_type=sa.VARCHAR(length=23),
28
+ type_=sa.String(length=255),
29
+ existing_nullable=False)
30
+ op.drop_index(op.f('source_name_idx'), table_name='source')
31
+ op.create_index(op.f('source_name_idx'), 'source', ['name'], unique=True)
32
+ op.create_index(op.f('source_collection_id_idx'), 'source', ['collection_id'], unique=True)
33
+ op.create_index(op.f('source_type_idx'), 'source', ['type'], unique=False)
34
+ op.create_foreign_key(op.f('source_collection_id_fkey'), 'source', 'collection', ['collection_id'], ['id'])
35
+ # ### end Alembic commands ###
36
+
37
+
38
+ def downgrade() -> None:
39
+ """Downgrade schema."""
40
+ # ### commands auto generated by Alembic - please adjust! ###
41
+ op.drop_constraint(op.f('source_collection_id_fkey'), 'source', type_='foreignkey')
42
+ op.drop_index(op.f('source_type_idx'), table_name='source')
43
+ op.drop_index(op.f('source_collection_id_idx'), table_name='source')
44
+ op.drop_index(op.f('source_name_idx'), table_name='source')
45
+ op.create_index(op.f('source_name_idx'), 'source', ['name'], unique=False)
46
+ op.alter_column('source', 'name',
47
+ existing_type=sa.String(length=255),
48
+ type_=sa.VARCHAR(length=23),
49
+ existing_nullable=False)
50
+ op.drop_column('source', 'collection_id')
51
+ op.drop_column('source', 'type')
52
+ # ### end Alembic commands ###
@@ -0,0 +1,38 @@
1
+ """added travel advisory enum
2
+
3
+ Revision ID: 5cfa0c462948
4
+ Revises: f9c750ec2a0b
5
+ Create Date: 2025-10-07 17:22:46.670468
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = '5cfa0c462948'
16
+ down_revision: Union[str, Sequence[str], None] = 'f9c750ec2a0b'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.alter_column('source', 'type',
25
+ existing_type=sa.VARCHAR(length=11),
26
+ type_=sa.Enum('S3', 'SHARE_POINT', 'GRID', 'CRM', 'CONFLUENCE', 'CUSTOM', 'TRAVEL_ADVISORY', name='sourcename', native_enum=False),
27
+ existing_nullable=True)
28
+ # ### end Alembic commands ###
29
+
30
+
31
+ def downgrade() -> None:
32
+ """Downgrade schema."""
33
+ # ### commands auto generated by Alembic - please adjust! ###
34
+ op.alter_column('source', 'type',
35
+ existing_type=sa.Enum('S3', 'SHARE_POINT', 'GRID', 'CRM', 'CONFLUENCE', 'CUSTOM', 'TRAVEL_ADVISORY', name='sourcename', native_enum=False),
36
+ type_=sa.VARCHAR(length=11),
37
+ existing_nullable=True)
38
+ # ### end Alembic commands ###
@@ -0,0 +1,38 @@
1
+ """Added Destination Report and event sources
2
+
3
+ Revision ID: c91eb8e38cc7
4
+ Revises: 5cfa0c462948
5
+ Create Date: 2025-10-08 13:04:14.325976
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = 'c91eb8e38cc7'
16
+ down_revision: Union[str, Sequence[str], None] = '5cfa0c462948'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.alter_column('source', 'type',
25
+ existing_type=sa.VARCHAR(length=15),
26
+ type_=sa.Enum('S3', 'SHARE_POINT', 'GRID', 'GRID_DESTINATION_REPORT', 'GRID_EVENT_REPORT', 'CRM', 'CONFLUENCE', 'CUSTOM', 'TRAVEL_ADVISORY', name='sourcename', native_enum=False),
27
+ existing_nullable=True)
28
+ # ### end Alembic commands ###
29
+
30
+
31
+ def downgrade() -> None:
32
+ """Downgrade schema."""
33
+ # ### commands auto generated by Alembic - please adjust! ###
34
+ op.alter_column('source', 'type',
35
+ existing_type=sa.Enum('S3', 'SHARE_POINT', 'GRID', 'GRID_DESTINATION_REPORT', 'GRID_EVENT_REPORT', 'CRM', 'CONFLUENCE', 'CUSTOM', 'TRAVEL_ADVISORY', name='sourcename', native_enum=False),
36
+ type_=sa.VARCHAR(length=15),
37
+ existing_nullable=True)
38
+ # ### end Alembic commands ###
@@ -0,0 +1,42 @@
1
+ """added qa id to vovetor
2
+
3
+ Revision ID: 796b720ea35f
4
+ Revises: c91eb8e38cc7
5
+ Create Date: 2025-10-09 13:08:56.972719
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = '796b720ea35f'
16
+ down_revision: Union[str, Sequence[str], None] = 'c91eb8e38cc7'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.add_column('vector', sa.Column('qa_pair_id', sa.Integer(), nullable=True))
25
+ op.alter_column('vector', 'chunk_id',
26
+ existing_type=sa.INTEGER(),
27
+ nullable=True)
28
+ op.create_unique_constraint(op.f('vector_qa_pair_id_key'), 'vector', ['qa_pair_id'])
29
+ op.create_foreign_key(op.f('vector_qa_pair_id_fkey'), 'vector', 'qa_pair', ['qa_pair_id'], ['id'])
30
+ # ### end Alembic commands ###
31
+
32
+
33
+ def downgrade() -> None:
34
+ """Downgrade schema."""
35
+ # ### commands auto generated by Alembic - please adjust! ###
36
+ op.drop_constraint(op.f('vector_qa_pair_id_fkey'), 'vector', type_='foreignkey')
37
+ op.drop_constraint(op.f('vector_qa_pair_id_key'), 'vector', type_='unique')
38
+ op.alter_column('vector', 'chunk_id',
39
+ existing_type=sa.INTEGER(),
40
+ nullable=False)
41
+ op.drop_column('vector', 'qa_pair_id')
42
+ # ### end Alembic commands ###
@@ -0,0 +1,32 @@
1
+ """added sharepoint_drive_item_id as an optional field to document table
2
+
3
+ Revision ID: 663c66268631
4
+ Revises: 796b720ea35f
5
+ Create Date: 2025-10-16 16:11:31.728752
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = '663c66268631'
16
+ down_revision: Union[str, Sequence[str], None] = '796b720ea35f'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.add_column('document', sa.Column('sharepoint_drive_item_id', sa.String(length=1024), nullable=True))
25
+ # ### end Alembic commands ###
26
+
27
+
28
+ def downgrade() -> None:
29
+ """Downgrade schema."""
30
+ # ### commands auto generated by Alembic - please adjust! ###
31
+ op.drop_column('document', 'sharepoint_drive_item_id')
32
+ # ### end Alembic commands ###
@@ -0,0 +1,32 @@
1
+ """added sharepoint_directory in source
2
+
3
+ Revision ID: 919d07a93f83
4
+ Revises: 663c66268631
5
+ Create Date: 2025-10-23 12:28:57.570381
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = '919d07a93f83'
16
+ down_revision: Union[str, Sequence[str], None] = '663c66268631'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.add_column('source', sa.Column('sharepoint_directory', sa.String(length=2048), nullable=True))
25
+ # ### end Alembic commands ###
26
+
27
+
28
+ def downgrade() -> None:
29
+ """Downgrade schema."""
30
+ # ### commands auto generated by Alembic - please adjust! ###
31
+ op.drop_column('source', 'sharepoint_directory')
32
+ # ### end Alembic commands ###
@@ -0,0 +1,50 @@
1
+ """added AgentCollectionAccess table
2
+
3
+ Revision ID: ff3be2c4311f
4
+ Revises: 919d07a93f83
5
+ Create Date: 2025-10-27 13:31:19.882851
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = 'ff3be2c4311f'
16
+ down_revision: Union[str, Sequence[str], None] = '919d07a93f83'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.create_table('agent_collection_access',
25
+ sa.Column('agent_id', sa.Integer(), nullable=False),
26
+ sa.Column('collection_id', sa.Integer(), nullable=False),
27
+ sa.Column('access_granted_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=True),
28
+ sa.Column('id', sa.Integer(), nullable=False),
29
+ sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
30
+ sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
31
+ sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
32
+ sa.ForeignKeyConstraint(['agent_id'], ['agent.id'], name=op.f('agent_collection_access_agent_id_fkey'), ondelete='CASCADE'),
33
+ sa.ForeignKeyConstraint(['collection_id'], ['collection.id'], name=op.f('agent_collection_access_collection_id_fkey'), ondelete='CASCADE'),
34
+ sa.PrimaryKeyConstraint('id', name=op.f('agent_collection_access_pkey')),
35
+ sa.UniqueConstraint('agent_id', 'collection_id', name='uq_agent_collection')
36
+ )
37
+ op.create_index(op.f('agent_collection_access_agent_id_idx'), 'agent_collection_access', ['agent_id'], unique=False)
38
+ op.create_index(op.f('agent_collection_access_collection_id_idx'), 'agent_collection_access', ['collection_id'], unique=False)
39
+ op.create_index(op.f('agent_collection_access_id_idx'), 'agent_collection_access', ['id'], unique=False)
40
+ # ### end Alembic commands ###
41
+
42
+
43
+ def downgrade() -> None:
44
+ """Downgrade schema."""
45
+ # ### commands auto generated by Alembic - please adjust! ###
46
+ op.drop_index(op.f('agent_collection_access_id_idx'), table_name='agent_collection_access')
47
+ op.drop_index(op.f('agent_collection_access_collection_id_idx'), table_name='agent_collection_access')
48
+ op.drop_index(op.f('agent_collection_access_agent_id_idx'), table_name='agent_collection_access')
49
+ op.drop_table('agent_collection_access')
50
+ # ### end Alembic commands ###
@@ -0,0 +1,46 @@
1
+ """AD Enum and field added
2
+
3
+ Revision ID: b789e61df26a
4
+ Revises: ff3be2c4311f
5
+ Create Date: 2025-10-28 13:33:30.377086
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = 'b789e61df26a'
16
+ down_revision: Union[str, Sequence[str], None] = 'ff3be2c4311f'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # Add new MICROSOFT_AD value to the existing contactsource enum type
24
+ op.execute("ALTER TYPE contactsource ADD VALUE IF NOT EXISTS 'MICROSOFT_AD'")
25
+
26
+ # ### commands auto generated by Alembic - please adjust! ###
27
+ op.add_column('contact', sa.Column('azure_ad_object_id', sa.String(length=36), nullable=True))
28
+ op.add_column('contact', sa.Column('azure_ad_tenant_id', sa.String(length=36), nullable=True))
29
+ op.create_index(op.f('contact_azure_ad_object_id_idx'), 'contact', ['azure_ad_object_id'], unique=True)
30
+ op.create_index(op.f('contact_azure_ad_tenant_id_idx'), 'contact', ['azure_ad_tenant_id'], unique=False)
31
+ # ### end Alembic commands ###
32
+
33
+
34
+ def downgrade() -> None:
35
+ """Downgrade schema."""
36
+ # ### commands auto generated by Alembic - please adjust! ###
37
+ op.drop_index(op.f('contact_azure_ad_tenant_id_idx'), table_name='contact')
38
+ op.drop_index(op.f('contact_azure_ad_object_id_idx'), table_name='contact')
39
+ op.drop_column('contact', 'azure_ad_tenant_id')
40
+ op.drop_column('contact', 'azure_ad_object_id')
41
+ # ### end Alembic commands ###
42
+
43
+ # NOTE: Removing enum values from PostgreSQL types is complex and risky.
44
+ # The 'MICROSOFT_AD' value will remain in the contactsource type after downgrade.
45
+ # If you need to remove it, you would need to recreate the enum type entirely,
46
+ # which requires updating all dependent columns. Not recommended for production.
@@ -0,0 +1,34 @@
1
+ """removed collection from source integration config should be used
2
+
3
+ Revision ID: cc27b20a106e
4
+ Revises: b789e61df26a
5
+ Create Date: 2025-11-03 16:33:41.227671
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = 'cc27b20a106e'
16
+ down_revision: Union[str, Sequence[str], None] = 'b789e61df26a'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.drop_index(op.f('source_collection_id_idx'), table_name='source')
25
+ op.create_index(op.f('source_collection_id_idx'), 'source', ['collection_id'], unique=False)
26
+ # ### end Alembic commands ###
27
+
28
+
29
+ def downgrade() -> None:
30
+ """Downgrade schema."""
31
+ # ### commands auto generated by Alembic - please adjust! ###
32
+ op.drop_index(op.f('source_collection_id_idx'), table_name='source')
33
+ op.create_index(op.f('source_collection_id_idx'), 'source', ['collection_id'], unique=True)
34
+ # ### end Alembic commands ###
@@ -0,0 +1,36 @@
1
+ """removed collection from source integration config should be used
2
+
3
+ Revision ID: bf5c2ce928e3
4
+ Revises: cc27b20a106e
5
+ Create Date: 2025-11-03 16:53:03.130091
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = 'bf5c2ce928e3'
16
+ down_revision: Union[str, Sequence[str], None] = 'cc27b20a106e'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.drop_index(op.f('source_collection_id_idx'), table_name='source')
25
+ op.drop_constraint(op.f('source_collection_id_fkey'), 'source', type_='foreignkey')
26
+ op.drop_column('source', 'collection_id')
27
+ # ### end Alembic commands ###
28
+
29
+
30
+ def downgrade() -> None:
31
+ """Downgrade schema."""
32
+ # ### commands auto generated by Alembic - please adjust! ###
33
+ op.add_column('source', sa.Column('collection_id', sa.INTEGER(), autoincrement=False, nullable=False))
34
+ op.create_foreign_key(op.f('source_collection_id_fkey'), 'source', 'collection', ['collection_id'], ['id'])
35
+ op.create_index(op.f('source_collection_id_idx'), 'source', ['collection_id'], unique=False)
36
+ # ### end Alembic commands ###
@@ -0,0 +1,32 @@
1
+ """remove source
2
+
3
+ Revision ID: b733b48d78b5
4
+ Revises: bf5c2ce928e3
5
+ Create Date: 2025-11-03 17:38:08.937565
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = 'b733b48d78b5'
16
+ down_revision: Union[str, Sequence[str], None] = 'bf5c2ce928e3'
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ """Upgrade schema."""
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ pass
25
+ # ### end Alembic commands ###
26
+
27
+
28
+ def downgrade() -> None:
29
+ """Downgrade schema."""
30
+ # ### commands auto generated by Alembic - please adjust! ###
31
+ pass
32
+ # ### end Alembic commands ###
prism_models/qdrant.py ADDED
@@ -0,0 +1,102 @@
1
+ from typing import Optional, List, Any
2
+ from datetime import datetime
3
+ from pydantic import BaseModel, Field, UUID4, ValidationError
4
+ from sqlalchemy import JSON, TypeDecorator
5
+ from sqlalchemy.engine.interfaces import Dialect
6
+ from enum import Enum
7
+
8
+ class ChunkTypeEnum(str, Enum):
9
+ TEXT = "TEXT"
10
+ Q_AND_A = "Q/A"
11
+ AUGMENTED_TEXT = "AUGMENTED_TEXT"
12
+ AUGMENTED_Q_AND_A = "AUGMENTED_Q/A"
13
+
14
+ class QdrantVectorPayload(BaseModel):
15
+ virtual_collection_names: Optional[List[str]] = Field(
16
+ default=None, description="Names of the virtual collections"
17
+ )
18
+ uuid: Optional[UUID4] = Field(
19
+ default=None, description="Unique identifier for the vector"
20
+ )
21
+
22
+ document_id: Optional[int] = Field(
23
+ default=None, description="ID of the document associated with the chunk"
24
+ )
25
+
26
+ chunk_text: Optional[str] = Field(
27
+ default=None, description="Text content of the chunk"
28
+ )
29
+ is_active: Optional[bool] = Field(
30
+ default=True, description="Whether the vector is active"
31
+ )
32
+ deleted_at: Optional[datetime] = Field(
33
+ default=None, description="Timestamp when the vector was deleted"
34
+ )
35
+
36
+ chunk_type: ChunkTypeEnum = Field(
37
+ default=ChunkTypeEnum.TEXT,
38
+ description="Type of the chunk"
39
+ )
40
+
41
+ class Config:
42
+ orm_mode = True
43
+
44
+
45
+ class DestinationVectorPayload(QdrantVectorPayload):
46
+ destination_id: Optional[int] = Field(
47
+ default=None, description="ID of the destination associated with the chunk"
48
+ )
49
+ report_title: Optional[str] = Field(
50
+ default=None, description="Title of the report"
51
+ )
52
+ destination_name: Optional[str] = Field(
53
+ default=None, description="Name of the destination"
54
+ )
55
+
56
+
57
+ class PydanticType(TypeDecorator):
58
+ """
59
+ A SQLAlchemy column type that validates JSON data against a Pydantic model.
60
+
61
+ Usage:
62
+ class MyModel(Base):
63
+ data: Mapped[dict] = mapped_column(PydanticType(MyPydanticModel))
64
+ """
65
+ impl = JSON
66
+ cache_ok = True
67
+
68
+ def __init__(self, pydantic_model: type[BaseModel], *args, **kwargs):
69
+ super().__init__(*args, **kwargs)
70
+ self.pydantic_model = pydantic_model
71
+
72
+ def process_bind_param(self, value: Any, dialect: Dialect) -> dict | None:
73
+ """
74
+ Validate and convert Pydantic model to dict before storing in database.
75
+ """
76
+ if value is None:
77
+ return None
78
+
79
+ if isinstance(value, self.pydantic_model):
80
+ return value.model_dump(mode='json')
81
+
82
+ if isinstance(value, dict):
83
+ try:
84
+ validated = self.pydantic_model(**value)
85
+ return validated.model_dump(mode='json')
86
+ except ValidationError as e:
87
+ raise ValueError(f"Invalid data for {self.pydantic_model.__name__}: {e}")
88
+
89
+ raise ValueError(f"Expected {self.pydantic_model.__name__} or dict, got {type(value)}")
90
+
91
+ def process_result_value(self, value: dict | None, dialect: Dialect) -> BaseModel | None:
92
+ """
93
+ Convert dict from database to Pydantic model instance.
94
+ """
95
+ if value is None:
96
+ return None
97
+
98
+ try:
99
+ return self.pydantic_model(**value)
100
+ except ValidationError as e:
101
+ print(f"Warning: Invalid data in database for {self.pydantic_model.__name__}: {e}")
102
+ return None
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: prism-models
3
+ Version: 0.1.8
4
+ Requires-Python: >=3.12
5
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.0
6
+ Requires-Dist: alembic>=1.16.0
7
+ Requires-Dist: asyncpg>=0.29.0
8
+ Requires-Dist: pydantic>=2.0.0
9
+ Requires-Dist: pydantic-settings>=2.1.0
10
+ Requires-Dist: uuid7>=0.1.0
@@ -0,0 +1,44 @@
1
+ prism_models/__init__.py,sha256=IMDlzCmXkCSiY2Ag5BUS4KS2muPJrinwgSquMcmLCG0,1448
2
+ prism_models/agent_profile.py,sha256=pyWv0yZlt32iMzSht8z90F-RUZlLqVAFdjJKJlOuMEk,4602
3
+ prism_models/base.py,sha256=Ka8zNToTiTG0jNgzqqj2goGmPXt8zxuuSMYvotnb8wY,2281
4
+ prism_models/chat.py,sha256=apkzBWRhJyhT2VBMOSewhFfueyjkpR3u3vQYTSWG2qc,12013
5
+ prism_models/config.py,sha256=L1e7yJ3D3ySzNNzYQYyfBOpNJFwjwdOSTOo2gkfBaXw,963
6
+ prism_models/content.py,sha256=Sq5yWEP5mJVMN9gL9_H48f23svVDLbD1gRHYg13CXpk,10573
7
+ prism_models/feedback.py,sha256=tMZISQ0mk7_1ADsK4bO36_VZ0f-JDdAPcfWzIZBk0_g,6202
8
+ prism_models/qdrant.py,sha256=rnW_MPeC1kdtAMPlVIwWoRyJKd2TgKP5rc8i8GMrqCs,3399
9
+ prism_models/migration/README,sha256=MVlc9TYmr57RbhXET6QxgyCcwWP7w-vLkEsirENqiIQ,38
10
+ prism_models/migration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ prism_models/migration/env.py,sha256=Uobqv_peoEUYAZST0D0hO7xHPQe8OPxqZ0yV1xuNE2c,4096
12
+ prism_models/migration/script.py.mako,sha256=04kgeBtNMa4cCnG8CfQcKt6P6rnloIfj8wy0u_DBydM,704
13
+ prism_models/migration/versions/2025_09_11_1516_161f8829d93f_initial_schema.py,sha256=6nkB5DLbTNCk84SYsKz0kUzyhvDPjkkC9HuwN37QUao,35166
14
+ prism_models/migration/versions/2025_09_11_1558_5e011849ea76_changes_for_feedback.py,sha256=KmglWbDxyOSctzgTpyis0TC0-rEqZKrhM9xgFiTWF-s,5434
15
+ prism_models/migration/versions/2025_09_14_2243_059af231c2b2_profile_entities.py,sha256=aKxOOEDPo_wZwh93vJNXXQDdO9dqlPJ5pK3mY_Hef9U,6331
16
+ prism_models/migration/versions/2025_09_15_1646_3219fec0bb10_agent_changes.py,sha256=0b7TyOyEBU-HaINIMGYZjhWHbz5m5LEB1Bjz-IZ72qQ,868
17
+ prism_models/migration/versions/2025_09_16_1627_f2013b08daac_rename_metadata_to_additional_data.py,sha256=ihzMYcVK-37DN1jYsuOMISvBjnGDwViDTaj4FczONRs,1415
18
+ prism_models/migration/versions/2025_09_17_1147_327febbf555f_display_name_added.py,sha256=5DhctzmhumdDt157ytUi0JNQPCt6KXF9_u_ADutR5pw,1021
19
+ prism_models/migration/versions/2025_09_18_1106_b0bcb7ca1dc9_add_support_for_profile_on_create_convo.py,sha256=MWZRiCnVKaojXOGMpr_G41611yIXnAuBzAeeV6Nusw4,1445
20
+ prism_models/migration/versions/2025_09_18_1511_bbc1955191e6_preview_mode.py,sha256=-lokRulsgfjt1LXY2e1pcLFSw40ELICpRM6QLec9pjM,1043
21
+ prism_models/migration/versions/2025_09_26_1115_6eb70e848451_added_publish_status_to_document.py,sha256=i_yNpWCgIG9t8nfPR58xerzcgCqKFMl7lxPvixGkHPU,1463
22
+ prism_models/migration/versions/2025_09_26_1240_f8b0ea2e743c_drop_unique_title_version_on_document.py,sha256=Td2ijXUdUrN68aFizK5SKYC4XwOw3DPKwEGFjycv7Qs,1480
23
+ prism_models/migration/versions/2025_09_26_1505_07dc8c2589e0_added_chunk_id_and_vector_embeddings_to_.py,sha256=6S3qCe0JBx-LNZN3jhGN_9RrKBOKCDVuywzZxveDRaQ,1916
24
+ prism_models/migration/versions/2025_09_29_1220_46ba2693b883_add_markdown_markdown_file_path_s3_.py,sha256=NRZFSr4Zm9XWUujx7-QUBKL1BdICMOKuNVxw3PZsg9Y,934
25
+ prism_models/migration/versions/2025_10_02_1520_bf1472a9b021_removed_doc_id_from_config_table_and_.py,sha256=aB-k8Dqw39YHxgg_hBcPEDyDmFxjn5d1KEQuTCUJ_8E,1155
26
+ prism_models/migration/versions/2025_10_02_1525_6c0e63e0fef8_removed_doc_id_from_config_table_.py,sha256=-4OSytv3-L_Yc3TI2pUB8gpPH3iQzuU3KzeRqZdaD9Q,1228
27
+ prism_models/migration/versions/2025_10_02_1608_1b3eb48f5017_config_id_on_delete_will_be_set_to_null.py,sha256=k9d2CSFCegeeJulUtI3sXmff9ttDi9pftLsgWIwiqm0,1224
28
+ prism_models/migration/versions/2025_10_03_1109_ac85b606d8a4_added_docling_hybrid_to_chunkstrategy.py,sha256=B1z0SvnnkXAAHHQeQQu1aMJGQml66yoTj1sL0BraK6Y,787
29
+ prism_models/migration/versions/2025_10_03_1204_7d1cb343a63f_added_s3_bucket_and_s3_dir_in_source_.py,sha256=qkiMOFumgssJz2dceyN5CNd8hlbY9xruJVozQZrvOe0,1563
30
+ prism_models/migration/versions/2025_10_03_1452_f9c750ec2a0b_1_to_1_relationship_between_collection_.py,sha256=u-zRopfKHEO-2nNBmGXALkPl4mVnIwj2Y2rfcWKTAow,2264
31
+ prism_models/migration/versions/2025_10_07_1722_5cfa0c462948_added_travel_advisory_enum.py,sha256=dxhTunpblAaWN6KNMMYuoZmFNcZ1VMrR5SfOwcDLO4Y,1310
32
+ prism_models/migration/versions/2025_10_08_1304_c91eb8e38cc7_added_destination_report_and_event_.py,sha256=7Re8GVdOC4KMIP14MWpVAD6LlV4ow0uP4w_jYF8iT_g,1422
33
+ prism_models/migration/versions/2025_10_09_1308_796b720ea35f_added_qa_id_to_vovetor.py,sha256=tW58ejf2_NcaK038Igf3zicZQymeVt4I4uzZULNtHV0,1467
34
+ prism_models/migration/versions/2025_10_16_1611_663c66268631_added_sharepoint_drive_item_id_as_an_.py,sha256=IaG9NDyTGENq65GyrhGoScBb-U82x5V7NBKpG9PYy5Q,968
35
+ prism_models/migration/versions/2025_10_23_1228_919d07a93f83_added_sharepoint_directory_in_source.py,sha256=dk7jTusquTc9rDlJtduGIi-YiqNpGfex63WQkVLMeuk,923
36
+ prism_models/migration/versions/2025_10_27_1331_ff3be2c4311f_added_agentcollectionaccess_table.py,sha256=wFa9DJSQjhHSrl2JUA2vgPz8qLcL01xepu_MDHhSjGo,2528
37
+ prism_models/migration/versions/2025_10_28_1333_b789e61df26a_ad_enum_and_field_added.py,sha256=rdtLBBRs8Sin4IkZZ4veV8cO_n_clFMGyPz5kIgIAwc,1922
38
+ prism_models/migration/versions/2025_11_03_1633_cc27b20a106e_removed_collection_from_source_.py,sha256=Dp_t4iH8FOiXPBzZ9tXF31fYtCdTXhEv8fXoBZ2UMvY,1135
39
+ prism_models/migration/versions/2025_11_03_1653_bf5c2ce928e3_removed_collection_from_source_.py,sha256=zhKjtCQSBjnG55tUUqBrK6WWQpkYq670cjBwFOJZDc8,1319
40
+ prism_models/migration/versions/2025_11_03_1738_b733b48d78b5_remove_source.py,sha256=6NtXTDRbeO70wGJ2ZtCBUwfCRgMyHUGiDmBS0I4vlqE,763
41
+ prism_models-0.1.8.dist-info/METADATA,sha256=Jw2xgpUANdeiBg510lk-aMIdOhf4njG9R8zhG0Dsfiw,283
42
+ prism_models-0.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
+ prism_models-0.1.8.dist-info/top_level.txt,sha256=UNzqwpLgFYU0EoyB9LiB1jTtc89A1sQ24fSEyNVvgJI,13
44
+ prism_models-0.1.8.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ prism_models