julee 0.1.1__py3-none-any.whl → 0.1.3__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 (157) hide show
  1. julee/api/app.py +9 -8
  2. julee/api/dependencies.py +15 -15
  3. julee/api/requests.py +10 -9
  4. julee/api/responses.py +2 -1
  5. julee/api/routers/__init__.py +5 -5
  6. julee/api/routers/assembly_specifications.py +5 -4
  7. julee/api/routers/documents.py +1 -1
  8. julee/api/routers/knowledge_service_configs.py +4 -3
  9. julee/api/routers/knowledge_service_queries.py +7 -6
  10. julee/api/routers/system.py +4 -3
  11. julee/api/routers/workflows.py +4 -5
  12. julee/api/services/system_initialization.py +6 -6
  13. julee/api/tests/routers/test_assembly_specifications.py +4 -3
  14. julee/api/tests/routers/test_documents.py +5 -4
  15. julee/api/tests/routers/test_knowledge_service_configs.py +7 -6
  16. julee/api/tests/routers/test_knowledge_service_queries.py +4 -3
  17. julee/api/tests/routers/test_system.py +5 -4
  18. julee/api/tests/routers/test_workflows.py +5 -4
  19. julee/api/tests/test_app.py +5 -4
  20. julee/api/tests/test_dependencies.py +3 -2
  21. julee/api/tests/test_requests.py +2 -1
  22. julee/contrib/__init__.py +15 -0
  23. julee/contrib/polling/__init__.py +47 -0
  24. julee/contrib/polling/domain/__init__.py +17 -0
  25. julee/contrib/polling/domain/models/__init__.py +13 -0
  26. julee/contrib/polling/domain/models/polling_config.py +39 -0
  27. julee/contrib/polling/domain/services/__init__.py +11 -0
  28. julee/contrib/polling/domain/services/poller.py +39 -0
  29. julee/contrib/polling/infrastructure/__init__.py +15 -0
  30. julee/contrib/polling/infrastructure/services/__init__.py +12 -0
  31. julee/contrib/polling/infrastructure/services/polling/__init__.py +12 -0
  32. julee/contrib/polling/infrastructure/services/polling/http/__init__.py +12 -0
  33. julee/contrib/polling/infrastructure/services/polling/http/http_poller_service.py +80 -0
  34. julee/contrib/polling/infrastructure/temporal/__init__.py +20 -0
  35. julee/contrib/polling/infrastructure/temporal/activities.py +42 -0
  36. julee/contrib/polling/infrastructure/temporal/activity_names.py +20 -0
  37. julee/contrib/polling/infrastructure/temporal/proxies.py +45 -0
  38. julee/contrib/polling/tests/__init__.py +6 -0
  39. julee/contrib/polling/tests/unit/__init__.py +6 -0
  40. julee/contrib/polling/tests/unit/infrastructure/__init__.py +7 -0
  41. julee/contrib/polling/tests/unit/infrastructure/services/__init__.py +6 -0
  42. julee/contrib/polling/tests/unit/infrastructure/services/polling/__init__.py +6 -0
  43. julee/contrib/polling/tests/unit/infrastructure/services/polling/http/__init__.py +7 -0
  44. julee/contrib/polling/tests/unit/infrastructure/services/polling/http/test_http_poller_service.py +163 -0
  45. julee/docs/__init__.py +5 -0
  46. julee/docs/sphinx_hcd/__init__.py +82 -0
  47. julee/docs/sphinx_hcd/accelerators.py +1078 -0
  48. julee/docs/sphinx_hcd/apps.py +499 -0
  49. julee/docs/sphinx_hcd/config.py +148 -0
  50. julee/docs/sphinx_hcd/epics.py +448 -0
  51. julee/docs/sphinx_hcd/integrations.py +306 -0
  52. julee/docs/sphinx_hcd/journeys.py +783 -0
  53. julee/docs/sphinx_hcd/personas.py +435 -0
  54. julee/docs/sphinx_hcd/stories.py +932 -0
  55. julee/docs/sphinx_hcd/utils.py +180 -0
  56. julee/domain/models/__init__.py +5 -6
  57. julee/domain/models/assembly/assembly.py +7 -7
  58. julee/domain/models/assembly/tests/factories.py +2 -1
  59. julee/domain/models/assembly/tests/test_assembly.py +16 -13
  60. julee/domain/models/assembly_specification/assembly_specification.py +11 -10
  61. julee/domain/models/assembly_specification/knowledge_service_query.py +14 -9
  62. julee/domain/models/assembly_specification/tests/factories.py +2 -1
  63. julee/domain/models/assembly_specification/tests/test_assembly_specification.py +9 -6
  64. julee/domain/models/assembly_specification/tests/test_knowledge_service_query.py +3 -1
  65. julee/domain/models/custom_fields/content_stream.py +3 -2
  66. julee/domain/models/custom_fields/tests/test_custom_fields.py +2 -1
  67. julee/domain/models/document/document.py +12 -10
  68. julee/domain/models/document/tests/factories.py +3 -2
  69. julee/domain/models/document/tests/test_document.py +6 -3
  70. julee/domain/models/knowledge_service_config/knowledge_service_config.py +4 -4
  71. julee/domain/models/policy/__init__.py +4 -4
  72. julee/domain/models/policy/document_policy_validation.py +17 -17
  73. julee/domain/models/policy/policy.py +12 -10
  74. julee/domain/models/policy/tests/factories.py +2 -1
  75. julee/domain/models/policy/tests/test_document_policy_validation.py +3 -1
  76. julee/domain/models/policy/tests/test_policy.py +2 -1
  77. julee/domain/repositories/__init__.py +3 -3
  78. julee/domain/repositories/assembly.py +3 -1
  79. julee/domain/repositories/assembly_specification.py +2 -0
  80. julee/domain/repositories/base.py +33 -16
  81. julee/domain/repositories/document.py +3 -1
  82. julee/domain/repositories/document_policy_validation.py +3 -1
  83. julee/domain/repositories/knowledge_service_config.py +2 -0
  84. julee/domain/repositories/knowledge_service_query.py +1 -0
  85. julee/domain/repositories/policy.py +3 -1
  86. julee/domain/use_cases/decorators.py +3 -2
  87. julee/domain/use_cases/extract_assemble_data.py +23 -13
  88. julee/domain/use_cases/initialize_system_data.py +13 -13
  89. julee/domain/use_cases/tests/test_extract_assemble_data.py +10 -10
  90. julee/domain/use_cases/tests/test_initialize_system_data.py +2 -2
  91. julee/domain/use_cases/tests/test_validate_document.py +11 -11
  92. julee/domain/use_cases/validate_document.py +26 -15
  93. julee/maintenance/__init__.py +1 -0
  94. julee/maintenance/release.py +188 -0
  95. julee/repositories/__init__.py +4 -1
  96. julee/repositories/memory/assembly.py +6 -5
  97. julee/repositories/memory/assembly_specification.py +9 -9
  98. julee/repositories/memory/base.py +12 -11
  99. julee/repositories/memory/document.py +8 -7
  100. julee/repositories/memory/document_policy_validation.py +7 -6
  101. julee/repositories/memory/knowledge_service_config.py +9 -7
  102. julee/repositories/memory/knowledge_service_query.py +9 -7
  103. julee/repositories/memory/policy.py +6 -5
  104. julee/repositories/memory/tests/test_document.py +6 -4
  105. julee/repositories/memory/tests/test_document_policy_validation.py +2 -1
  106. julee/repositories/memory/tests/test_policy.py +2 -1
  107. julee/repositories/minio/assembly.py +4 -4
  108. julee/repositories/minio/assembly_specification.py +6 -8
  109. julee/repositories/minio/client.py +22 -25
  110. julee/repositories/minio/document.py +11 -11
  111. julee/repositories/minio/document_policy_validation.py +5 -5
  112. julee/repositories/minio/knowledge_service_config.py +8 -8
  113. julee/repositories/minio/knowledge_service_query.py +6 -9
  114. julee/repositories/minio/policy.py +4 -4
  115. julee/repositories/minio/tests/fake_client.py +11 -9
  116. julee/repositories/minio/tests/test_assembly.py +3 -1
  117. julee/repositories/minio/tests/test_assembly_specification.py +2 -1
  118. julee/repositories/minio/tests/test_client_protocol.py +5 -5
  119. julee/repositories/minio/tests/test_document.py +7 -6
  120. julee/repositories/minio/tests/test_document_policy_validation.py +3 -1
  121. julee/repositories/minio/tests/test_knowledge_service_config.py +4 -2
  122. julee/repositories/minio/tests/test_knowledge_service_query.py +3 -2
  123. julee/repositories/minio/tests/test_policy.py +3 -1
  124. julee/repositories/temporal/activities.py +5 -5
  125. julee/repositories/temporal/proxies.py +5 -5
  126. julee/services/knowledge_service/__init__.py +1 -2
  127. julee/services/knowledge_service/anthropic/knowledge_service.py +8 -7
  128. julee/services/knowledge_service/anthropic/tests/test_knowledge_service.py +11 -10
  129. julee/services/knowledge_service/factory.py +8 -8
  130. julee/services/knowledge_service/knowledge_service.py +22 -18
  131. julee/services/knowledge_service/memory/knowledge_service.py +13 -12
  132. julee/services/knowledge_service/memory/test_knowledge_service.py +10 -7
  133. julee/services/knowledge_service/test_factory.py +11 -10
  134. julee/services/temporal/activities.py +10 -10
  135. julee/services/temporal/proxies.py +2 -2
  136. julee/util/domain.py +6 -6
  137. julee/util/repos/minio/file_storage.py +8 -9
  138. julee/util/repos/temporal/client_proxies/file_storage.py +3 -4
  139. julee/util/repos/temporal/data_converter.py +6 -6
  140. julee/util/repos/temporal/minio_file_storage.py +1 -1
  141. julee/util/repos/temporal/proxies/file_storage.py +2 -3
  142. julee/util/repositories.py +6 -7
  143. julee/util/temporal/activities.py +1 -1
  144. julee/util/temporal/decorators.py +28 -33
  145. julee/util/tests/test_decorators.py +13 -15
  146. julee/util/validation/repository.py +3 -3
  147. julee/util/validation/type_guards.py +12 -11
  148. julee/worker.py +9 -8
  149. julee/workflows/__init__.py +2 -2
  150. julee/workflows/extract_assemble.py +2 -1
  151. julee/workflows/validate_document.py +3 -2
  152. {julee-0.1.1.dist-info → julee-0.1.3.dist-info}/METADATA +4 -1
  153. julee-0.1.3.dist-info/RECORD +197 -0
  154. julee-0.1.1.dist-info/RECORD +0 -161
  155. {julee-0.1.1.dist-info → julee-0.1.3.dist-info}/WHEEL +0 -0
  156. {julee-0.1.1.dist-info → julee-0.1.3.dist-info}/licenses/LICENSE +0 -0
  157. {julee-0.1.1.dist-info → julee-0.1.3.dist-info}/top_level.txt +0 -0
