letschatty 0.4.350__py3-none-any.whl → 0.4.352__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 (92) hide show
  1. letschatty/models/ai_microservices/__init__.py +4 -4
  2. letschatty/models/ai_microservices/expected_output.py +2 -29
  3. letschatty/models/ai_microservices/lambda_events.py +28 -155
  4. letschatty/models/ai_microservices/lambda_invokation_types.py +1 -4
  5. letschatty/models/ai_microservices/n8n_ai_agents_payload.py +1 -3
  6. letschatty/models/analytics/events/__init__.py +3 -3
  7. letschatty/models/analytics/events/chat_based_events/chat_client.py +19 -0
  8. letschatty/models/analytics/events/chat_based_events/chat_funnel.py +69 -13
  9. letschatty/models/analytics/events/company_based_events/asset_events.py +9 -2
  10. letschatty/models/analytics/events/event_type_to_classes.py +7 -3
  11. letschatty/models/analytics/events/event_types.py +11 -50
  12. letschatty/models/chat/chat.py +13 -2
  13. letschatty/models/chat/chat_with_assets.py +6 -1
  14. letschatty/models/chat/client.py +0 -2
  15. letschatty/models/chat/continuous_conversation.py +1 -1
  16. letschatty/models/company/CRM/funnel.py +365 -33
  17. letschatty/models/company/__init__.py +10 -1
  18. letschatty/models/company/assets/ai_agents_v2/ai_agents_decision_output.py +1 -1
  19. letschatty/models/company/assets/ai_agents_v2/chatty_ai_agent_in_chat.py +0 -4
  20. letschatty/models/company/assets/ai_agents_v2/chatty_ai_mode.py +2 -2
  21. letschatty/models/company/assets/ai_agents_v2/get_chat_with_prompt_response.py +0 -1
  22. letschatty/models/company/assets/ai_agents_v2/pre_qualify_config.py +1 -29
  23. letschatty/models/company/assets/automation.py +10 -19
  24. letschatty/models/company/assets/chat_assets.py +3 -2
  25. letschatty/models/company/assets/company_assets.py +2 -0
  26. letschatty/models/company/assets/sale.py +3 -3
  27. letschatty/models/company/empresa.py +4 -1
  28. letschatty/models/company/integrations/product_sync_status.py +28 -0
  29. letschatty/models/company/integrations/shopify/company_shopify_integration.py +62 -0
  30. letschatty/models/company/integrations/shopify/shopify_product_sync_status.py +18 -0
  31. letschatty/models/company/integrations/shopify/shopify_webhook_topics.py +40 -0
  32. letschatty/models/company/integrations/sync_status_enum.py +9 -0
  33. letschatty/models/company/integrations/tienda_nube/company_tienda_nube_integration.py +62 -0
  34. letschatty/models/company/integrations/tienda_nube/tienda_nube_product_sync_status.py +18 -0
  35. letschatty/models/company/integrations/tienda_nube/tienda_nube_webhook_topics.py +46 -0
  36. letschatty/models/data_base/collection_interface.py +29 -101
  37. letschatty/models/data_base/mongo_connection.py +9 -92
  38. letschatty/models/messages/chatty_messages/schema/chatty_content/content_document.py +4 -2
  39. letschatty/models/messages/chatty_messages/schema/chatty_content/content_media.py +4 -3
  40. letschatty/models/utils/custom_exceptions/custom_exceptions.py +1 -14
  41. letschatty/services/ai_agents/smart_follow_up_context_builder_v2.py +2 -5
  42. letschatty/services/chat/chat_service.py +47 -11
  43. letschatty/services/chatty_assets/__init__.py +0 -12
  44. letschatty/services/chatty_assets/asset_service.py +13 -190
  45. letschatty/services/chatty_assets/base_container.py +2 -3
  46. letschatty/services/chatty_assets/base_container_with_collection.py +26 -35
  47. letschatty/services/continuous_conversation_service/continuous_conversation_helper.py +0 -11
  48. letschatty/services/events/events_manager.py +1 -218
  49. letschatty/services/factories/analytics/events_factory.py +30 -66
  50. letschatty/services/factories/lambda_ai_orchestrartor/lambda_events_factory.py +8 -46
  51. letschatty/services/messages_helpers/get_caption_or_body_or_preview.py +4 -6
  52. letschatty/services/validators/analytics_validator.py +11 -0
  53. {letschatty-0.4.350.dist-info → letschatty-0.4.352.dist-info}/METADATA +1 -1
  54. {letschatty-0.4.350.dist-info → letschatty-0.4.352.dist-info}/RECORD +56 -83
  55. letschatty/models/analytics/events/chat_based_events/ai_agent_execution_event.py +0 -71
  56. letschatty/services/chatty_assets/assets_collections.py +0 -137
  57. letschatty/services/chatty_assets/collections/__init__.py +0 -38
  58. letschatty/services/chatty_assets/collections/ai_agent_collection.py +0 -19
  59. letschatty/services/chatty_assets/collections/ai_agent_in_chat_collection.py +0 -32
  60. letschatty/services/chatty_assets/collections/ai_component_collection.py +0 -21
  61. letschatty/services/chatty_assets/collections/chain_of_thought_collection.py +0 -30
  62. letschatty/services/chatty_assets/collections/chat_collection.py +0 -21
  63. letschatty/services/chatty_assets/collections/contact_point_collection.py +0 -21
  64. letschatty/services/chatty_assets/collections/fast_answer_collection.py +0 -21
  65. letschatty/services/chatty_assets/collections/filter_criteria_collection.py +0 -18
  66. letschatty/services/chatty_assets/collections/flow_collection.py +0 -20
  67. letschatty/services/chatty_assets/collections/product_collection.py +0 -20
  68. letschatty/services/chatty_assets/collections/sale_collection.py +0 -20
  69. letschatty/services/chatty_assets/collections/source_collection.py +0 -21
  70. letschatty/services/chatty_assets/collections/tag_collection.py +0 -19
  71. letschatty/services/chatty_assets/collections/topic_collection.py +0 -21
  72. letschatty/services/chatty_assets/collections/user_collection.py +0 -20
  73. letschatty/services/chatty_assets/example_usage.py +0 -44
  74. letschatty/services/chatty_assets/services/__init__.py +0 -37
  75. letschatty/services/chatty_assets/services/ai_agent_in_chat_service.py +0 -73
  76. letschatty/services/chatty_assets/services/ai_agent_service.py +0 -23
  77. letschatty/services/chatty_assets/services/chain_of_thought_service.py +0 -70
  78. letschatty/services/chatty_assets/services/chat_service.py +0 -25
  79. letschatty/services/chatty_assets/services/contact_point_service.py +0 -29
  80. letschatty/services/chatty_assets/services/fast_answer_service.py +0 -32
  81. letschatty/services/chatty_assets/services/filter_criteria_service.py +0 -30
  82. letschatty/services/chatty_assets/services/flow_service.py +0 -25
  83. letschatty/services/chatty_assets/services/product_service.py +0 -30
  84. letschatty/services/chatty_assets/services/sale_service.py +0 -25
  85. letschatty/services/chatty_assets/services/source_service.py +0 -28
  86. letschatty/services/chatty_assets/services/tag_service.py +0 -32
  87. letschatty/services/chatty_assets/services/topic_service.py +0 -31
  88. letschatty/services/chatty_assets/services/user_service.py +0 -32
  89. letschatty/services/events/__init__.py +0 -6
  90. letschatty/services/factories/analytics/ai_agent_event_factory.py +0 -161
  91. {letschatty-0.4.350.dist-info → letschatty-0.4.352.dist-info}/LICENSE +0 -0
  92. {letschatty-0.4.350.dist-info → letschatty-0.4.352.dist-info}/WHEEL +0 -0
