solace-agent-mesh 1.4.12__py3-none-any.whl → 1.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of solace-agent-mesh might be problematic. Click here for more details.
- solace_agent_mesh/agent/adk/adk_llm.txt +3 -4
- solace_agent_mesh/agent/adk/adk_llm_detail.txt +566 -0
- solace_agent_mesh/agent/adk/artifacts/artifacts_llm.txt +1 -1
- solace_agent_mesh/agent/adk/callbacks.py +51 -2
- solace_agent_mesh/agent/adk/models/lite_llm.py +1 -0
- solace_agent_mesh/agent/adk/models/models_llm.txt +1 -2
- solace_agent_mesh/agent/agent_llm.txt +1 -1
- solace_agent_mesh/agent/agent_llm_detail.txt +1702 -0
- solace_agent_mesh/agent/protocol/event_handlers.py +2 -13
- solace_agent_mesh/agent/protocol/protocol_llm.txt +15 -2
- solace_agent_mesh/agent/protocol/protocol_llm_detail.txt +92 -0
- solace_agent_mesh/agent/sac/component.py +51 -21
- solace_agent_mesh/agent/sac/sac_llm.txt +15 -1
- solace_agent_mesh/agent/sac/sac_llm_detail.txt +200 -0
- solace_agent_mesh/agent/sac/task_execution_context.py +73 -0
- solace_agent_mesh/agent/testing/testing_llm_detail.txt +68 -0
- solace_agent_mesh/agent/tools/tools_llm.txt +148 -154
- solace_agent_mesh/agent/tools/tools_llm_detail.txt +274 -0
- solace_agent_mesh/agent/utils/utils_llm.txt +1 -1
- solace_agent_mesh/agent/utils/utils_llm_detail.txt +149 -0
- solace_agent_mesh/assets/docs/404.html +3 -3
- solace_agent_mesh/assets/docs/assets/js/483cef9a.bf9398af.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/{main.f67fc9f4.js → main.0c149855.js} +2 -2
- solace_agent_mesh/assets/docs/assets/js/{runtime~main.40527046.js → runtime~main.c66557e4.js} +1 -1
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/installation/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/rbac-setup-guilde/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/single-sign-on/index.html +8 -4
- solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-gateway-upgrade-to-0.3.0/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-technical-migration-map/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/litellm_models/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rag-integration/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-python-tools/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +3 -3
- solace_agent_mesh/assets/docs/lunr-index-1760032255022.json +1 -0
- solace_agent_mesh/assets/docs/lunr-index.json +1 -1
- solace_agent_mesh/assets/docs/search-doc-1760032255022.json +1 -0
- solace_agent_mesh/assets/docs/search-doc.json +1 -1
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-j1LW-wlq.js → authCallback-DwrxZE0E.js} +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/{client-B9p_nFNA.js → client-DarGQzyw.js} +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-CZbpmwfA.css +1 -0
- solace_agent_mesh/client/webui/frontend/static/assets/main-C__uuUkB.js +339 -0
- solace_agent_mesh/client/webui/frontend/static/assets/{vendor-CS5YMf8a.js → vendor-BKIeiHj_.js} +80 -70
- solace_agent_mesh/client/webui/frontend/static/auth-callback.html +3 -3
- solace_agent_mesh/client/webui/frontend/static/index.html +4 -4
- solace_agent_mesh/common/a2a/a2a_llm.txt +1 -1
- solace_agent_mesh/common/a2a/a2a_llm_detail.txt +193 -0
- solace_agent_mesh/common/a2a_spec/a2a_spec_llm.txt +1 -1
- solace_agent_mesh/common/a2a_spec/a2a_spec_llm_detail.txt +736 -0
- solace_agent_mesh/common/a2a_spec/schemas/llm_invocation.json +23 -0
- solace_agent_mesh/common/a2a_spec/schemas/schemas_llm.txt +93 -15
- solace_agent_mesh/common/a2a_spec/schemas/tool_result.json +23 -0
- solace_agent_mesh/common/common_llm.txt +24 -39
- solace_agent_mesh/common/common_llm_detail.txt +2562 -0
- solace_agent_mesh/common/data_parts.py +9 -1
- solace_agent_mesh/common/middleware/middleware_llm_detail.txt +185 -0
- solace_agent_mesh/common/sac/sac_llm.txt +1 -1
- solace_agent_mesh/common/sac/sac_llm_detail.txt +82 -0
- solace_agent_mesh/common/sam_events/sam_events_llm.txt +104 -0
- solace_agent_mesh/common/sam_events/sam_events_llm_detail.txt +115 -0
- solace_agent_mesh/common/services/services_llm.txt +57 -6
- solace_agent_mesh/common/services/services_llm_detail.txt +459 -0
- solace_agent_mesh/common/utils/embeds/embeds_llm.txt +1 -1
- solace_agent_mesh/common/utils/utils_llm.txt +75 -87
- solace_agent_mesh/common/utils/utils_llm_detail.txt +572 -0
- solace_agent_mesh/core_a2a/core_a2a_llm_detail.txt +101 -0
- solace_agent_mesh/gateway/base/app.py +1 -1
- solace_agent_mesh/gateway/base/base_llm.txt +1 -1
- solace_agent_mesh/gateway/base/base_llm_detail.txt +235 -0
- solace_agent_mesh/gateway/gateway_llm.txt +242 -235
- solace_agent_mesh/gateway/gateway_llm_detail.txt +3885 -0
- solace_agent_mesh/gateway/http_sse/alembic/alembic_llm.txt +295 -0
- solace_agent_mesh/gateway/http_sse/alembic/env.py +10 -1
- solace_agent_mesh/gateway/http_sse/alembic/versions/20251006_98882922fa59_add_tasks_events_feedback_chat_tasks.py +190 -0
- solace_agent_mesh/gateway/http_sse/alembic/versions/versions_llm.txt +155 -0
- solace_agent_mesh/gateway/http_sse/alembic.ini +1 -1
- solace_agent_mesh/gateway/http_sse/app.py +148 -2
- solace_agent_mesh/gateway/http_sse/component.py +368 -60
- solace_agent_mesh/gateway/http_sse/components/components_llm.txt +46 -6
- solace_agent_mesh/gateway/http_sse/components/task_logger_forwarder.py +108 -0
- solace_agent_mesh/gateway/http_sse/components/visualization_forwarder_component.py +1 -1
- solace_agent_mesh/gateway/http_sse/dependencies.py +116 -26
- solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +172 -172
- solace_agent_mesh/gateway/http_sse/http_sse_llm_detail.txt +3278 -0
- solace_agent_mesh/gateway/http_sse/main.py +146 -41
- solace_agent_mesh/gateway/http_sse/repository/__init__.py +3 -12
- solace_agent_mesh/gateway/http_sse/repository/chat_task_repository.py +103 -0
- solace_agent_mesh/gateway/http_sse/repository/entities/__init__.py +5 -3
- solace_agent_mesh/gateway/http_sse/repository/entities/chat_task.py +75 -0
- solace_agent_mesh/gateway/http_sse/repository/entities/entities_llm.txt +263 -0
- solace_agent_mesh/gateway/http_sse/repository/entities/feedback.py +20 -0
- solace_agent_mesh/gateway/http_sse/repository/entities/session_history.py +0 -16
- solace_agent_mesh/gateway/http_sse/repository/entities/task.py +25 -0
- solace_agent_mesh/gateway/http_sse/repository/entities/task_event.py +21 -0
- solace_agent_mesh/gateway/http_sse/repository/feedback_repository.py +81 -0
- solace_agent_mesh/gateway/http_sse/repository/interfaces.py +73 -18
- solace_agent_mesh/gateway/http_sse/repository/models/__init__.py +9 -5
- solace_agent_mesh/gateway/http_sse/repository/models/chat_task_model.py +31 -0
- solace_agent_mesh/gateway/http_sse/repository/models/feedback_model.py +21 -0
- solace_agent_mesh/gateway/http_sse/repository/models/models_llm.txt +266 -0
- solace_agent_mesh/gateway/http_sse/repository/models/session_model.py +3 -3
- solace_agent_mesh/gateway/http_sse/repository/models/task_event_model.py +25 -0
- solace_agent_mesh/gateway/http_sse/repository/models/task_model.py +32 -0
- solace_agent_mesh/gateway/http_sse/repository/repository_llm.txt +340 -0
- solace_agent_mesh/gateway/http_sse/repository/session_repository.py +4 -53
- solace_agent_mesh/gateway/http_sse/repository/task_repository.py +173 -0
- solace_agent_mesh/gateway/http_sse/routers/artifacts.py +1 -1
- solace_agent_mesh/gateway/http_sse/routers/config.py +26 -4
- solace_agent_mesh/gateway/http_sse/routers/dto/dto_llm.txt +346 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/requests/__init__.py +3 -3
- solace_agent_mesh/gateway/http_sse/routers/dto/requests/requests_llm.txt +83 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/requests/session_requests.py +2 -10
- solace_agent_mesh/gateway/http_sse/routers/dto/requests/task_requests.py +58 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/__init__.py +5 -3
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/responses_llm.txt +107 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/session_responses.py +1 -15
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/task_responses.py +30 -0
- solace_agent_mesh/gateway/http_sse/routers/feedback.py +37 -0
- solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +255 -204
- solace_agent_mesh/gateway/http_sse/routers/sessions.py +220 -40
- solace_agent_mesh/gateway/http_sse/routers/tasks.py +168 -42
- solace_agent_mesh/gateway/http_sse/services/data_retention_service.py +272 -0
- solace_agent_mesh/gateway/http_sse/services/feedback_service.py +241 -0
- solace_agent_mesh/gateway/http_sse/services/people_service.py +0 -80
- solace_agent_mesh/gateway/http_sse/services/services_llm.txt +177 -13
- solace_agent_mesh/gateway/http_sse/services/session_service.py +151 -84
- solace_agent_mesh/gateway/http_sse/services/task_logger_service.py +317 -0
- solace_agent_mesh/gateway/http_sse/shared/exception_handlers.py +25 -14
- solace_agent_mesh/gateway/http_sse/shared/shared_llm.txt +285 -0
- solace_agent_mesh/gateway/http_sse/shared/types.py +7 -0
- solace_agent_mesh/gateway/http_sse/utils/__init__.py +1 -0
- solace_agent_mesh/gateway/http_sse/utils/stim_utils.py +32 -0
- solace_agent_mesh/gateway/http_sse/utils/utils_llm.txt +47 -0
- solace_agent_mesh/solace_agent_mesh_llm.txt +1 -1
- solace_agent_mesh/solace_agent_mesh_llm_detail.txt +8599 -0
- {solace_agent_mesh-1.4.12.dist-info → solace_agent_mesh-1.5.0.dist-info}/METADATA +1 -1
- {solace_agent_mesh-1.4.12.dist-info → solace_agent_mesh-1.5.0.dist-info}/RECORD +172 -124
- solace_agent_mesh/agent/adk/invocation_monitor.py +0 -295
- solace_agent_mesh/assets/docs/assets/js/483cef9a.4736f2d8.js +0 -1
- solace_agent_mesh/assets/docs/lunr-index-1759936913198.json +0 -1
- solace_agent_mesh/assets/docs/search-doc-1759936913198.json +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-ChRwcV89.css +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-DnnE01OM.js +0 -339
- solace_agent_mesh/gateway/http_sse/repository/entities/message.py +0 -41
- solace_agent_mesh/gateway/http_sse/repository/message_repository.py +0 -84
- solace_agent_mesh/gateway/http_sse/repository/models/message_model.py +0 -45
- /solace_agent_mesh/assets/docs/assets/js/{main.f67fc9f4.js.LICENSE.txt → main.0c149855.js.LICENSE.txt} +0 -0
- {solace_agent_mesh-1.4.12.dist-info → solace_agent_mesh-1.5.0.dist-info}/WHEEL +0 -0
- {solace_agent_mesh-1.4.12.dist-info → solace_agent_mesh-1.5.0.dist-info}/entry_points.txt +0 -0
- {solace_agent_mesh-1.4.12.dist-info → solace_agent_mesh-1.5.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
## Quick Summary
|
|
2
|
+
This directory contains SQLAlchemy ORM models and Pydantic schemas for database persistence in the HTTP SSE gateway. It provides models for managing chat sessions, messages, tasks, task events, and user feedback with proper relationships and database schema definitions.
|
|
3
|
+
|
|
4
|
+
## Files Overview
|
|
5
|
+
- `__init__.py` - Package initialization exposing all SQLAlchemy and Pydantic models
|
|
6
|
+
- `base.py` - SQLAlchemy declarative base configuration
|
|
7
|
+
- `feedback_model.py` - FeedbackModel for storing user feedback on tasks
|
|
8
|
+
- `message_model.py` - MessageModel and Pydantic schemas for chat messages with session relationships
|
|
9
|
+
- `session_model.py` - SessionModel and Pydantic schemas for managing chat sessions
|
|
10
|
+
- `task_event_model.py` - TaskEventModel for storing A2A task events with task relationships
|
|
11
|
+
- `task_model.py` - TaskModel for managing tasks with event relationships and token usage tracking
|
|
12
|
+
|
|
13
|
+
## Developer API Reference
|
|
14
|
+
|
|
15
|
+
### __init__.py
|
|
16
|
+
**Purpose:** Package entry point that exposes all SQLAlchemy models and Pydantic schemas
|
|
17
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.models import Base, MessageModel, SessionModel, CreateMessageModel, UpdateMessageModel, CreateSessionModel, UpdateSessionModel, TaskEventModel, TaskModel, FeedbackModel`
|
|
18
|
+
|
|
19
|
+
**Constants/Variables:**
|
|
20
|
+
- `__all__: List[str]` - Public API exports including all models and schemas
|
|
21
|
+
|
|
22
|
+
### base.py
|
|
23
|
+
**Purpose:** Provides the SQLAlchemy declarative base for all models
|
|
24
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.base import Base`
|
|
25
|
+
|
|
26
|
+
**Constants/Variables:**
|
|
27
|
+
- `Base: DeclarativeMeta` - SQLAlchemy declarative base class for all models
|
|
28
|
+
|
|
29
|
+
**Usage Examples:**
|
|
30
|
+
```python
|
|
31
|
+
from solace_agent_mesh.gateway.http_sse.repository.models.base import Base
|
|
32
|
+
from sqlalchemy import create_engine
|
|
33
|
+
|
|
34
|
+
# Create all tables
|
|
35
|
+
engine = create_engine("sqlite:///example.db")
|
|
36
|
+
Base.metadata.create_all(engine)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### feedback_model.py
|
|
40
|
+
**Purpose:** SQLAlchemy model for storing user feedback on tasks
|
|
41
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.feedback_model import FeedbackModel`
|
|
42
|
+
|
|
43
|
+
**Classes:**
|
|
44
|
+
- `FeedbackModel(Base)` - SQLAlchemy model for user feedback
|
|
45
|
+
- `id: Column[String]` - Primary key feedback identifier
|
|
46
|
+
- `session_id: Column[String]` - Session identifier
|
|
47
|
+
- `task_id: Column[String]` - Task identifier (indexed)
|
|
48
|
+
- `user_id: Column[String]` - User identifier (indexed)
|
|
49
|
+
- `rating: Column[String]` - Feedback rating (e.g., 'up', 'down')
|
|
50
|
+
- `comment: Column[Text]` - Optional feedback comment
|
|
51
|
+
- `created_time: Column[BigInteger]` - Creation timestamp in epoch milliseconds
|
|
52
|
+
|
|
53
|
+
**Usage Examples:**
|
|
54
|
+
```python
|
|
55
|
+
from solace_agent_mesh.gateway.http_sse.repository.models.feedback_model import FeedbackModel
|
|
56
|
+
from sqlalchemy.orm import sessionmaker
|
|
57
|
+
|
|
58
|
+
# Create feedback
|
|
59
|
+
feedback = FeedbackModel(
|
|
60
|
+
id="feedback_123",
|
|
61
|
+
session_id="session_456",
|
|
62
|
+
task_id="task_789",
|
|
63
|
+
user_id="user_123",
|
|
64
|
+
rating="up",
|
|
65
|
+
comment="Great response!",
|
|
66
|
+
created_time=1640995200000
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# Add to database
|
|
70
|
+
Session = sessionmaker(bind=engine)
|
|
71
|
+
db_session = Session()
|
|
72
|
+
db_session.add(feedback)
|
|
73
|
+
db_session.commit()
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### message_model.py
|
|
77
|
+
**Purpose:** SQLAlchemy model and Pydantic schemas for storing chat messages with session relationships
|
|
78
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.message_model import MessageModel, CreateMessageModel, UpdateMessageModel`
|
|
79
|
+
|
|
80
|
+
**Classes:**
|
|
81
|
+
- `MessageModel(Base)` - SQLAlchemy model for chat messages
|
|
82
|
+
- `id: Column[String]` - Primary key message identifier
|
|
83
|
+
- `session_id: Column[String]` - Foreign key to sessions table with CASCADE delete
|
|
84
|
+
- `message: Column[Text]` - Message content
|
|
85
|
+
- `created_time: Column[BigInteger]` - Creation timestamp (auto-generated)
|
|
86
|
+
- `sender_type: Column[String]` - Type of message sender (max 50 chars)
|
|
87
|
+
- `sender_name: Column[String]` - Name of message sender (max 255 chars)
|
|
88
|
+
- `session: relationship` - SQLAlchemy relationship to SessionModel
|
|
89
|
+
|
|
90
|
+
- `CreateMessageModel(BaseModel)` - Pydantic model for creating messages
|
|
91
|
+
- `id: str` - Message identifier
|
|
92
|
+
- `session_id: str` - Session identifier
|
|
93
|
+
- `message: str` - Message content
|
|
94
|
+
- `sender_type: str` - Sender type
|
|
95
|
+
- `sender_name: str` - Sender name
|
|
96
|
+
- `created_time: int` - Creation timestamp
|
|
97
|
+
|
|
98
|
+
- `UpdateMessageModel(BaseModel)` - Pydantic model for updating messages
|
|
99
|
+
- `message: str` - Updated message content
|
|
100
|
+
- `sender_type: str` - Updated sender type
|
|
101
|
+
- `sender_name: str` - Updated sender name
|
|
102
|
+
|
|
103
|
+
**Usage Examples:**
|
|
104
|
+
```python
|
|
105
|
+
from solace_agent_mesh.gateway.http_sse.repository.models.message_model import MessageModel, CreateMessageModel
|
|
106
|
+
from sqlalchemy.orm import sessionmaker
|
|
107
|
+
|
|
108
|
+
# Create using SQLAlchemy model
|
|
109
|
+
message = MessageModel(
|
|
110
|
+
id="msg_123",
|
|
111
|
+
session_id="session_456",
|
|
112
|
+
message="Hello, world!",
|
|
113
|
+
sender_type="user",
|
|
114
|
+
sender_name="John Doe"
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
# Create using Pydantic model
|
|
118
|
+
create_data = CreateMessageModel(
|
|
119
|
+
id="msg_124",
|
|
120
|
+
session_id="session_456",
|
|
121
|
+
message="How are you?",
|
|
122
|
+
sender_type="user",
|
|
123
|
+
sender_name="John Doe",
|
|
124
|
+
created_time=1640995200000
|
|
125
|
+
)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### session_model.py
|
|
129
|
+
**Purpose:** SQLAlchemy model and Pydantic schemas for managing chat sessions with message relationships
|
|
130
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.session_model import SessionModel, CreateSessionModel, UpdateSessionModel`
|
|
131
|
+
|
|
132
|
+
**Classes:**
|
|
133
|
+
- `SessionModel(Base)` - SQLAlchemy model for chat sessions
|
|
134
|
+
- `id: Column[String]` - Primary key session identifier
|
|
135
|
+
- `name: Column[String]` - Optional session name
|
|
136
|
+
- `user_id: Column[String]` - Required user identifier
|
|
137
|
+
- `agent_id: Column[String]` - Optional agent identifier
|
|
138
|
+
- `created_time: Column[BigInteger]` - Creation timestamp (auto-generated)
|
|
139
|
+
- `updated_time: Column[BigInteger]` - Last update timestamp (auto-updated)
|
|
140
|
+
- `messages: relationship` - SQLAlchemy relationship to MessageModel with cascade delete
|
|
141
|
+
|
|
142
|
+
- `CreateSessionModel(BaseModel)` - Pydantic model for creating sessions
|
|
143
|
+
- `id: str` - Session identifier
|
|
144
|
+
- `name: str | None` - Optional session name
|
|
145
|
+
- `user_id: str` - User identifier
|
|
146
|
+
- `agent_id: str | None` - Optional agent identifier
|
|
147
|
+
- `created_time: int` - Creation timestamp
|
|
148
|
+
- `updated_time: int` - Update timestamp
|
|
149
|
+
|
|
150
|
+
- `UpdateSessionModel(BaseModel)` - Pydantic model for updating sessions
|
|
151
|
+
- `name: str | None` - Optional updated session name
|
|
152
|
+
- `agent_id: str | None` - Optional updated agent identifier
|
|
153
|
+
- `updated_time: int` - Update timestamp
|
|
154
|
+
|
|
155
|
+
**Usage Examples:**
|
|
156
|
+
```python
|
|
157
|
+
from solace_agent_mesh.gateway.http_sse.repository.models.session_model import SessionModel, CreateSessionModel
|
|
158
|
+
from sqlalchemy.orm import sessionmaker
|
|
159
|
+
|
|
160
|
+
# Create using SQLAlchemy model
|
|
161
|
+
session = SessionModel(
|
|
162
|
+
id="session_123",
|
|
163
|
+
name="My Chat Session",
|
|
164
|
+
user_id="user_456",
|
|
165
|
+
agent_id="agent_789"
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
# Create using Pydantic model
|
|
169
|
+
create_data = CreateSessionModel(
|
|
170
|
+
id="session_124",
|
|
171
|
+
name="Another Session",
|
|
172
|
+
user_id="user_456",
|
|
173
|
+
agent_id="agent_789",
|
|
174
|
+
created_time=1640995200000,
|
|
175
|
+
updated_time=1640995200000
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# Access related messages
|
|
179
|
+
messages = session.messages # Returns list of MessageModel instances
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### task_event_model.py
|
|
183
|
+
**Purpose:** SQLAlchemy model for storing A2A task events with task relationships
|
|
184
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.task_event_model import TaskEventModel`
|
|
185
|
+
|
|
186
|
+
**Classes:**
|
|
187
|
+
- `TaskEventModel(Base)` - SQLAlchemy model for A2A task events
|
|
188
|
+
- `id: Column[String]` - Primary key event identifier
|
|
189
|
+
- `task_id: Column[String]` - Foreign key to tasks table with CASCADE delete (indexed)
|
|
190
|
+
- `user_id: Column[String]` - Optional user identifier (indexed)
|
|
191
|
+
- `created_time: Column[BigInteger]` - Creation timestamp in epoch milliseconds
|
|
192
|
+
- `topic: Column[Text]` - Event topic
|
|
193
|
+
- `direction: Column[String]` - Event direction (max 50 chars)
|
|
194
|
+
- `payload: Column[JSON]` - Event payload as JSON
|
|
195
|
+
- `task: relationship` - SQLAlchemy relationship to TaskModel
|
|
196
|
+
|
|
197
|
+
**Usage Examples:**
|
|
198
|
+
```python
|
|
199
|
+
from solace_agent_mesh.gateway.http_sse.repository.models.task_event_model import TaskEventModel
|
|
200
|
+
from sqlalchemy.orm import sessionmaker
|
|
201
|
+
|
|
202
|
+
# Create a task event
|
|
203
|
+
event = TaskEventModel(
|
|
204
|
+
id="event_123",
|
|
205
|
+
task_id="task_456",
|
|
206
|
+
user_id="user_789",
|
|
207
|
+
created_time=1640995200000,
|
|
208
|
+
topic="agent/response",
|
|
209
|
+
direction="inbound",
|
|
210
|
+
payload={"message": "Task completed", "status": "success"}
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
# Add to database
|
|
214
|
+
Session = sessionmaker(bind=engine)
|
|
215
|
+
db_session = Session()
|
|
216
|
+
db_session.add(event)
|
|
217
|
+
db_session.commit()
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### task_model.py
|
|
221
|
+
**Purpose:** SQLAlchemy model for managing tasks with event relationships and token usage tracking
|
|
222
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.task_model import TaskModel`
|
|
223
|
+
|
|
224
|
+
**Classes:**
|
|
225
|
+
- `TaskModel(Base)` - SQLAlchemy model for tasks
|
|
226
|
+
- `id: Column[String]` - Primary key task identifier
|
|
227
|
+
- `user_id: Column[String]` - User identifier (indexed)
|
|
228
|
+
- `start_time: Column[BigInteger]` - Task start timestamp in epoch milliseconds
|
|
229
|
+
- `end_time: Column[BigInteger]` - Optional task end timestamp
|
|
230
|
+
- `status: Column[String]` - Optional task status
|
|
231
|
+
- `initial_request_text: Column[Text]` - Optional initial request text (indexed)
|
|
232
|
+
- `total_input_tokens: Column[Integer]` - Optional total input tokens used
|
|
233
|
+
- `total_output_tokens: Column[Integer]` - Optional total output tokens used
|
|
234
|
+
- `total_cached_input_tokens: Column[Integer]` - Optional total cached input tokens
|
|
235
|
+
- `token_usage_details: Column[JSON]` - Optional detailed token usage information
|
|
236
|
+
- `events: relationship` - SQLAlchemy relationship to TaskEventModel with cascade delete
|
|
237
|
+
|
|
238
|
+
**Usage Examples:**
|
|
239
|
+
```python
|
|
240
|
+
from solace_agent_mesh.gateway.http_sse.repository.models.task_model import TaskModel
|
|
241
|
+
from sqlalchemy.orm import sessionmaker
|
|
242
|
+
|
|
243
|
+
# Create a new task with token tracking
|
|
244
|
+
task = TaskModel(
|
|
245
|
+
id="task_123",
|
|
246
|
+
user_id="user_456",
|
|
247
|
+
start_time=1640995200000,
|
|
248
|
+
status="in_progress",
|
|
249
|
+
initial_request_text="Please help me with this task",
|
|
250
|
+
total_input_tokens=150,
|
|
251
|
+
total_output_tokens=300,
|
|
252
|
+
total_cached_input_tokens=50,
|
|
253
|
+
token_usage_details={"model": "gpt-4", "breakdown": {"reasoning": 200, "response": 100}}
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
# Add to database
|
|
257
|
+
Session = sessionmaker(bind=engine)
|
|
258
|
+
db_session = Session()
|
|
259
|
+
db_session.add(task)
|
|
260
|
+
db_session.commit()
|
|
261
|
+
|
|
262
|
+
# Access related events
|
|
263
|
+
events = task.events # Returns list of TaskEventModel instances
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
# content_hash: 0583795702abeb023659a686bf3cfa551016bdd0284b01f2448dd9d4d2050f3b
|
|
@@ -24,9 +24,9 @@ class SessionModel(Base):
|
|
|
24
24
|
BigInteger, nullable=False, default=now_epoch_ms, onupdate=now_epoch_ms
|
|
25
25
|
)
|
|
26
26
|
|
|
27
|
-
# Relationship to
|
|
28
|
-
|
|
29
|
-
"
|
|
27
|
+
# Relationship to chat tasks
|
|
28
|
+
chat_tasks = relationship(
|
|
29
|
+
"ChatTaskModel", back_populates="session", cascade="all, delete-orphan"
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Task Event SQLAlchemy model.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from sqlalchemy import JSON, BigInteger, Column, ForeignKey, String, Text
|
|
6
|
+
from sqlalchemy.orm import relationship
|
|
7
|
+
|
|
8
|
+
from .base import Base
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TaskEventModel(Base):
|
|
12
|
+
"""SQLAlchemy model for A2A task events."""
|
|
13
|
+
|
|
14
|
+
__tablename__ = "task_events"
|
|
15
|
+
|
|
16
|
+
id = Column(String, primary_key=True)
|
|
17
|
+
task_id = Column(String, ForeignKey("tasks.id", ondelete="CASCADE"), index=True)
|
|
18
|
+
user_id = Column(String, nullable=True, index=True)
|
|
19
|
+
created_time = Column(BigInteger, nullable=False)
|
|
20
|
+
topic = Column(Text, nullable=False)
|
|
21
|
+
direction = Column(String(50), nullable=False)
|
|
22
|
+
payload = Column(JSON, nullable=False)
|
|
23
|
+
|
|
24
|
+
# Relationship to task
|
|
25
|
+
task = relationship("TaskModel", back_populates="events")
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Task SQLAlchemy model.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from sqlalchemy import BigInteger, Column, Integer, JSON, String, Text
|
|
6
|
+
from sqlalchemy.orm import relationship
|
|
7
|
+
|
|
8
|
+
from .base import Base
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TaskModel(Base):
|
|
12
|
+
"""SQLAlchemy model for tasks."""
|
|
13
|
+
|
|
14
|
+
__tablename__ = "tasks"
|
|
15
|
+
|
|
16
|
+
id = Column(String, primary_key=True)
|
|
17
|
+
user_id = Column(String, nullable=False, index=True)
|
|
18
|
+
start_time = Column(BigInteger, nullable=False)
|
|
19
|
+
end_time = Column(BigInteger, nullable=True)
|
|
20
|
+
status = Column(String, nullable=True)
|
|
21
|
+
initial_request_text = Column(Text, nullable=True, index=True)
|
|
22
|
+
|
|
23
|
+
# Token usage columns
|
|
24
|
+
total_input_tokens = Column(Integer, nullable=True)
|
|
25
|
+
total_output_tokens = Column(Integer, nullable=True)
|
|
26
|
+
total_cached_input_tokens = Column(Integer, nullable=True)
|
|
27
|
+
token_usage_details = Column(JSON, nullable=True)
|
|
28
|
+
|
|
29
|
+
# Relationship to events
|
|
30
|
+
events = relationship(
|
|
31
|
+
"TaskEventModel", back_populates="task", cascade="all, delete-orphan"
|
|
32
|
+
)
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
## Quick Summary
|
|
2
|
+
|
|
3
|
+
The repository directory implements the data access layer for the HTTP SSE gateway using the Repository pattern. It provides a clean separation between domain entities and database persistence through SQLAlchemy ORM models. The architecture consists of abstract interfaces, concrete implementations, domain entities with business logic, and SQLAlchemy models for database operations. The two main subdirectories (entities and models) work together to provide a complete data persistence solution for chat sessions, messages, tasks, feedback, and events.
|
|
4
|
+
|
|
5
|
+
## Files and Subdirectories Overview
|
|
6
|
+
|
|
7
|
+
**Direct files:**
|
|
8
|
+
- `__init__.py` - Main package exports for repository interfaces, implementations, entities, and models
|
|
9
|
+
- `interfaces.py` - Abstract repository interfaces defining data access contracts for sessions, messages, tasks, and feedback
|
|
10
|
+
- `message_repository.py` - SQLAlchemy implementation of message data access operations
|
|
11
|
+
- `session_repository.py` - SQLAlchemy implementation of session data access operations
|
|
12
|
+
- `feedback_repository.py` - SQLAlchemy implementation of feedback data access operations
|
|
13
|
+
- `task_repository.py` - SQLAlchemy implementation of task data access operations
|
|
14
|
+
|
|
15
|
+
**Subdirectories:**
|
|
16
|
+
- `entities/` - Domain entities with business logic for sessions, messages, tasks, feedback, and events
|
|
17
|
+
- `models/` - SQLAlchemy ORM models for database persistence and schema definition
|
|
18
|
+
|
|
19
|
+
## Developer API Reference
|
|
20
|
+
|
|
21
|
+
### Direct Files
|
|
22
|
+
|
|
23
|
+
#### __init__.py
|
|
24
|
+
**Purpose:** Central package exports for all repository components
|
|
25
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository import IMessageRepository, ISessionRepository, MessageRepository, SessionRepository, Session, Message, SessionHistory, Base, MessageModel, SessionModel`
|
|
26
|
+
|
|
27
|
+
**Exports:**
|
|
28
|
+
- `IMessageRepository` - Message repository interface
|
|
29
|
+
- `ISessionRepository` - Session repository interface
|
|
30
|
+
- `MessageRepository` - Message repository implementation
|
|
31
|
+
- `SessionRepository` - Session repository implementation
|
|
32
|
+
- `Message` - Message domain entity
|
|
33
|
+
- `Session` - Session domain entity
|
|
34
|
+
- `SessionHistory` - Session with messages composite entity
|
|
35
|
+
- `Base` - SQLAlchemy declarative base
|
|
36
|
+
- `MessageModel` - SQLAlchemy message model
|
|
37
|
+
- `SessionModel` - SQLAlchemy session model
|
|
38
|
+
|
|
39
|
+
#### interfaces.py
|
|
40
|
+
**Purpose:** Defines abstract repository interfaces for data access contracts
|
|
41
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.interfaces import ISessionRepository, IMessageRepository, ITaskRepository, IFeedbackRepository`
|
|
42
|
+
|
|
43
|
+
**Classes:**
|
|
44
|
+
- `ISessionRepository(ABC)` - Abstract interface for session data operations
|
|
45
|
+
- `find_by_user(user_id: UserId, pagination: PaginationInfo | None = None) -> list[Session]` - Find all sessions for a user
|
|
46
|
+
- `count_by_user(user_id: UserId) -> int` - Count total sessions for a user
|
|
47
|
+
- `find_user_session(session_id: SessionId, user_id: UserId) -> Session | None` - Find specific user session
|
|
48
|
+
- `save(session: Session) -> Session` - Save or update a session
|
|
49
|
+
- `delete(session_id: SessionId, user_id: UserId) -> bool` - Delete user session
|
|
50
|
+
- `find_user_session_with_messages(session_id: SessionId, user_id: UserId, pagination: PaginationInfo | None = None) -> tuple[Session, list[Message]] | None` - Find session with messages
|
|
51
|
+
|
|
52
|
+
- `IMessageRepository(ABC)` - Abstract interface for message data operations
|
|
53
|
+
- `find_by_session(session_id: SessionId, pagination: PaginationInfo | None = None) -> list[Message]` - Find messages in session
|
|
54
|
+
- `save(message: Message) -> Message` - Save or update a message
|
|
55
|
+
- `delete_by_session(session_id: SessionId) -> bool` - Delete all session messages
|
|
56
|
+
|
|
57
|
+
- `ITaskRepository(ABC)` - Abstract interface for task data operations
|
|
58
|
+
- `save_task(task: Task) -> Task` - Create or update a task
|
|
59
|
+
- `save_event(event: TaskEvent) -> TaskEvent` - Save a task event
|
|
60
|
+
- `find_by_id(task_id: str) -> Task | None` - Find a task by its ID
|
|
61
|
+
- `find_by_id_with_events(task_id: str) -> tuple[Task, list[TaskEvent]] | None` - Find a task with all its events
|
|
62
|
+
- `search(user_id: UserId, start_date: int | None = None, end_date: int | None = None, search_query: str | None = None, pagination: PaginationParams | None = None) -> list[Task]` - Search for tasks with filters
|
|
63
|
+
- `delete_tasks_older_than(cutoff_time_ms: int, batch_size: int) -> int` - Delete tasks older than cutoff time
|
|
64
|
+
|
|
65
|
+
- `IFeedbackRepository(ABC)` - Abstract interface for feedback data operations
|
|
66
|
+
- `save(feedback: Feedback) -> Feedback` - Save feedback
|
|
67
|
+
- `delete_feedback_older_than(cutoff_time_ms: int, batch_size: int) -> int` - Delete feedback older than cutoff time
|
|
68
|
+
|
|
69
|
+
#### message_repository.py
|
|
70
|
+
**Purpose:** SQLAlchemy implementation of message repository interface
|
|
71
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.message_repository import MessageRepository`
|
|
72
|
+
|
|
73
|
+
**Classes:**
|
|
74
|
+
- `MessageRepository(IMessageRepository)` - SQLAlchemy message repository implementation
|
|
75
|
+
- `__init__(db: DBSession)` - Initialize with database session
|
|
76
|
+
- `find_by_session(session_id: SessionId, pagination: PaginationInfo | None = None) -> list[Message]` - Find messages in session with pagination
|
|
77
|
+
- `save(message: Message) -> Message` - Save or update message in database
|
|
78
|
+
- `delete_by_session(session_id: SessionId) -> bool` - Delete all messages in session
|
|
79
|
+
- `_convert_model_to_entity(model: MessageModel) -> Message` - Convert SQLAlchemy model to domain entity
|
|
80
|
+
|
|
81
|
+
#### session_repository.py
|
|
82
|
+
**Purpose:** SQLAlchemy implementation of session repository interface
|
|
83
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.session_repository import SessionRepository`
|
|
84
|
+
|
|
85
|
+
**Classes:**
|
|
86
|
+
- `SessionRepository(ISessionRepository)` - SQLAlchemy session repository implementation
|
|
87
|
+
- `__init__(db: DBSession)` - Initialize with database session
|
|
88
|
+
- `find_by_user(user_id: UserId, pagination: PaginationInfo | None = None) -> list[Session]` - Find user sessions with pagination
|
|
89
|
+
- `count_by_user(user_id: UserId) -> int` - Count total sessions for a user
|
|
90
|
+
- `find_user_session(session_id: SessionId, user_id: UserId) -> Session | None` - Find specific user session
|
|
91
|
+
- `save(session: Session) -> Session` - Save or update session in database
|
|
92
|
+
- `delete(session_id: SessionId, user_id: UserId) -> bool` - Delete user session
|
|
93
|
+
- `find_user_session_with_messages(session_id: SessionId, user_id: UserId, pagination: PaginationInfo | None = None) -> tuple[Session, list[Message]] | None` - Find session with messages
|
|
94
|
+
- `_message_model_to_entity(model: MessageModel) -> Message` - Convert message model to entity
|
|
95
|
+
|
|
96
|
+
#### feedback_repository.py
|
|
97
|
+
**Purpose:** SQLAlchemy implementation of feedback repository interface
|
|
98
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.feedback_repository import FeedbackRepository`
|
|
99
|
+
|
|
100
|
+
**Classes:**
|
|
101
|
+
- `FeedbackRepository(IFeedbackRepository)` - SQLAlchemy feedback repository implementation
|
|
102
|
+
- `__init__(db: DBSession)` - Initialize with database session
|
|
103
|
+
- `save(feedback: Feedback) -> Feedback` - Save feedback to database
|
|
104
|
+
- `delete_feedback_older_than(cutoff_time_ms: int, batch_size: int) -> int` - Delete feedback older than cutoff time using batch deletion
|
|
105
|
+
- `_model_to_entity(model: FeedbackModel) -> Feedback` - Convert SQLAlchemy model to domain entity
|
|
106
|
+
|
|
107
|
+
#### task_repository.py
|
|
108
|
+
**Purpose:** SQLAlchemy implementation of task repository interface
|
|
109
|
+
**Import:** `from solace_agent_mesh.gateway.http_sse.repository.task_repository import TaskRepository`
|
|
110
|
+
|
|
111
|
+
**Classes:**
|
|
112
|
+
- `TaskRepository(ITaskRepository)` - SQLAlchemy task repository implementation
|
|
113
|
+
- `__init__(db: DBSession)` - Initialize with database session
|
|
114
|
+
- `save_task(task: Task) -> Task` - Create or update a task
|
|
115
|
+
- `save_event(event: TaskEvent) -> TaskEvent` - Save a task event
|
|
116
|
+
- `find_by_id(task_id: str) -> Task | None` - Find a task by its ID
|
|
117
|
+
- `find_by_id_with_events(task_id: str) -> tuple[Task, list[TaskEvent]] | None` - Find a task with all its events
|
|
118
|
+
- `search(user_id: UserId, start_date: int | None = None, end_date: int | None = None, search_query: str | None = None, pagination: PaginationParams | None = None) -> list[Task]` - Search for tasks with filters
|
|
119
|
+
- `delete_tasks_older_than(cutoff_time_ms: int, batch_size: int) -> int` - Delete tasks older than cutoff time using batch deletion
|
|
120
|
+
- `_task_model_to_entity(model: TaskModel) -> Task` - Convert SQLAlchemy task model to domain entity
|
|
121
|
+
- `_event_model_to_entity(model: TaskEventModel) -> TaskEvent` - Convert SQLAlchemy event model to domain entity
|
|
122
|
+
|
|
123
|
+
### Subdirectory APIs
|
|
124
|
+
|
|
125
|
+
#### entities/
|
|
126
|
+
**Purpose:** Provides domain entities with business logic for sessions, messages, tasks, feedback, and events
|
|
127
|
+
**Key Exports:** Message, Session, SessionHistory, Task, TaskEvent, Feedback
|
|
128
|
+
**Import Examples:**
|
|
129
|
+
```python
|
|
130
|
+
from solace_agent_mesh.gateway.http_sse.repository.entities import Message, Session, SessionHistory, Task, TaskEvent, Feedback
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### models/
|
|
134
|
+
**Purpose:** Provides SQLAlchemy ORM models for database persistence and schema definition
|
|
135
|
+
**Key Exports:** Base, MessageModel, SessionModel, TaskModel, TaskEventModel, FeedbackModel
|
|
136
|
+
**Import Examples:**
|
|
137
|
+
```python
|
|
138
|
+
from solace_agent_mesh.gateway.http_sse.repository.models import Base, MessageModel, SessionModel, TaskModel, TaskEventModel, FeedbackModel
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Complete Usage Guide
|
|
142
|
+
|
|
143
|
+
### 1. Setting Up the Repository Layer
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from sqlalchemy import create_engine
|
|
147
|
+
from sqlalchemy.orm import sessionmaker
|
|
148
|
+
from solace_agent_mesh.gateway.http_sse.repository import (
|
|
149
|
+
Base, MessageRepository, SessionRepository, TaskRepository, FeedbackRepository
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
# Create database engine and session
|
|
153
|
+
engine = create_engine("sqlite:///chat.db")
|
|
154
|
+
Base.metadata.create_all(engine)
|
|
155
|
+
Session = sessionmaker(bind=engine)
|
|
156
|
+
db_session = Session()
|
|
157
|
+
|
|
158
|
+
# Initialize repositories
|
|
159
|
+
message_repo = MessageRepository(db_session)
|
|
160
|
+
session_repo = SessionRepository(db_session)
|
|
161
|
+
task_repo = TaskRepository(db_session)
|
|
162
|
+
feedback_repo = FeedbackRepository(db_session)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 2. Working with Sessions
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from solace_agent_mesh.gateway.http_sse.repository.entities import Session
|
|
169
|
+
from solace_agent_mesh.gateway.http_sse.shared.types import PaginationInfo
|
|
170
|
+
import time
|
|
171
|
+
|
|
172
|
+
# Create a new session
|
|
173
|
+
session = Session(
|
|
174
|
+
id="session_123",
|
|
175
|
+
user_id="user_456",
|
|
176
|
+
name="Customer Support Chat",
|
|
177
|
+
agent_id="agent_789",
|
|
178
|
+
created_time=int(time.time() * 1000)
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
# Save session
|
|
182
|
+
saved_session = session_repo.save(session)
|
|
183
|
+
|
|
184
|
+
# Find user sessions with pagination
|
|
185
|
+
pagination = PaginationInfo(page=1, page_size=10)
|
|
186
|
+
user_sessions = session_repo.find_by_user("user_456", pagination)
|
|
187
|
+
|
|
188
|
+
# Count total sessions for user
|
|
189
|
+
total_sessions = session_repo.count_by_user("user_456")
|
|
190
|
+
|
|
191
|
+
# Find specific session
|
|
192
|
+
found_session = session_repo.find_user_session("session_123", "user_456")
|
|
193
|
+
|
|
194
|
+
# Update session
|
|
195
|
+
if found_session:
|
|
196
|
+
found_session.update_name("Updated Chat Name")
|
|
197
|
+
session_repo.save(found_session)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 3. Working with Messages
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from solace_agent_mesh.gateway.http_sse.repository.entities import Message
|
|
204
|
+
from solace_agent_mesh.gateway.http_sse.shared.enums import SenderType, MessageType
|
|
205
|
+
|
|
206
|
+
# Create a new message
|
|
207
|
+
message = Message(
|
|
208
|
+
id="msg_123",
|
|
209
|
+
session_id="session_123",
|
|
210
|
+
message="Hello, how can I help you today?",
|
|
211
|
+
sender_type=SenderType.AGENT,
|
|
212
|
+
sender_name="Support Agent",
|
|
213
|
+
message_type=MessageType.TEXT,
|
|
214
|
+
created_time=int(time.time() * 1000)
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
# Validate and save message
|
|
218
|
+
message.validate_message_content()
|
|
219
|
+
saved_message = message_repo.save(message)
|
|
220
|
+
|
|
221
|
+
# Find messages in session
|
|
222
|
+
session_messages = message_repo.find_by_session("session_123", pagination)
|
|
223
|
+
|
|
224
|
+
# Check message properties
|
|
225
|
+
if message.is_from_agent():
|
|
226
|
+
print("Message from agent")
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### 4. Working with Tasks and Events
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
from solace_agent_mesh.gateway.http_sse.repository.entities import Task, TaskEvent
|
|
233
|
+
|
|
234
|
+
# Create a new task
|
|
235
|
+
task = Task(
|
|
236
|
+
id="task_123",
|
|
237
|
+
user_id="user_456",
|
|
238
|
+
start_time=int(time.time() * 1000),
|
|
239
|
+
status="in_progress",
|
|
240
|
+
initial_request_text="Help me with my order"
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
# Save task
|
|
244
|
+
saved_task = task_repo.save_task(task)
|
|
245
|
+
|
|
246
|
+
# Create task event
|
|
247
|
+
event = TaskEvent(
|
|
248
|
+
id="event_123",
|
|
249
|
+
task_id="task_123",
|
|
250
|
+
user_id="user_456",
|
|
251
|
+
created_time=int(time.time() * 1000),
|
|
252
|
+
topic="task.status.changed",
|
|
253
|
+
direction="outbound",
|
|
254
|
+
payload={"status": "completed", "result": "success"}
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
# Save event
|
|
258
|
+
saved_event = task_repo.save_event(event)
|
|
259
|
+
|
|
260
|
+
# Find task with events
|
|
261
|
+
result = task_repo.find_by_id_with_events("task_123")
|
|
262
|
+
if result:
|
|
263
|
+
task, events = result
|
|
264
|
+
print(f"Task {task.id} has {len(events)} events")
|
|
265
|
+
|
|
266
|
+
# Search tasks
|
|
267
|
+
from solace_agent_mesh.gateway.http_sse.shared.types import PaginationParams
|
|
268
|
+
pagination_params = PaginationParams(page=1, page_size=10)
|
|
269
|
+
tasks = task_repo.search(
|
|
270
|
+
user_id="user_456",
|
|
271
|
+
search_query="order",
|
|
272
|
+
pagination=pagination_params
|
|
273
|
+
)
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### 5. Working with Feedback
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
from solace_agent_mesh.gateway.http_sse.repository.entities import Feedback
|
|
280
|
+
|
|
281
|
+
# Create feedback
|
|
282
|
+
feedback = Feedback(
|
|
283
|
+
id="feedback_123",
|
|
284
|
+
session_id="session_123",
|
|
285
|
+
task_id="task_123",
|
|
286
|
+
user_id="user_456",
|
|
287
|
+
rating="up",
|
|
288
|
+
comment="Great service!",
|
|
289
|
+
created_time=int(time.time() * 1000)
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
# Save feedback
|
|
293
|
+
saved_feedback = feedback_repo.save(feedback)
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 6. Working with Session History (Combined Operations)
|
|
297
|
+
|
|
298
|
+
```python
|
|
299
|
+
from solace_agent_mesh.gateway.http_sse.repository.entities import SessionHistory
|
|
300
|
+
|
|
301
|
+
# Get session with messages in one operation
|
|
302
|
+
result = session_repo.find_user_session_with_messages(
|
|
303
|
+
"session_123", "user_456", pagination
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
if result:
|
|
307
|
+
session, messages = result
|
|
308
|
+
|
|
309
|
+
# Create session history object
|
|
310
|
+
history = SessionHistory(
|
|
311
|
+
session=session,
|
|
312
|
+
messages=messages,
|
|
313
|
+
total_message_count=len(messages)
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
print(f"Session: {history.session.name}")
|
|
317
|
+
print(f"Messages: {len(history.messages)}")
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### 7. Using Repository Interfaces for Dependency Injection
|
|
321
|
+
|
|
322
|
+
```python
|
|
323
|
+
from solace_agent_mesh.gateway.http_sse.repository.interfaces import (
|
|
324
|
+
ISessionRepository, IMessageRepository, ITaskRepository, IFeedbackRepository
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
class ChatService:
|
|
328
|
+
def __init__(
|
|
329
|
+
self,
|
|
330
|
+
session_repo: ISessionRepository,
|
|
331
|
+
message_repo: IMessageRepository,
|
|
332
|
+
task_repo: ITaskRepository,
|
|
333
|
+
feedback_repo: IFeedbackRepository
|
|
334
|
+
):
|
|
335
|
+
self.session_repo = session_repo
|
|
336
|
+
self.message_repo = message_repo
|
|
337
|
+
self.task_repo = task_repo
|
|
338
|
+
self.feedback_
|
|
339
|
+
|
|
340
|
+
# content_hash: e4e822acd625d1acce1f4ea0721844e7428a9b110c9e73b6657b8d3adc8ed038
|