@@ -6,9 +6,9 @@ specification repository implementation, using the fake client to avoid
6
6
  external dependencies during testing.
7
7
  """
8
8
 
9
- import pytest
10
9
  from datetime import datetime, timezone
11
10
 
11
+ import pytest
12
12
 
13
13
  from julee.domain.models.assembly_specification import (
14
14
  AssemblySpecification,
@@ -17,6 +17,7 @@ from julee.domain.models.assembly_specification import (
17
17
  from julee.repositories.minio.assembly_specification import (
18
18
  MinioAssemblySpecificationRepository,
19
19
  )
20
+
20
21
  from .fake_client import FakeMinioClient
21
22
 
22
23
 
@@ -34,11 +34,11 @@ class TestMinioClientProtocol:
34
34
  assert hasattr(real_client, "stat_object")
35
35
 
36
36
  # Test that methods are callable
37
- assert callable(getattr(real_client, "bucket_exists"))
38
- assert callable(getattr(real_client, "make_bucket"))
39
- assert callable(getattr(real_client, "put_object"))
40
- assert callable(getattr(real_client, "get_object"))
41
- assert callable(getattr(real_client, "stat_object"))
37
+ assert callable(real_client.bucket_exists)
38
+ assert callable(real_client.make_bucket)
39
+ assert callable(real_client.put_object)
40
+ assert callable(real_client.get_object)
41
+ assert callable(real_client.stat_object)
42
42
 
43
43
  def test_protocol_accepts_real_minio_client(self) -> None:
44
44
  """Test that our protocol accepts a real Minio client instance."""
@@ -6,20 +6,21 @@ without requiring a real MinIO instance. They follow the Clean Architecture
6
6
  testing patterns and verify idempotency, error handling, and content.
7
7
  """