@@ -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
-
@@ -1,73 +0,0 @@
1
- """AI Agent In Chat Service - Pre-configured AssetService for CRUD operations only"""
2
-
3
- from datetime import datetime
4
- from zoneinfo import ZoneInfo
5
- from typing import Optional
6
- from ..asset_service import AssetService, CacheConfig
7
- from ..collections.ai_agent_in_chat_collection import AIAgentInChatCollection
8
- from ....models.company.assets.ai_agents_v2.chatty_ai_agent_in_chat import ChattyAIAgentInChat
9
- from ....models.data_base.mongo_connection import MongoConnection
10
- from ....models.utils.types.identifier import StrObjectId
11
- import logging
12
-
13
- logger = logging.getLogger(__name__)
14
-
15
-
16
- class AIAgentInChatService(AssetService[ChattyAIAgentInChat, ChattyAIAgentInChat]):
17
- """
18
- Pre-configured service for AI Agent In Chat CRUD operations.
19
-
20
- For business logic operations (set_to_processing, escalate, etc.),
21
- use AIAgentInChatEditor instead.
22
-
23
- No events needed - this is operational state, not a business asset.
24
- """
25
-
26
- def __init__(
27
- self,
28
- connection: MongoConnection,
29
- cache_config: CacheConfig = CacheConfig(
30
- keep_items_always_in_memory=False,
31
- keep_previews_always_in_memory=False
32
- )
33
- ):
34
- collection = AIAgentInChatCollection(connection)
35
- super().__init__(
36
- collection=collection,
37
- cache_config=cache_config
38
- )
39
-
40
- collection: AIAgentInChatCollection # Type annotation for better type checking
41
-
42
- async def get_by_chat_id(self, chat_id: StrObjectId) -> Optional[ChattyAIAgentInChat]:
43
- """Get AI agent state for a chat"""
44
- return await self.collection.get_by_chat_id(chat_id)
45
-
46
- async def update(self, ai_agent_in_chat: ChattyAIAgentInChat) -> ChattyAIAgentInChat:
47
- """Update AI agent state"""
48
- ai_agent_in_chat.updated_at = datetime.now(ZoneInfo("UTC"))
49
- ai_agent_dict = ai_agent_in_chat.model_dump(by_alias=True, exclude_none=False)
50
- # Remove _id field as it's immutable in MongoDB
51
- ai_agent_dict.pop('_id', None)
52
- result = await self.collection.async_collection.update_one(
53
- {"chat_id": ai_agent_in_chat.chat_id},
54
- {"$set": ai_agent_dict}
55
- )
56
- if result.matched_count == 0:
57
- raise ValueError(f"AI agent state for chat {ai_agent_in_chat.chat_id} not found")
58
- return ai_agent_in_chat
59
-
60
- async def create(self, ai_agent_in_chat: ChattyAIAgentInChat) -> ChattyAIAgentInChat:
61
- """Create new AI agent state"""
62
- ai_agent_dict = ai_agent_in_chat.model_dump(by_alias=True, exclude_none=False)
63
- result = await self.collection.async_collection.insert_one(ai_agent_dict)
64
- if not result.inserted_id:
65
- raise Exception(f"Failed to create AI agent state for chat {ai_agent_in_chat.chat_id}")
66
- return ai_agent_in_chat
67
-
68
- async def delete(self, chat_id: StrObjectId) -> None:
69
- """Delete AI agent state"""
70
- result = await self.collection.async_collection.delete_one({"chat_id": chat_id})
71
- if result.deleted_count == 0:
72
- raise ValueError(f"AI agent state for chat {chat_id} not found")
73
-
@@ -1,23 +0,0 @@
1
- """AI Agent Service - Pre-configured AssetService for AI Agents"""
2
-
3
- from ..asset_service import AssetService, CacheConfig
4
- from ..collections import AiAgentCollection
5
- from ....models.company.assets.ai_agents_v2.chatty_ai_agent import ChattyAIAgent, ChattyAIAgentPreview
6
- from ....models.data_base.mongo_connection import MongoConnection
7
-
8
-
9
- class AiAgentService(AssetService[ChattyAIAgent, ChattyAIAgentPreview]):
10
- """Pre-configured service for AI Agent assets with sensible defaults"""
11
-
12
- def __init__(self,
13
- connection: MongoConnection,
14
- cache_config: CacheConfig = CacheConfig(
15
- keep_items_always_in_memory=False,
16
- keep_previews_always_in_memory=True
17
- )):
18
- collection = AiAgentCollection(connection)
19
- super().__init__(
20
- collection=collection,
21
- cache_config=cache_config
22
- )
23
-
@@ -1,70 +0,0 @@
1
- """Chain Of Thought Service - Pre-configured AssetService for CRUD operations only"""
2
-
3
- from datetime import datetime
4
- from zoneinfo import ZoneInfo
5
- from typing import List, Optional
6
- from ..asset_service import AssetService, CacheConfig
7
- from ..collections.chain_of_thought_collection import ChainOfThoughtCollection
8
- from ....models.company.assets.ai_agents_v2.chain_of_thought_in_chat import ChainOfThoughtInChat
9
- from ....models.data_base.mongo_connection import MongoConnection
10
- from ....models.utils.types.identifier import StrObjectId
11
- from ....models.utils.types.serializer_type import SerializerType
12
- from bson import ObjectId
13
- import logging
14
-
15
- logger = logging.getLogger(__name__)
16
-
17
-
18
- class ChainOfThoughtService(AssetService[ChainOfThoughtInChat, ChainOfThoughtInChat]):
19
- """
20
- Pre-configured service for Chain Of Thought CRUD operations.
21
-
22
- For business logic operations (create for N8N, set as failed, etc.),
23
- use ChainOfThoughtsEditor instead.
24
-
25
- No events needed - this is execution state, not a business asset.
26
- """
27
-
28
- def __init__(
29
- self,
30
- connection: MongoConnection,
31
- cache_config: CacheConfig = CacheConfig(
32
- keep_items_always_in_memory=False,
33
- keep_previews_always_in_memory=False
34
- )
35
- ):
36
- collection = ChainOfThoughtCollection(connection)
37
- super().__init__(
38
- collection=collection,
39
- cache_config=cache_config
40
- )
41
-
42
- collection: ChainOfThoughtCollection # Type annotation for better type checking
43
-
44
- async def get_by_chat_id(self, chat_id: StrObjectId, skip: int = 0, limit: int = 10) -> List[ChainOfThoughtInChat]:
45
- """Get chain of thoughts by chat ID, sorted by created_at (newest first)"""
46
- return await self.collection.get_by_chat_id(chat_id=chat_id, skip=skip, limit=limit)
47
-
48
- async def get_by_id(self, cot_id: StrObjectId) -> Optional[ChainOfThoughtInChat]:
49
- """Get chain of thought by ID"""
50
- return await self.collection.get_by_id(cot_id)
51
-
52
- async def create(self, cot: ChainOfThoughtInChat) -> ChainOfThoughtInChat:
53
- """Create new chain of thought"""
54
- cot_dict = cot.model_dump(by_alias=True, exclude_none=False)
55
- result = await self.collection.async_collection.insert_one(cot_dict)
56
- if not result.inserted_id:
57
- raise Exception(f"Failed to create chain of thought {cot.id}")
58
- return cot
59
-
60
- async def update(self, cot: ChainOfThoughtInChat) -> ChainOfThoughtInChat:
61
- """Update chain of thought"""
62
- cot.updated_at = datetime.now(ZoneInfo("UTC"))
63
- cot_dict = cot.model_dump(by_alias=True, exclude_none=False)
64
- result = await self.collection.async_collection.update_one(
65
- {"_id": cot.id},
66
- {"$set": cot_dict}
67
- )
68
- if result.matched_count == 0:
69
- raise ValueError(f"Chain of thought {cot.id} not found")
70
- return cot
@@ -1,25 +0,0 @@
1
- """Chat Service - Pre-configured AssetService for Chats"""
2
-
3
- from ..asset_service import AssetService, CacheConfig
4
- from ..collections import ChatCollection
5
- from ....models.chat.chat import Chat
6
- from ....models.base_models import ChattyAssetPreview
7
- from ....models.data_base.mongo_connection import MongoConnection
8
-
9
-
10
- class ChatService(AssetService[Chat, ChattyAssetPreview]):
11
- """
12
- Pre-configured service for Chat assets with sensible defaults.
13
-
14
- Note: No event configuration - Chat events are handled by ChatsEditor, not AssetService.
15
- """
16
-
17
- def __init__(self,
18
- connection: MongoConnection,
19
- cache_config: CacheConfig = CacheConfig.default()):
20
- collection = ChatCollection(connection)
21
- super().__init__(
22
- collection=collection,
23
- cache_config=cache_config
24
- )
25
-
@@ -1,29 +0,0 @@
1
- """Contact Point Service - Pre-configured AssetService for Contact Points"""
2
-
3
- from ..asset_service import AssetService, CacheConfig
4
- from ..collections import ContactPointCollection
5
- from ....models.company.assets.contact_point import ContactPoint
6
- from ....models.base_models import ChattyAssetPreview
7
- from ....models.data_base.mongo_connection import MongoConnection
8
-
9
-
10
- class ContactPointService(AssetService[ContactPoint, ChattyAssetPreview]):
11
- """
12
- Pre-configured service for ContactPoint assets with sensible defaults.
13
-
14
- Note: No event configuration - ContactPoint events are managed separately by the contact points system.
15
- """
16
-
17
- def __init__(self,
18
- connection: MongoConnection,
19
- cache_config: CacheConfig = CacheConfig(
20
- keep_items_always_in_memory=False,
21
- keep_previews_always_in_memory=False,
22
- cache_expiration_time=0
23
- )):
24
- collection = ContactPointCollection(connection)
25
- super().__init__(
26
- collection=collection,
27
- cache_config=cache_config
28
- )
29
-
@@ -1,32 +0,0 @@
1
- """Fast Answer Service - Pre-configured AssetService for Fast Answers"""
2
-
3
- from ..asset_service import AssetService, CacheConfig
4
- from ..collections.fast_answer_collection import FastAnswerCollection
5
- from ....models.company.assets import ChattyFastAnswer
6
- from ....models.base_models import ChattyAssetPreview
7
- from ....models.data_base.mongo_connection import MongoConnection
8
- from ....models.analytics.events import CompanyAssetType, EventType
9
-
10
-
11
- class FastAnswerService(AssetService[ChattyFastAnswer, ChattyAssetPreview]):
12
- """Pre-configured service for Fast Answer assets with sensible defaults"""
13
-
14
- # Event configuration - enables automatic event handling in API
15
- asset_type_enum = CompanyAssetType.FAST_ANSWERS
16
- event_type_created = EventType.FAST_ANSWER_CREATED
17
- event_type_updated = EventType.FAST_ANSWER_UPDATED
18
- event_type_deleted = EventType.FAST_ANSWER_DELETED
19
-
20
- def __init__(self,
21
- connection: MongoConnection,
22
- cache_config: CacheConfig = CacheConfig(
23
- keep_items_always_in_memory=False,
24
- cache_expiration_time=60*30, # 30 minutes
25
- keep_previews_always_in_memory=True
26
- )):
27
- collection = FastAnswerCollection(connection)
28
- super().__init__(
29
- collection=collection,
30
- cache_config=cache_config
31
- )
32
-
@@ -1,30 +0,0 @@
1
- """Filter Criteria Service - Pre-configured AssetService for Filter Criterias"""
2
-
3
- from ..asset_service import AssetService, CacheConfig
4
- from ..collections import FilterCriteriaCollection
5
- from ....models.company.assets.filter_criteria import FilterCriteria, FilterCriteriaPreview
6
- from ....models.data_base.mongo_connection import MongoConnection
7
- from ....models.analytics.events import CompanyAssetType, EventType
8
-
9
-
10
- class FilterCriteriaService(AssetService[FilterCriteria, FilterCriteriaPreview]):
11
- """Pre-configured service for Filter Criteria assets with sensible defaults"""
12
-
13
- # Event configuration - enables automatic event handling in API
14
- asset_type_enum = CompanyAssetType.FILTER_CRITERIA
15
- event_type_created = EventType.FILTER_CRITERIA_CREATED
16
- event_type_updated = EventType.FILTER_CRITERIA_UPDATED
17
- event_type_deleted = EventType.FILTER_CRITERIA_DELETED
18
-
19
- def __init__(self,
20
- connection: MongoConnection,
21
- cache_config: CacheConfig = CacheConfig(
22
- keep_items_always_in_memory=False,
23
- keep_previews_always_in_memory=True
24
- )):
25
- collection = FilterCriteriaCollection(connection)
26
- super().__init__(
27
- collection=collection,
28
- cache_config=cache_config
29
- )
30
-