letschatty 0.4.337__py3-none-any.whl → 0.4.339__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.
- letschatty/models/ai_microservices/__init__.py +3 -3
- letschatty/models/ai_microservices/expected_output.py +2 -29
- letschatty/models/ai_microservices/lambda_events.py +39 -135
- letschatty/models/ai_microservices/lambda_invokation_types.py +1 -3
- letschatty/models/ai_microservices/n8n_ai_agents_payload.py +1 -3
- letschatty/models/analytics/events/__init__.py +2 -3
- letschatty/models/analytics/events/chat_based_events/chat_funnel.py +69 -13
- letschatty/models/analytics/events/company_based_events/asset_events.py +9 -2
- letschatty/models/analytics/events/event_type_to_classes.py +6 -3
- letschatty/models/analytics/events/event_types.py +9 -50
- letschatty/models/chat/chat.py +2 -0
- letschatty/models/chat/chat_with_assets.py +6 -1
- letschatty/models/chat/client.py +0 -2
- letschatty/models/chat/continuous_conversation.py +1 -1
- letschatty/models/company/CRM/funnel.py +365 -33
- letschatty/models/company/__init__.py +2 -1
- letschatty/models/company/assets/ai_agents_v2/ai_agents_decision_output.py +1 -1
- letschatty/models/company/assets/ai_agents_v2/chain_of_thought_in_chat.py +3 -5
- letschatty/models/company/assets/ai_agents_v2/chatty_ai_agent_in_chat.py +2 -37
- letschatty/models/company/assets/ai_agents_v2/chatty_ai_mode.py +2 -2
- letschatty/models/company/assets/ai_agents_v2/get_chat_with_prompt_response.py +0 -1
- letschatty/models/company/assets/ai_agents_v2/pre_qualify_config.py +2 -14
- letschatty/models/company/assets/ai_agents_v2/statuses.py +33 -0
- letschatty/models/company/assets/automation.py +10 -19
- letschatty/models/company/assets/chat_assets.py +9 -0
- letschatty/models/company/assets/company_assets.py +2 -0
- letschatty/models/company/form_field.py +9 -2
- letschatty/models/data_base/collection_interface.py +29 -101
- letschatty/models/data_base/mongo_connection.py +9 -92
- letschatty/models/messages/chatty_messages/schema/chatty_content/content_document.py +4 -2
- letschatty/models/messages/chatty_messages/schema/chatty_content/content_media.py +4 -3
- letschatty/models/utils/custom_exceptions/custom_exceptions.py +1 -14
- letschatty/services/ai_agents/smart_follow_up_context_builder_v2.py +2 -5
- letschatty/services/chat/chat_service.py +16 -2
- letschatty/services/chatty_assets/__init__.py +0 -12
- letschatty/services/chatty_assets/asset_service.py +13 -190
- letschatty/services/chatty_assets/base_container.py +2 -3
- letschatty/services/chatty_assets/base_container_with_collection.py +26 -35
- letschatty/services/continuous_conversation_service/continuous_conversation_helper.py +0 -11
- letschatty/services/events/events_manager.py +1 -218
- letschatty/services/factories/analytics/events_factory.py +6 -66
- letschatty/services/factories/lambda_ai_orchestrartor/lambda_events_factory.py +8 -25
- letschatty/services/messages_helpers/get_caption_or_body_or_preview.py +4 -6
- {letschatty-0.4.337.dist-info → letschatty-0.4.339.dist-info}/METADATA +1 -1
- {letschatty-0.4.337.dist-info → letschatty-0.4.339.dist-info}/RECORD +47 -82
- letschatty/models/analytics/events/chat_based_events/ai_agent_execution_event.py +0 -71
- letschatty/services/chatty_assets/assets_collections.py +0 -137
- letschatty/services/chatty_assets/collections/__init__.py +0 -38
- letschatty/services/chatty_assets/collections/ai_agent_collection.py +0 -19
- letschatty/services/chatty_assets/collections/ai_agent_in_chat_collection.py +0 -32
- letschatty/services/chatty_assets/collections/ai_component_collection.py +0 -21
- letschatty/services/chatty_assets/collections/chain_of_thought_collection.py +0 -30
- letschatty/services/chatty_assets/collections/chat_collection.py +0 -21
- letschatty/services/chatty_assets/collections/contact_point_collection.py +0 -21
- letschatty/services/chatty_assets/collections/fast_answer_collection.py +0 -21
- letschatty/services/chatty_assets/collections/filter_criteria_collection.py +0 -18
- letschatty/services/chatty_assets/collections/flow_collection.py +0 -20
- letschatty/services/chatty_assets/collections/product_collection.py +0 -20
- letschatty/services/chatty_assets/collections/sale_collection.py +0 -20
- letschatty/services/chatty_assets/collections/source_collection.py +0 -21
- letschatty/services/chatty_assets/collections/tag_collection.py +0 -19
- letschatty/services/chatty_assets/collections/topic_collection.py +0 -21
- letschatty/services/chatty_assets/collections/user_collection.py +0 -20
- letschatty/services/chatty_assets/example_usage.py +0 -44
- letschatty/services/chatty_assets/services/__init__.py +0 -37
- letschatty/services/chatty_assets/services/ai_agent_in_chat_service.py +0 -73
- letschatty/services/chatty_assets/services/ai_agent_service.py +0 -23
- letschatty/services/chatty_assets/services/chain_of_thought_service.py +0 -70
- letschatty/services/chatty_assets/services/chat_service.py +0 -25
- letschatty/services/chatty_assets/services/contact_point_service.py +0 -29
- letschatty/services/chatty_assets/services/fast_answer_service.py +0 -32
- letschatty/services/chatty_assets/services/filter_criteria_service.py +0 -30
- letschatty/services/chatty_assets/services/flow_service.py +0 -25
- letschatty/services/chatty_assets/services/product_service.py +0 -30
- letschatty/services/chatty_assets/services/sale_service.py +0 -25
- letschatty/services/chatty_assets/services/source_service.py +0 -28
- letschatty/services/chatty_assets/services/tag_service.py +0 -32
- letschatty/services/chatty_assets/services/topic_service.py +0 -31
- letschatty/services/chatty_assets/services/user_service.py +0 -32
- letschatty/services/events/__init__.py +0 -6
- letschatty/services/factories/analytics/ai_agent_event_factory.py +0 -161
- {letschatty-0.4.337.dist-info → letschatty-0.4.339.dist-info}/LICENSE +0 -0
- {letschatty-0.4.337.dist-info → letschatty-0.4.339.dist-info}/WHEEL +0 -0
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Read-only Assets Collections Container
|
|
3
|
-
|
|
4
|
-
This module provides a singleton container class that gives microservices
|
|
5
|
-
read-only access to asset data using pre-configured AssetCollection subclasses.
|
|
6
|
-
Perfect for services that only need to read asset data without CRUD operations.
|
|
7
|
-
"""
|
|
8
|
-
from __future__ import annotations
|
|
9
|
-
from typing import TYPE_CHECKING, Any
|
|
10
|
-
import logging
|
|
11
|
-
|
|
12
|
-
# Import base components
|
|
13
|
-
from ...models.data_base.mongo_connection import MongoConnection
|
|
14
|
-
from ...models.base_models.singleton import SingletonMeta
|
|
15
|
-
|
|
16
|
-
# Import pre-configured collection subclasses
|
|
17
|
-
from .collections import (
|
|
18
|
-
ProductCollection,
|
|
19
|
-
TagCollection,
|
|
20
|
-
UserCollection,
|
|
21
|
-
ChatCollection,
|
|
22
|
-
SourceCollection,
|
|
23
|
-
FlowCollection,
|
|
24
|
-
SaleCollection,
|
|
25
|
-
ContactPointCollection,
|
|
26
|
-
AiAgentCollection,
|
|
27
|
-
FilterCriteriaCollection,
|
|
28
|
-
AiComponentCollection
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
# Import asset models for type hints
|
|
32
|
-
from ...models.company.assets.product import Product
|
|
33
|
-
from ...models.company.assets.tag import Tag
|
|
34
|
-
from ...models.company.assets.users.user import User
|
|
35
|
-
from ...models.chat.chat import Chat
|
|
36
|
-
from ...models.analytics.sources import SourceBase
|
|
37
|
-
from ...models.company.assets.flow import FlowPreview
|
|
38
|
-
from ...models.company.assets.sale import Sale
|
|
39
|
-
from ...models.company.assets.contact_point import ContactPoint
|
|
40
|
-
from ...models.company.assets.ai_agents_v2.chatty_ai_agent import ChattyAIAgent
|
|
41
|
-
from ...models.company.assets.filter_criteria import FilterCriteria
|
|
42
|
-
|
|
43
|
-
if TYPE_CHECKING:
|
|
44
|
-
pass
|
|
45
|
-
|
|
46
|
-
logger = logging.getLogger("AssetsCollections")
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
class AssetsCollections(metaclass=SingletonMeta):
|
|
50
|
-
"""
|
|
51
|
-
Read-only singleton container for accessing asset collections across microservices.
|
|
52
|
-
|
|
53
|
-
This class provides simple read access to various asset types without the overhead
|
|
54
|
-
of the full AssetService (no caching, no events, no write operations).
|
|
55
|
-
|
|
56
|
-
Usage:
|
|
57
|
-
assets = AssetsCollections(connection)
|
|
58
|
-
product = assets.get_product_by_id(product_id)
|
|
59
|
-
tag = assets.get_tag_by_id(tag_id)
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
def __init__(self, connection: MongoConnection):
|
|
63
|
-
"""
|
|
64
|
-
Initialize all asset collections using pre-configured collection subclasses.
|
|
65
|
-
|
|
66
|
-
Args:
|
|
67
|
-
connection: MongoConnection instance to use for database access
|
|
68
|
-
"""
|
|
69
|
-
logger.debug("Initializing AssetsCollections")
|
|
70
|
-
|
|
71
|
-
# Initialize all collections using pre-configured subclasses
|
|
72
|
-
# Each collection subclass already knows its collection name, asset type,
|
|
73
|
-
# preview type, and create_instance_method
|
|
74
|
-
self.products = ProductCollection(connection)
|
|
75
|
-
self.tags = TagCollection(connection)
|
|
76
|
-
self.users = UserCollection(connection)
|
|
77
|
-
self.chats = ChatCollection(connection)
|
|
78
|
-
self.sources = SourceCollection(connection)
|
|
79
|
-
self.flows = FlowCollection(connection)
|
|
80
|
-
self.sales = SaleCollection(connection)
|
|
81
|
-
self.contact_points = ContactPointCollection(connection)
|
|
82
|
-
self.ai_agents = AiAgentCollection(connection)
|
|
83
|
-
self.filter_criterias = FilterCriteriaCollection(connection)
|
|
84
|
-
self.ai_components = AiComponentCollection(connection)
|
|
85
|
-
|
|
86
|
-
logger.debug("AssetsCollections initialized successfully")
|
|
87
|
-
|
|
88
|
-
# Convenience getter methods for easy access
|
|
89
|
-
|
|
90
|
-
async def get_product_by_id(self, id: str) -> Product:
|
|
91
|
-
"""Get a product by ID."""
|
|
92
|
-
return await self.products.get_by_id(id)
|
|
93
|
-
|
|
94
|
-
async def get_tag_by_id(self, id: str) -> Tag:
|
|
95
|
-
"""Get a tag by ID."""
|
|
96
|
-
return await self.tags.get_by_id(id)
|
|
97
|
-
|
|
98
|
-
async def get_user_by_id(self, id: str) -> User:
|
|
99
|
-
"""Get a user by ID."""
|
|
100
|
-
return await self.users.get_by_id(id)
|
|
101
|
-
|
|
102
|
-
async def get_chat_by_id(self, id: str) -> Chat:
|
|
103
|
-
"""Get a chat by ID."""
|
|
104
|
-
return await self.chats.get_by_id(id)
|
|
105
|
-
|
|
106
|
-
async def get_source_by_id(self, id: str) -> SourceBase:
|
|
107
|
-
"""Get a source by ID."""
|
|
108
|
-
return await self.sources.get_by_id(id)
|
|
109
|
-
|
|
110
|
-
async def get_flow_by_id(self, id: str) -> FlowPreview:
|
|
111
|
-
"""Get a flow by ID."""
|
|
112
|
-
return await self.flows.get_by_id(id)
|
|
113
|
-
|
|
114
|
-
async def get_sale_by_id(self, id: str) -> Sale:
|
|
115
|
-
"""Get a sale by ID."""
|
|
116
|
-
return await self.sales.get_by_id(id)
|
|
117
|
-
|
|
118
|
-
async def get_contact_point_by_id(self, id: str) -> ContactPoint:
|
|
119
|
-
"""Get a contact point by ID."""
|
|
120
|
-
return await self.contact_points.get_by_id(id)
|
|
121
|
-
|
|
122
|
-
async def get_ai_agent_by_id(self, id: str) -> ChattyAIAgent:
|
|
123
|
-
"""Get an AI agent by ID."""
|
|
124
|
-
return await self.ai_agents.get_by_id(id)
|
|
125
|
-
|
|
126
|
-
async def get_filter_criteria_by_id(self, id: str) -> FilterCriteria:
|
|
127
|
-
"""Get a filter criteria by ID."""
|
|
128
|
-
return await self.filter_criterias.get_by_id(id)
|
|
129
|
-
|
|
130
|
-
async def get_filter_criterias_by_ids(self, ids: list[str]) -> list[FilterCriteria]:
|
|
131
|
-
"""Get multiple filter criterias by their IDs in a single query."""
|
|
132
|
-
return await self.filter_criterias.get_by_ids(ids=ids)
|
|
133
|
-
|
|
134
|
-
async def get_ai_components_by_ids(self, ids: list[str]) -> list[Any]:
|
|
135
|
-
"""Get multiple AI components by their IDs in a single query."""
|
|
136
|
-
return await self.ai_components.get_by_ids(ids=ids)
|
|
137
|
-
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Asset Collection Subclasses
|
|
3
|
-
|
|
4
|
-
This module provides pre-configured AssetCollection subclasses for each asset type.
|
|
5
|
-
These ensure consistency between the API and microservices by defining the collection
|
|
6
|
-
configuration (collection name, asset type, preview type, create_instance_method) once.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
from .product_collection import ProductCollection
|
|
10
|
-
from .tag_collection import TagCollection
|
|
11
|
-
from .user_collection import UserCollection
|
|
12
|
-
from .chat_collection import ChatCollection
|
|
13
|
-
from .source_collection import SourceCollection
|
|
14
|
-
from .flow_collection import FlowCollection
|
|
15
|
-
from .sale_collection import SaleCollection
|
|
16
|
-
from .contact_point_collection import ContactPointCollection
|
|
17
|
-
from .ai_agent_collection import AiAgentCollection
|
|
18
|
-
from .fast_answer_collection import FastAnswerCollection
|
|
19
|
-
from .topic_collection import TopicCollection
|
|
20
|
-
from .filter_criteria_collection import FilterCriteriaCollection
|
|
21
|
-
from .ai_component_collection import AiComponentCollection
|
|
22
|
-
|
|
23
|
-
__all__ = [
|
|
24
|
-
'ProductCollection',
|
|
25
|
-
'TagCollection',
|
|
26
|
-
'UserCollection',
|
|
27
|
-
'ChatCollection',
|
|
28
|
-
'SourceCollection',
|
|
29
|
-
'FlowCollection',
|
|
30
|
-
'SaleCollection',
|
|
31
|
-
'ContactPointCollection',
|
|
32
|
-
'AiAgentCollection',
|
|
33
|
-
'FastAnswerCollection',
|
|
34
|
-
'TopicCollection',
|
|
35
|
-
'FilterCriteriaCollection',
|
|
36
|
-
'AiComponentCollection',
|
|
37
|
-
]
|
|
38
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"""AI Agent Collection - Pre-configured AssetCollection for AI Agents"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.company.assets.ai_agents_v2.chatty_ai_agent import ChattyAIAgent, ChattyAIAgentPreview
|
|
5
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class AiAgentCollection(AssetCollection[ChattyAIAgent, ChattyAIAgentPreview]):
|
|
9
|
-
"""Pre-configured collection for AI Agent assets"""
|
|
10
|
-
|
|
11
|
-
def __init__(self, connection: MongoConnection):
|
|
12
|
-
super().__init__(
|
|
13
|
-
collection="ai_agents",
|
|
14
|
-
asset_type=ChattyAIAgent,
|
|
15
|
-
connection=connection,
|
|
16
|
-
create_instance_method=ChattyAIAgent.default_create_instance_method,
|
|
17
|
-
preview_type=ChattyAIAgentPreview
|
|
18
|
-
)
|
|
19
|
-
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"""AI Agent In Chat Collection - Pre-configured AssetCollection for AI Agent state in chats"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.company.assets.ai_agents_v2.chatty_ai_agent_in_chat import ChattyAIAgentInChat
|
|
5
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
6
|
-
from typing import Optional
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class AIAgentInChatCollection(AssetCollection[ChattyAIAgentInChat, ChattyAIAgentInChat]):
|
|
10
|
-
"""
|
|
11
|
-
Pre-configured collection for AI Agent In Chat state.
|
|
12
|
-
|
|
13
|
-
This is a standalone collection (not embedded in Chat) that allows Lambda to
|
|
14
|
-
manage AI agent state independently without loading entire chat documents.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
def __init__(self, connection: MongoConnection):
|
|
18
|
-
super().__init__(
|
|
19
|
-
collection="chatty_ai_agents_in_chat",
|
|
20
|
-
asset_type=ChattyAIAgentInChat,
|
|
21
|
-
connection=connection,
|
|
22
|
-
create_instance_method=lambda doc: ChattyAIAgentInChat(**doc),
|
|
23
|
-
preview_type=ChattyAIAgentInChat # No separate preview type needed
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
async def get_by_chat_id(self, chat_id: str) -> Optional[ChattyAIAgentInChat]:
|
|
27
|
-
"""Get AI agent state by chat ID, or None if not found"""
|
|
28
|
-
doc = await self.async_collection.find_one({"chat_id": chat_id, "deleted_at": None})
|
|
29
|
-
if not doc:
|
|
30
|
-
return None
|
|
31
|
-
return self.create_instance(doc)
|
|
32
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"""AI Component Collection - Pre-configured AssetCollection for AI Components"""
|
|
2
|
-
|
|
3
|
-
from typing import Any
|
|
4
|
-
from ..asset_service import AssetCollection
|
|
5
|
-
from ....models.base_models.ai_agent_component import AiAgentComponent, AiAgentComponentPreview
|
|
6
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
7
|
-
from ....services.ai_components_service import AiComponentsService
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class AiComponentCollection(AssetCollection[AiAgentComponent, AiAgentComponentPreview]):
|
|
11
|
-
"""Pre-configured collection for AI Component assets"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, connection: MongoConnection):
|
|
14
|
-
super().__init__(
|
|
15
|
-
collection="ai_components",
|
|
16
|
-
asset_type=AiAgentComponent,
|
|
17
|
-
connection=connection,
|
|
18
|
-
create_instance_method=AiComponentsService.instantiate_component,
|
|
19
|
-
preview_type=AiAgentComponentPreview
|
|
20
|
-
)
|
|
21
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"""Chain of Thought Collection - Pre-configured AssetCollection for Chain of Thoughts"""
|
|
2
|
-
|
|
3
|
-
from typing import Any, List, Dict
|
|
4
|
-
|
|
5
|
-
from letschatty.models.utils.types.serializer_type import SerializerType
|
|
6
|
-
from ..asset_service import AssetCollection, StrObjectId
|
|
7
|
-
from ....models.company.assets.ai_agents_v2.chain_of_thought_in_chat import (
|
|
8
|
-
ChainOfThoughtInChat,
|
|
9
|
-
ChainOfThoughtInChatPreview
|
|
10
|
-
)
|
|
11
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class ChainOfThoughtCollection(AssetCollection[ChainOfThoughtInChat, ChainOfThoughtInChatPreview]):
|
|
15
|
-
"""Pre-configured collection for Chain of Thought"""
|
|
16
|
-
|
|
17
|
-
def __init__(self, connection: MongoConnection):
|
|
18
|
-
super().__init__(
|
|
19
|
-
collection="chain_of_thoughts",
|
|
20
|
-
asset_type=ChainOfThoughtInChat,
|
|
21
|
-
connection=connection,
|
|
22
|
-
create_instance_method=lambda doc: ChainOfThoughtInChat(**doc),
|
|
23
|
-
preview_type=ChainOfThoughtInChatPreview
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
async def get_by_chat_id(self, chat_id: StrObjectId, skip: int = 0, limit: int = 10) -> List[Dict[str, Any]]:
|
|
27
|
-
"""Get chain of thoughts by chat ID, sorted by created_at (newest first)"""
|
|
28
|
-
cursor = self.async_collection.find({"chat_id": chat_id, "deleted_at": None}).sort("created_at", -1).skip(skip).limit(limit)
|
|
29
|
-
cot_docs = await cursor.to_list(length=None)
|
|
30
|
-
return [self.create_instance(cot_doc).model_dump_json(serializer=SerializerType.FRONTEND) for cot_doc in cot_docs]
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"""Chat Collection - Pre-configured AssetCollection for Chats"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.chat.chat import Chat
|
|
5
|
-
from ....models.base_models import ChattyAssetPreview
|
|
6
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
7
|
-
from ....services.factories.chats.chat_factory import ChatFactory
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class ChatCollection(AssetCollection[Chat, ChattyAssetPreview]):
|
|
11
|
-
"""Pre-configured collection for Chat assets"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, connection: MongoConnection):
|
|
14
|
-
super().__init__(
|
|
15
|
-
collection="chats",
|
|
16
|
-
asset_type=Chat,
|
|
17
|
-
connection=connection,
|
|
18
|
-
create_instance_method=ChatFactory.from_json,
|
|
19
|
-
preview_type=None
|
|
20
|
-
)
|
|
21
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"""Contact Point Collection - Pre-configured AssetCollection for Contact Points"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.company.assets.contact_point import ContactPoint
|
|
5
|
-
from ....models.base_models import ChattyAssetPreview
|
|
6
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
7
|
-
from ....services.factories.analytics.contact_point_factory import ContactPointFactory
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class ContactPointCollection(AssetCollection[ContactPoint, ChattyAssetPreview]):
|
|
11
|
-
"""Pre-configured collection for ContactPoint assets"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, connection: MongoConnection):
|
|
14
|
-
super().__init__(
|
|
15
|
-
collection="contact_points",
|
|
16
|
-
asset_type=ContactPoint,
|
|
17
|
-
connection=connection,
|
|
18
|
-
create_instance_method=ContactPointFactory.instantiate_contact_point,
|
|
19
|
-
preview_type=None
|
|
20
|
-
)
|
|
21
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"""FastAnswer Collection - Pre-configured AssetCollection for Fast Answers"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.company.assets import ChattyFastAnswer
|
|
5
|
-
from ....models.base_models import ChattyAssetPreview
|
|
6
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
7
|
-
from ...factories.chatty_fast_answers.chatty_fast_answers_factory import ChattyFastAnswersFactory
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class FastAnswerCollection(AssetCollection[ChattyFastAnswer, ChattyAssetPreview]):
|
|
11
|
-
"""Pre-configured collection for Fast Answer assets"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, connection: MongoConnection):
|
|
14
|
-
super().__init__(
|
|
15
|
-
collection="fast_answers",
|
|
16
|
-
asset_type=ChattyFastAnswer,
|
|
17
|
-
connection=connection,
|
|
18
|
-
create_instance_method=ChattyFastAnswersFactory.create,
|
|
19
|
-
preview_type=ChattyAssetPreview
|
|
20
|
-
)
|
|
21
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"""Filter Criteria Collection - Pre-configured AssetCollection for Filter Criterias"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.company.assets.filter_criteria import FilterCriteria, FilterCriteriaPreview
|
|
5
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class FilterCriteriaCollection(AssetCollection[FilterCriteria, FilterCriteriaPreview]):
|
|
9
|
-
"""Pre-configured collection for Filter Criteria assets"""
|
|
10
|
-
|
|
11
|
-
def __init__(self, connection: MongoConnection):
|
|
12
|
-
super().__init__(
|
|
13
|
-
collection="filter_criterias",
|
|
14
|
-
asset_type=FilterCriteria,
|
|
15
|
-
connection=connection,
|
|
16
|
-
create_instance_method=FilterCriteria.default_create_instance_method,
|
|
17
|
-
preview_type=FilterCriteriaPreview
|
|
18
|
-
)
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"""Flow Collection - Pre-configured AssetCollection for Flows"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.company.assets.flow import FlowPreview
|
|
5
|
-
from ....models.base_models import ChattyAssetPreview
|
|
6
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class FlowCollection(AssetCollection[FlowPreview, ChattyAssetPreview]):
|
|
10
|
-
"""Pre-configured collection for Flow assets"""
|
|
11
|
-
|
|
12
|
-
def __init__(self, connection: MongoConnection):
|
|
13
|
-
super().__init__(
|
|
14
|
-
collection="flows",
|
|
15
|
-
asset_type=FlowPreview,
|
|
16
|
-
connection=connection,
|
|
17
|
-
create_instance_method=FlowPreview.default_create_instance_method,
|
|
18
|
-
preview_type=None
|
|
19
|
-
)
|
|
20
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"""Product Collection - Pre-configured AssetCollection for Products"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.company.assets.product import Product, ProductPreview
|
|
5
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
6
|
-
from ....services.factories.product_factory import ProductFactory
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class ProductCollection(AssetCollection[Product, ProductPreview]):
|
|
10
|
-
"""Pre-configured collection for Product assets"""
|
|
11
|
-
|
|
12
|
-
def __init__(self, connection: MongoConnection):
|
|
13
|
-
super().__init__(
|
|
14
|
-
collection="products",
|
|
15
|
-
asset_type=Product,
|
|
16
|
-
connection=connection,
|
|
17
|
-
create_instance_method=ProductFactory.create_product,
|
|
18
|
-
preview_type=ProductPreview
|
|
19
|
-
)
|
|
20
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"""Sale Collection - Pre-configured AssetCollection for Sales"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.company.assets.sale import Sale
|
|
5
|
-
from ....models.base_models import ChattyAssetPreview
|
|
6
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class SaleCollection(AssetCollection[Sale, ChattyAssetPreview]):
|
|
10
|
-
"""Pre-configured collection for Sale assets"""
|
|
11
|
-
|
|
12
|
-
def __init__(self, connection: MongoConnection):
|
|
13
|
-
super().__init__(
|
|
14
|
-
collection="sales",
|
|
15
|
-
asset_type=Sale,
|
|
16
|
-
connection=connection,
|
|
17
|
-
create_instance_method=Sale.default_create_instance_method,
|
|
18
|
-
preview_type=None
|
|
19
|
-
)
|
|
20
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"""Source Collection - Pre-configured AssetCollection for Sources"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.analytics.sources import SourceBase
|
|
5
|
-
from ....models.base_models import ChattyAssetPreview
|
|
6
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
7
|
-
from ....services.factories.analytics.sources.source_factory import SourceFactory
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class SourceCollection(AssetCollection[SourceBase, ChattyAssetPreview]):
|
|
11
|
-
"""Pre-configured collection for Source assets"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, connection: MongoConnection):
|
|
14
|
-
super().__init__(
|
|
15
|
-
collection="sources",
|
|
16
|
-
asset_type=SourceBase,
|
|
17
|
-
connection=connection,
|
|
18
|
-
create_instance_method=SourceFactory.instantiate_source,
|
|
19
|
-
preview_type=None
|
|
20
|
-
)
|
|
21
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"""Tag Collection - Pre-configured AssetCollection for Tags"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.company.assets.tag import Tag, TagPreview
|
|
5
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class TagCollection(AssetCollection[Tag, TagPreview]):
|
|
9
|
-
"""Pre-configured collection for Tag assets"""
|
|
10
|
-
|
|
11
|
-
def __init__(self, connection: MongoConnection):
|
|
12
|
-
super().__init__(
|
|
13
|
-
collection="tags",
|
|
14
|
-
asset_type=Tag,
|
|
15
|
-
connection=connection,
|
|
16
|
-
create_instance_method=Tag.default_create_instance_method,
|
|
17
|
-
preview_type=TagPreview
|
|
18
|
-
)
|
|
19
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"""Topic Collection - Pre-configured AssetCollection for Topics"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.analytics.smart_messages.topic import Topic
|
|
5
|
-
from ....models.base_models import ChattyAssetPreview
|
|
6
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
7
|
-
from ...factories.analytics.smart_messages.topics_factory import TopicFactory
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class TopicCollection(AssetCollection[Topic, ChattyAssetPreview]):
|
|
11
|
-
"""Pre-configured collection for Topic assets"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, connection: MongoConnection):
|
|
14
|
-
super().__init__(
|
|
15
|
-
collection="topics",
|
|
16
|
-
asset_type=Topic,
|
|
17
|
-
connection=connection,
|
|
18
|
-
create_instance_method=TopicFactory.instantiate_topic,
|
|
19
|
-
preview_type=ChattyAssetPreview
|
|
20
|
-
)
|
|
21
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"""User Collection - Pre-configured AssetCollection for Users"""
|
|
2
|
-
|
|
3
|
-
from ..asset_service import AssetCollection
|
|
4
|
-
from ....models.company.assets.users.user import User, UserPreview
|
|
5
|
-
from ....models.data_base.mongo_connection import MongoConnection
|
|
6
|
-
from ....services.users.user_factory import UserFactory
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class UserCollection(AssetCollection[User, UserPreview]):
|
|
10
|
-
"""Pre-configured collection for User assets"""
|
|
11
|
-
|
|
12
|
-
def __init__(self, connection: MongoConnection):
|
|
13
|
-
super().__init__(
|
|
14
|
-
collection="users",
|
|
15
|
-
asset_type=User,
|
|
16
|
-
connection=connection,
|
|
17
|
-
create_instance_method=UserFactory.instantiate_user,
|
|
18
|
-
preview_type=UserPreview
|
|
19
|
-
)
|
|
20
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Example usage of the AssetsCollections class
|
|
3
|
-
|
|
4
|
-
This file demonstrates how to use the read-only AssetsCollections container
|
|
5
|
-
in a microservice.
|
|
6
|
-
"""
|
|
7
|
-
from .assets_collections import AssetsCollections
|
|
8
|
-
from ...models.data_base.mongo_connection import MongoConnection
|
|
9
|
-
|
|
10
|
-
# Example: How to use AssetsCollections in a microservice
|
|
11
|
-
|
|
12
|
-
def example_usage():
|
|
13
|
-
"""
|
|
14
|
-
Example of how to use AssetsCollections in your microservice.
|
|
15
|
-
"""
|
|
16
|
-
# Initialize the connection (typically this would be a singleton in your microservice)
|
|
17
|
-
connection = MongoConnection()
|
|
18
|
-
|
|
19
|
-
# Get the singleton instance
|
|
20
|
-
assets = AssetsCollections(connection)
|
|
21
|
-
|
|
22
|
-
# Read assets by ID
|
|
23
|
-
# product = assets.get_product_by_id("some_product_id")
|
|
24
|
-
# tag = assets.get_tag_by_id("some_tag_id")
|
|
25
|
-
# user = assets.get_user_by_id("some_user_id")
|
|
26
|
-
# chat = assets.get_chat_by_id("some_chat_id")
|
|
27
|
-
# source = assets.get_source_by_id("some_source_id")
|
|
28
|
-
# flow = assets.get_flow_by_id("some_flow_id")
|
|
29
|
-
# sale = assets.get_sale_by_id("some_sale_id")
|
|
30
|
-
# contact_point = assets.get_contact_point_by_id("some_contact_point_id")
|
|
31
|
-
# ai_agent = assets.get_ai_agent_by_id("some_ai_agent_id")
|
|
32
|
-
|
|
33
|
-
# Or access the collections directly for more advanced queries
|
|
34
|
-
# all_products = assets.products.get_docs(query={"active": True}, company_id="some_company_id")
|
|
35
|
-
|
|
36
|
-
print("AssetsCollections initialized and ready to use!")
|
|
37
|
-
|
|
38
|
-
# Note: This is read-only. No insert, update, or delete operations are available.
|
|
39
|
-
# For write operations, use the full AssetService classes in the API.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if __name__ == "__main__":
|
|
43
|
-
example_usage()
|
|
44
|
-
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Pre-configured Asset Services
|
|
3
|
-
|
|
4
|
-
This module provides ready-to-use AssetService subclasses for each asset type.
|
|
5
|
-
These services include the collection configuration and default cache settings.
|
|
6
|
-
|
|
7
|
-
API implementations can extend these to add business logic (events, validation, etc.)
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from .product_service import ProductService
|
|
11
|
-
from .tag_service import TagService
|
|
12
|
-
from .user_service import UserService
|
|
13
|
-
from .chat_service import ChatService
|
|
14
|
-
from .source_service import SourceService
|
|
15
|
-
from .flow_service import FlowService
|
|
16
|
-
from .sale_service import SaleService
|
|
17
|
-
from .contact_point_service import ContactPointService
|
|
18
|
-
from .ai_agent_service import AiAgentService
|
|
19
|
-
from .fast_answer_service import FastAnswerService
|
|
20
|
-
from .topic_service import TopicService
|
|
21
|
-
from .filter_criteria_service import FilterCriteriaService
|
|
22
|
-
|
|
23
|
-
__all__ = [
|
|
24
|
-
'ProductService',
|
|
25
|
-
'TagService',
|
|
26
|
-
'UserService',
|
|
27
|
-
'ChatService',
|
|
28
|
-
'SourceService',
|
|
29
|
-
'FlowService',
|
|
30
|
-
'SaleService',
|
|
31
|
-
'ContactPointService',
|
|
32
|
-
'AiAgentService',
|
|
33
|
-
'FastAnswerService',
|
|
34
|
-
'TopicService',
|
|
35
|
-
'FilterCriteriaService',
|
|
36
|
-
]
|
|
37
|
-
|