8
8
 
9
- import io
10
- import pytest
11
9
  import hashlib
12
- import multihash
10
+ import io
13
11
  from typing import Any
14
12
  from unittest.mock import Mock
15
- from minio.error import S3Error
16
13
 
14
+ import multihash
15
+ import pytest
16
+ from minio.error import S3Error
17
17
 
18
- from julee.repositories.minio.document import MinioDocumentRepository
19
- from julee.domain.models.document import Document, DocumentStatus
20
18
  from julee.domain.models.custom_fields.content_stream import (
21
19
  ContentStream,
22
20
  )
21
+ from julee.domain.models.document import Document, DocumentStatus
22
+ from julee.repositories.minio.document import MinioDocumentRepository
23
+
23
24
  from .fake_client import FakeMinioClient
24
25
 
25
26
 
@@ -7,9 +7,10 @@ repository that differs from the inherited mixins. Uses the fake client to
7
7
  avoid external dependencies during testing.
8
8
  """
9
9
 
10
- import pytest
11
10
  from datetime import datetime, timezone
12
11
 
12
+ import pytest
13
+
13
14
  from julee.domain.models.policy import (
14
15
  DocumentPolicyValidation,
15
16
  DocumentPolicyValidationStatus,
@@ -17,6 +18,7 @@ from julee.domain.models.policy import (
17
18
  from julee.repositories.minio.document_policy_validation import (
18
19
  MinioDocumentPolicyValidationRepository,
19
20
  )
21
+
20
22
  from .fake_client import FakeMinioClient
21
23
 
22
24
 
@@ -6,16 +6,18 @@ configuration repository implementation, using the fake client to avoid
6
6
  external dependencies during testing.
7
7
  """
8
8
 
9
- import pytest
10
9
  from datetime import datetime, timezone
11
10
 
11
+ import pytest
12
+
12
13
  from julee.domain.models.knowledge_service_config import (
13
14
  KnowledgeServiceConfig,
15
+ ServiceApi,
14
16
  )
15
- from julee.domain.models.knowledge_service_config import ServiceApi
16
17
  from julee.repositories.minio.knowledge_service_config import (
17
18
  MinioKnowledgeServiceConfigRepository,
18
19
  )
20
+
19
21
  from .fake_client import FakeMinioClient
20
22
 
21
23
 
@@ -6,16 +6,17 @@ query repository implementation, using the fake client to avoid external
6
6
  dependencies during testing.
7
7
  """
8
8
 
9
- import pytest
10
-
11
9
  from datetime import datetime, timezone
12
10
 
11
+ import pytest
12
+
13
13
  from julee.domain.models.assembly_specification import (
14
14
  KnowledgeServiceQuery,
15
15
  )
16
16
  from julee.repositories.minio.knowledge_service_query import (
17
17
  MinioKnowledgeServiceQueryRepository,
18
18
  )
19
+
19
20
  from .fake_client import FakeMinioClient
20
21
 
21
22
 
@@ -6,11 +6,13 @@ implementation, using the fake client to avoid external dependencies during
6
6
  testing.
7
7
  """
8
8
 
9
- import pytest
10
9
  from datetime import datetime, timezone
11
10
 
11
+ import pytest
12
+
12
13
  from julee.domain.models.policy import Policy, PolicyStatus
13
14
  from julee.repositories.minio.policy import MinioPolicyRepository
15
+
14
16
  from .fake_client import FakeMinioClient
15
17
 
16
18
 
@@ -10,12 +10,14 @@ The classes follow the naming pattern documented in systemPatterns.org:
10
10
  - Each repository type gets its own activity prefix
11
11
  """
12
12
 
13
- from julee.util.temporal.decorators import temporal_activity_registration
14
13
  from julee.repositories.minio.assembly import MinioAssemblyRepository
15
14
  from julee.repositories.minio.assembly_specification import (
16
15
  MinioAssemblySpecificationRepository,
17
16
  )
18
17
  from julee.repositories.minio.document import MinioDocumentRepository
18
+ from julee.repositories.minio.document_policy_validation import (
19
+ MinioDocumentPolicyValidationRepository,
20
+ )
19
21
  from julee.repositories.minio.knowledge_service_config import (
20
22
  MinioKnowledgeServiceConfigRepository,
21
23
  )
@@ -25,20 +27,18 @@ from julee.repositories.minio.knowledge_service_query import (
25
27
  from julee.repositories.minio.policy import (
26
28
  MinioPolicyRepository,
27
29
  )
28
- from julee.repositories.minio.document_policy_validation import (
29
- MinioDocumentPolicyValidationRepository,
30
- )
31
30
 
32
31
  # Import activity name bases from shared module
33
32
  from julee.repositories.temporal.activity_names import (
34
33
  ASSEMBLY_ACTIVITY_BASE,
35
34
  ASSEMBLY_SPECIFICATION_ACTIVITY_BASE,
36
35
  DOCUMENT_ACTIVITY_BASE,
36
+ DOCUMENT_POLICY_VALIDATION_ACTIVITY_BASE,
37
37
  KNOWLEDGE_SERVICE_CONFIG_ACTIVITY_BASE,
38
38
  KNOWLEDGE_SERVICE_QUERY_ACTIVITY_BASE,
39
39
  POLICY_ACTIVITY_BASE,
40
- DOCUMENT_POLICY_VALIDATION_ACTIVITY_BASE,
41
40
  )
41
+ from julee.util.temporal.decorators import temporal_activity_registration
42
42
 
43
43
 
44
44
  @temporal_activity_registration(ASSEMBLY_ACTIVITY_BASE)
@@ -11,12 +11,14 @@ workflow.execute_activity() with the appropriate activity names, timeouts,
11
11
  and retry policies.
12
12
  """
13
13
 
14
- from julee.util.temporal.decorators import temporal_workflow_proxy
15
14
  from julee.domain.repositories.assembly import AssemblyRepository
16
15
  from julee.domain.repositories.assembly_specification import (
17
16
  AssemblySpecificationRepository,
18
17
  )
19
18
  from julee.domain.repositories.document import DocumentRepository
19
+ from julee.domain.repositories.document_policy_validation import (
20
+ DocumentPolicyValidationRepository,
21
+ )
20
22
  from julee.domain.repositories.knowledge_service_config import (
21
23
  KnowledgeServiceConfigRepository,
22
24
  )
@@ -24,20 +26,18 @@ from julee.domain.repositories.knowledge_service_query import (
24
26
  KnowledgeServiceQueryRepository,
25
27
  )
26
28
  from julee.domain.repositories.policy import PolicyRepository
27
- from julee.domain.repositories.document_policy_validation import (
28
- DocumentPolicyValidationRepository,
29
- )
30
29
 
31
30
  # Import activity name bases from shared module
32
31
  from julee.repositories.temporal.activity_names import (
33
32
  ASSEMBLY_ACTIVITY_BASE,
34
33
  ASSEMBLY_SPECIFICATION_ACTIVITY_BASE,
35
34
  DOCUMENT_ACTIVITY_BASE,
35
+ DOCUMENT_POLICY_VALIDATION_ACTIVITY_BASE,
36
36
  KNOWLEDGE_SERVICE_CONFIG_ACTIVITY_BASE,
37
37
  KNOWLEDGE_SERVICE_QUERY_ACTIVITY_BASE,
38
38
  POLICY_ACTIVITY_BASE,
39
- DOCUMENT_POLICY_VALIDATION_ACTIVITY_BASE,
40
39
  )
40
+ from julee.util.temporal.decorators import temporal_workflow_proxy
41
41
 
42
42
 
43
43
  @temporal_workflow_proxy(
@@ -9,12 +9,11 @@ appropriate implementation based on the service_api configuration.
9
9
  import logging
10
10
 
11
11
  from .knowledge_service import (
12
+ FileRegistrationResult,
12
13
  KnowledgeService,
13
14
  QueryResult,
14
- FileRegistrationResult,
15
15
  )
16
16
 
17
-
18
17
  logger = logging.getLogger(__name__)
19
18
 
20
19
 
@@ -10,23 +10,24 @@ Requirements:
10
10
  - ANTHROPIC_API_KEY environment variable must be set
11
11
  """
12
12
 
13
- import os
14
13
  import logging
14
+ import os
15
15
  import time
16
16
  import uuid
17
- from typing import Optional, List, Dict, Any
18
17
  from datetime import datetime, timezone
18
+ from typing import Any
19
19
 
20
20
  from anthropic import AsyncAnthropic
21
21
 
22
+ from julee.domain.models.document import Document
22
23
  from julee.domain.models.knowledge_service_config import (
23
24
  KnowledgeServiceConfig,
24
25
  )
25
- from julee.domain.models.document import Document
26
+
26
27
  from ..knowledge_service import (
28
+ FileRegistrationResult,
27
29
  KnowledgeService,
28
30
  QueryResult,
29
- FileRegistrationResult,
30
31
  )
31
32
 
32
33
  logger = logging.getLogger(__name__)
@@ -171,9 +172,9 @@ class AnthropicKnowledgeService(KnowledgeService):
171
172
  self,
172
173
  config: KnowledgeServiceConfig,
173
174
  query_text: str,
174
- service_file_ids: Optional[List[str]] = None,
175
- query_metadata: Optional[Dict[str, Any]] = None,
176
- assistant_prompt: Optional[str] = None,
175
+ service_file_ids: list[str] | None = None,
176
+ query_metadata: dict[str, Any] | None = None,
177
+ assistant_prompt: str | None = None,
177
178
  ) -> QueryResult:
178
179
  """Execute a query against Anthropic.
179
180
 
@@ -6,19 +6,20 @@ KnowledgeService protocol, verifying file registration and query
6
6
  execution functionality.
7
7
  """
8
8
 
9
- import pytest
10
- from unittest.mock import AsyncMock, MagicMock, patch
11
- from datetime import datetime, timezone
12
9
  import io
10
+ from datetime import datetime, timezone
11
+ from unittest.mock import AsyncMock, MagicMock, patch
12
+
13
+ import pytest
13
14
 
14
- from julee.domain.models.knowledge_service_config import (
15
- KnowledgeServiceConfig,
16
- )
17
- from julee.domain.models.document import Document, DocumentStatus
18
- from julee.domain.models.knowledge_service_config import ServiceApi
19
15
  from julee.domain.models.custom_fields.content_stream import (
20
16
  ContentStream,
21
17
  )
18
+ from julee.domain.models.document import Document, DocumentStatus
19
+ from julee.domain.models.knowledge_service_config import (
20
+ KnowledgeServiceConfig,
21
+ ServiceApi,
22
+ )
22
23
  from julee.services.knowledge_service.anthropic import (
23
24
  knowledge_service as anthropic_ks,
24
25
  )
@@ -184,7 +185,7 @@ class TestAnthropicKnowledgeService:
184
185
  ) -> None:
185
186
  """Test execute_query handles API errors gracefully."""
186
187
  mock_client = MagicMock()
187
- mock_client.messages.create = AsyncMock(side_effect=Exception("API Error"))
188
+ mock_client.messages.create = AsyncMock(side_effect=RuntimeError("API Error"))
188
189
 
189
190
  with patch(
190
191
  "julee.services.knowledge_service.anthropic.knowledge_service.AsyncAnthropic"
@@ -193,7 +194,7 @@ class TestAnthropicKnowledgeService:
193
194
 
194
195
  service = anthropic_ks.AnthropicKnowledgeService()
195
196
 
196
- with pytest.raises(Exception):
197
+ with pytest.raises(RuntimeError):
197
198
  await service.execute_query(knowledge_service_config, "Test query")
198
199
 
199
200
  @patch.dict("os.environ", {"ANTHROPIC_API_KEY": "test-key"})
@@ -6,20 +6,20 @@ KnowledgeService instances based on the service API configuration.
6
6
  """
7
7
 
8
8
  import logging
9
+ from typing import Any
9
10
 
11
+ from julee.domain.models.document import Document
10
12
  from julee.domain.models.knowledge_service_config import (
11
13
  KnowledgeServiceConfig,
12
14
  ServiceApi,
13
15
  )
14
- from .knowledge_service import KnowledgeService
15
- from .anthropic import AnthropicKnowledgeService
16
- from julee.domain.models.document import Document
17
16
  from julee.services.knowledge_service import (
18
- QueryResult,
19
17
  FileRegistrationResult,
18
+ QueryResult,
20
19
  )
21
- from typing import Dict, Any, List, Optional
22
20
 
21
+ from .anthropic import AnthropicKnowledgeService
22
+ from .knowledge_service import KnowledgeService
23
23
 
24
24
  logger = logging.getLogger(__name__)
25
25
 
@@ -47,9 +47,9 @@ class ConfigurableKnowledgeService(KnowledgeService):
47
47
  self,
48
48
  config: KnowledgeServiceConfig,
49
49
  query_text: str,
50
- service_file_ids: Optional[List[str]] = None,
51
- query_metadata: Optional[Dict[str, Any]] = None,
52
- assistant_prompt: Optional[str] = None,
50
+ service_file_ids: list[str] | None = None,
51
+ query_metadata: dict[str, Any] | None = None,
52
+ assistant_prompt: str | None = None,
53
53
  ) -> QueryResult:
54
54
  """Execute a query against the knowledge service."""
55
55
  service = knowledge_service_factory(config)
@@ -11,16 +11,14 @@ Concrete implementations of this protocol are provided for different external
11
11
  services (Anthropic, OpenAI, etc.) and are created via factory functions.
12
12
  """
13
13
 
14
+ from datetime import datetime, timezone
14
15
  from typing import (
16
+ TYPE_CHECKING,
17
+ Any,
15
18
  Protocol,
16
- Optional,
17
- List,
18
19
  runtime_checkable,
19
- Dict,
20
- Any,
21
- TYPE_CHECKING,
22
20
  )
23
- from datetime import datetime, timezone
21
+
24
22
  from pydantic import BaseModel, Field
25
23
 
26
24
  if TYPE_CHECKING:
@@ -36,15 +34,15 @@ class QueryResult(BaseModel):
36
34
 
37
35
  query_id: str = Field(description="Unique identifier for this query execution")
38
36
  query_text: str = Field(description="The original query text that was executed")
39
- result_data: Dict[str, Any] = Field(
37
+ result_data: dict[str, Any] = Field(
40
38
  default_factory=dict,
41
39
  description="The structured result data from the query",
42
40
  )
43
- execution_time_ms: Optional[int] = Field(
41
+ execution_time_ms: int | None = Field(
44
42
  default=None,
45
43
  description="Time taken to execute the query in milliseconds",
46
44
  )
47
- created_at: Optional[datetime] = Field(
45
+ created_at: datetime | None = Field(
48
46
  default_factory=lambda: datetime.now(timezone.utc)
49
47
  )
50
48
 
@@ -56,11 +54,11 @@ class FileRegistrationResult(BaseModel):
56
54
  knowledge_service_file_id: str = Field(
57
55
  description="The file identifier assigned by the knowledge service"
58
56
  )
59
- registration_metadata: Dict[str, Any] = Field(
57
+ registration_metadata: dict[str, Any] = Field(
60
58
  default_factory=dict,
61
59
  description="Additional metadata from the registration process",
62
60
  )
63
- created_at: Optional[datetime] = Field(
61
+ created_at: datetime | None = Field(
64
62
  default_factory=lambda: datetime.now(timezone.utc)
65
63
  )
66
64
 
@@ -92,17 +90,20 @@ class KnowledgeService(Protocol):
92
90
  FileRegistrationResult containing registration details and the
93
91
  service's internal file identifier
94
92
 
95
- Implementation Notes:
93
+ .. rubric:: Implementation Notes
94
+
96
95
  - Must be idempotent: re-registering same document returns same result
97
96
  - Should handle service unavailability gracefully
98
97
  - Must return the service's internal file ID for future queries
99
98
  - Document content is accessed directly from the Document object
100
99
  - Should handle various document formats and sizes
101
100
 
102
- Workflow Context:
101
+ .. rubric:: Workflow Context
102
+
103
103
  In Temporal workflows, this method is implemented as an activity
104
104
  to ensure registration results are durably stored and consistent
105
105
  across workflow replays.
106
+
106
107
  """
107
108
  ...
108
109
 
@@ -110,9 +111,9 @@ class KnowledgeService(Protocol):
110
111
  self,
111
112
  config: "KnowledgeServiceConfig",
112
113
  query_text: str,
113
- service_file_ids: Optional[List[str]] = None,
114
- query_metadata: Optional[Dict[str, Any]] = None,
115
- assistant_prompt: Optional[str] = None,
114
+ service_file_ids: list[str] | None = None,
115
+ query_metadata: dict[str, Any] | None = None,
116
+ assistant_prompt: str | None = None,
116
117
  ) -> QueryResult:
117
118
  """Execute a query against the external knowledge service.
118
119
 
@@ -141,7 +142,8 @@ class KnowledgeService(Protocol):
141
142
  Returns:
142
143
  QueryResult containing query results and execution metadata
143
144
 
144
- Implementation Notes:
145
+ .. rubric:: Implementation Notes
146
+
145
147
  - Must be idempotent: same query returns consistent results
146
148
  - Service file IDs are provided as context to enhance query responses
147
149
  - Should handle service unavailability gracefully
@@ -152,9 +154,11 @@ class KnowledgeService(Protocol):
152
154
  - Should validate that service_file_ids exist in the service before
153
155
  including them in the query context
154
156
 
155
- Workflow Context:
157
+ .. rubric:: Workflow Context
158
+
156
159
  In Temporal workflows, this method is implemented as an activity
157
160
  to ensure query results are durably stored and can be replayed
158
161
  consistently.
162
+
159
163
  """
160
164
  ...
@@ -8,18 +8,19 @@ scenarios where external service dependencies should be avoided.
8
8
  """
9
9
 
10
10
  import logging
11
- from typing import Optional, List, Dict, Deque, Any
12
- from datetime import datetime, timezone
13
11
  from collections import deque
12
+ from datetime import datetime, timezone
13
+ from typing import Any
14
14
 
15
+ from julee.domain.models.document import Document
15
16
  from julee.domain.models.knowledge_service_config import (
16
17
  KnowledgeServiceConfig,
17
18
  )
18
- from julee.domain.models.document import Document
19
+
19
20
  from ..knowledge_service import (
21
+ FileRegistrationResult,
20
22
  KnowledgeService,
21
23
  QueryResult,
22
- FileRegistrationResult,
23
24
  )
24
25
 
25
26
  logger = logging.getLogger(__name__)
@@ -59,10 +60,10 @@ class MemoryKnowledgeService(KnowledgeService):
59
60
  self.config = config
60
61
 
61
62
  # Storage for file registrations, keyed by knowledge_service_file_id
62
- self._registered_files: Dict[str, FileRegistrationResult] = {}
63
+ self._registered_files: dict[str, FileRegistrationResult] = {}
63
64
 
64
65
  # Queue of canned query results to return
65
- self._canned_query_results: Deque[QueryResult] = deque()
66
+ self._canned_query_results: deque[QueryResult] = deque()
66
67
 
67
68
  def add_canned_query_result(self, query_result: QueryResult) -> None:
68
69
  """Add a canned query result to be returned by execute_query.
@@ -80,7 +81,7 @@ class MemoryKnowledgeService(KnowledgeService):
80
81
  )
81
82
  self._canned_query_results.append(query_result)
82
83
 
83
- def add_canned_query_results(self, query_results: List[QueryResult]) -> None:
84
+ def add_canned_query_results(self, query_results: list[QueryResult]) -> None:
84
85
  """Add multiple canned query results to be returned by execute_query.
85
86
 
86
87
  Args:
@@ -109,7 +110,7 @@ class MemoryKnowledgeService(KnowledgeService):
109
110
 
110
111
  def get_registered_file(
111
112
  self, knowledge_service_file_id: str
112
- ) -> Optional[FileRegistrationResult]:
113
+ ) -> FileRegistrationResult | None:
113
114
  """Get a registered file by its knowledge service file ID.
114
115
 
115
116
  Args:
@@ -120,7 +121,7 @@ class MemoryKnowledgeService(KnowledgeService):
120
121
  """
121
122
  return self._registered_files.get(knowledge_service_file_id)
122
123
 
123
- def get_all_registered_files(self) -> Dict[str, FileRegistrationResult]:
124
+ def get_all_registered_files(self) -> dict[str, FileRegistrationResult]:
124
125
  """Get all registered files.
125
126
 
126
127
  Returns:
@@ -203,9 +204,9 @@ class MemoryKnowledgeService(KnowledgeService):
203
204
  self,
204
205
  config: KnowledgeServiceConfig,
205
206
  query_text: str,
206
- service_file_ids: Optional[List[str]] = None,
207
- query_metadata: Optional[Dict[str, Any]] = None,
208
- assistant_prompt: Optional[str] = None,
207
+ service_file_ids: list[str] | None = None,
208
+ query_metadata: dict[str, Any] | None = None,
209
+ assistant_prompt: str | None = None,
209
210
  ) -> QueryResult:
210
211
  """Execute a query by returning a canned response.
211
212
 
@@ -6,19 +6,22 @@ KnowledgeService protocol, verifying file registration storage and
6
6
  canned query response functionality.
7
7
  """
8
8
 
9
- import pytest
9
+ import io
10
10
  from datetime import datetime, timezone
11
- from julee.domain.models.knowledge_service_config import (
12
- KnowledgeServiceConfig,
13
- )
14
- from julee.domain.models.document import Document, DocumentStatus
15
- from julee.domain.models.knowledge_service_config import ServiceApi
11
+
12
+ import pytest
13
+
16
14
  from julee.domain.models.custom_fields.content_stream import (
17
15
  ContentStream,
18
16
  )
17
+ from julee.domain.models.document import Document, DocumentStatus
18
+ from julee.domain.models.knowledge_service_config import (
19
+ KnowledgeServiceConfig,
20
+ ServiceApi,
21
+ )
22
+
19
23
  from ..knowledge_service import QueryResult
20
24
  from .knowledge_service import MemoryKnowledgeService
21
- import io
22
25
 
23
26
 
24
27
  @pytest.fixture
@@ -5,25 +5,26 @@ This module contains tests for the factory function that creates
5
5
  KnowledgeService implementations based on configuration.
6
6
  """
7
7
 
8
+ import io
9
+ from datetime import datetime, timezone
10
+
8
11
  import pytest
9
12
 
10
- from julee.domain.models.knowledge_service_config import (
11
- KnowledgeServiceConfig,
12
- )
13
- from julee.domain.models.document import Document, DocumentStatus
14
- from julee.domain.models.knowledge_service_config import ServiceApi
15
13
  from julee.domain.models.custom_fields.content_stream import (
16
14
  ContentStream,
17
15
  )
18
- from julee.services.knowledge_service import ensure_knowledge_service
19
- from julee.services.knowledge_service.factory import (
20
- knowledge_service_factory,
16
+ from julee.domain.models.document import Document, DocumentStatus
17
+ from julee.domain.models.knowledge_service_config import (
18
+ KnowledgeServiceConfig,
19
+ ServiceApi,
21
20
  )
21
+ from julee.services.knowledge_service import ensure_knowledge_service
22
22
  from julee.services.knowledge_service.anthropic import (
23
23
  AnthropicKnowledgeService,
24
24
  )
25
- import io
26
- from datetime import datetime, timezone
25
+ from julee.services.knowledge_service.factory import (
26
+ knowledge_service_factory,
27
+ )
27
28
 
28
29
 
29
30
  @pytest.fixture
@@ -13,23 +13,23 @@ The class follows the naming pattern documented in systemPatterns.org:
13
13
 
14
14
  import io
15
15
  import logging
16
+
16
17
  from typing_extensions import override
17
18
 
18
- from julee.util.temporal.decorators import temporal_activity_registration
19
- from julee.services.knowledge_service.factory import (
20
- ConfigurableKnowledgeService,
21
- )
22
- from julee.domain.repositories.document import DocumentRepository
19
+ from julee.domain.models.document import Document
23
20
  from julee.domain.models.knowledge_service_config import (
24
21
  KnowledgeServiceConfig,
25
22
  )
26
- from julee.domain.models.document import Document
27
- from ..knowledge_service import FileRegistrationResult
28
-
29
- # Import activity name bases from shared module
23
+ from julee.domain.repositories.document import DocumentRepository
24
+ from julee.services.knowledge_service.factory import (
25
+ ConfigurableKnowledgeService,
26
+ )
30
27
  from julee.services.temporal.activity_names import (
31
28
  KNOWLEDGE_SERVICE_ACTIVITY_BASE,
32
29
  )
30
+ from julee.util.temporal.decorators import temporal_activity_registration
31
+
32
+ from ..knowledge_service import FileRegistrationResult
33
33
 
34
34
 
35
35
  @temporal_activity_registration(KNOWLEDGE_SERVICE_ACTIVITY_BASE)
@@ -79,7 +79,7 @@ class TemporalKnowledgeService(ConfigurableKnowledgeService):
79
79
  return await super().register_file(config, document)
80
80
 
81
81
 
82
- # Export the temporal service class for use in worker.py
82
+ # Export the temporal service classes for use in worker.py
83
83
  __all__ = [
84
84
  "TemporalKnowledgeService",
85
85
  "KNOWLEDGE_SERVICE_ACTIVITY_BASE",