orchestrator-core 4.4.2__py3-none-any.whl → 4.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.
Files changed (71) hide show
  1. orchestrator/__init__.py +17 -2
  2. orchestrator/agentic_app.py +103 -0
  3. orchestrator/api/api_v1/api.py +14 -2
  4. orchestrator/api/api_v1/endpoints/search.py +296 -0
  5. orchestrator/app.py +32 -0
  6. orchestrator/cli/main.py +22 -1
  7. orchestrator/cli/search/__init__.py +32 -0
  8. orchestrator/cli/search/index_llm.py +73 -0
  9. orchestrator/cli/search/resize_embedding.py +135 -0
  10. orchestrator/cli/search/search_explore.py +208 -0
  11. orchestrator/cli/search/speedtest.py +151 -0
  12. orchestrator/db/models.py +37 -1
  13. orchestrator/devtools/populator.py +16 -0
  14. orchestrator/domain/base.py +2 -7
  15. orchestrator/domain/lifecycle.py +24 -7
  16. orchestrator/llm_settings.py +57 -0
  17. orchestrator/log_config.py +1 -0
  18. orchestrator/migrations/helpers.py +7 -1
  19. orchestrator/schemas/search.py +130 -0
  20. orchestrator/schemas/workflow.py +1 -0
  21. orchestrator/search/__init__.py +12 -0
  22. orchestrator/search/agent/__init__.py +21 -0
  23. orchestrator/search/agent/agent.py +62 -0
  24. orchestrator/search/agent/prompts.py +100 -0
  25. orchestrator/search/agent/state.py +21 -0
  26. orchestrator/search/agent/tools.py +258 -0
  27. orchestrator/search/core/__init__.py +12 -0
  28. orchestrator/search/core/embedding.py +73 -0
  29. orchestrator/search/core/exceptions.py +36 -0
  30. orchestrator/search/core/types.py +296 -0
  31. orchestrator/search/core/validators.py +40 -0
  32. orchestrator/search/docs/index.md +37 -0
  33. orchestrator/search/docs/running_local_text_embedding_inference.md +46 -0
  34. orchestrator/search/filters/__init__.py +40 -0
  35. orchestrator/search/filters/base.py +295 -0
  36. orchestrator/search/filters/date_filters.py +88 -0
  37. orchestrator/search/filters/definitions.py +107 -0
  38. orchestrator/search/filters/ltree_filters.py +56 -0
  39. orchestrator/search/filters/numeric_filter.py +73 -0
  40. orchestrator/search/indexing/__init__.py +16 -0
  41. orchestrator/search/indexing/indexer.py +334 -0
  42. orchestrator/search/indexing/registry.py +101 -0
  43. orchestrator/search/indexing/tasks.py +69 -0
  44. orchestrator/search/indexing/traverse.py +334 -0
  45. orchestrator/search/llm_migration.py +108 -0
  46. orchestrator/search/retrieval/__init__.py +16 -0
  47. orchestrator/search/retrieval/builder.py +123 -0
  48. orchestrator/search/retrieval/engine.py +154 -0
  49. orchestrator/search/retrieval/exceptions.py +90 -0
  50. orchestrator/search/retrieval/pagination.py +96 -0
  51. orchestrator/search/retrieval/retrievers/__init__.py +26 -0
  52. orchestrator/search/retrieval/retrievers/base.py +123 -0
  53. orchestrator/search/retrieval/retrievers/fuzzy.py +94 -0
  54. orchestrator/search/retrieval/retrievers/hybrid.py +277 -0
  55. orchestrator/search/retrieval/retrievers/semantic.py +94 -0
  56. orchestrator/search/retrieval/retrievers/structured.py +39 -0
  57. orchestrator/search/retrieval/utils.py +120 -0
  58. orchestrator/search/retrieval/validation.py +152 -0
  59. orchestrator/search/schemas/__init__.py +12 -0
  60. orchestrator/search/schemas/parameters.py +129 -0
  61. orchestrator/search/schemas/results.py +77 -0
  62. orchestrator/services/processes.py +1 -1
  63. orchestrator/services/settings_env_variables.py +2 -2
  64. orchestrator/settings.py +8 -1
  65. orchestrator/utils/state.py +6 -1
  66. orchestrator/workflows/steps.py +15 -1
  67. orchestrator/workflows/tasks/validate_products.py +1 -1
  68. {orchestrator_core-4.4.2.dist-info → orchestrator_core-4.5.0.dist-info}/METADATA +15 -8
  69. {orchestrator_core-4.4.2.dist-info → orchestrator_core-4.5.0.dist-info}/RECORD +71 -21
  70. {orchestrator_core-4.4.2.dist-info → orchestrator_core-4.5.0.dist-info}/WHEEL +0 -0
  71. {orchestrator_core-4.4.2.dist-info → orchestrator_core-4.5.0.dist-info}/licenses/LICENSE +0 -0
orchestrator/__init__.py CHANGED
@@ -13,15 +13,30 @@
13
13
 
14
14
  """This is the orchestrator workflow engine."""
15
15
 
16
- __version__ = "4.4.2"
16
+ __version__ = "4.5.0"
17
17
 
18
- from orchestrator.app import OrchestratorCore
18
+
19
+ from structlog import get_logger
20
+
21
+ logger = get_logger(__name__)
22
+
23
+ logger.info("Starting the orchestrator", version=__version__)
24
+
25
+ from orchestrator.llm_settings import llm_settings
19
26
  from orchestrator.settings import app_settings
27
+
28
+ if llm_settings.SEARCH_ENABLED or llm_settings.AGENT_ENABLED:
29
+
30
+ from orchestrator.agentic_app import LLMOrchestratorCore as OrchestratorCore
31
+ else:
32
+ from orchestrator.app import OrchestratorCore # type: ignore[assignment]
33
+
20
34
  from orchestrator.workflow import begin, conditional, done, focussteps, inputstep, retrystep, step, steplens, workflow
21
35
 
22
36
  __all__ = [
23
37
  "OrchestratorCore",
24
38
  "app_settings",
39
+ "llm_settings",
25
40
  "step",
26
41
  "inputstep",
27
42
  "workflow",
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env python3
2
+ """The main application module.
3
+
4
+ This module contains the main `LLMOrchestratorCore` class for the `FastAPI` backend and
5
+ provides the ability to run the CLI with LLM features (search and/or agent).
6
+ """
7
+ # Copyright 2019-2025 SURF
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ from typing import TYPE_CHECKING, Any
20
+
21
+ import typer
22
+ from structlog import get_logger
23
+
24
+ from orchestrator.app import OrchestratorCore
25
+ from orchestrator.cli.main import app as cli_app
26
+ from orchestrator.llm_settings import LLMSettings, llm_settings
27
+
28
+ if TYPE_CHECKING:
29
+ from pydantic_ai.models.openai import OpenAIModel
30
+ from pydantic_ai.toolsets import FunctionToolset
31
+
32
+ logger = get_logger(__name__)
33
+
34
+
35
+ class LLMOrchestratorCore(OrchestratorCore):
36
+ def __init__(
37
+ self,
38
+ *args: Any,
39
+ llm_settings: LLMSettings = llm_settings,
40
+ agent_model: "OpenAIModel | str | None" = None,
41
+ agent_tools: "list[FunctionToolset] | None" = None,
42
+ **kwargs: Any,
43
+ ) -> None:
44
+ """Initialize the `LLMOrchestratorCore` class.
45
+
46
+ This class extends `OrchestratorCore` with LLM features (search and agent).
47
+ It runs the search migration and mounts the agent endpoint based on feature flags.
48
+
49
+ Args:
50
+ *args: All the normal arguments passed to the `OrchestratorCore` class.
51
+ llm_settings: A class of settings for the LLM
52
+ agent_model: Override the agent model (defaults to llm_settings.AGENT_MODEL)
53
+ agent_tools: A list of tools that can be used by the agent
54
+ **kwargs: Additional arguments passed to the `OrchestratorCore` class.
55
+
56
+ Returns:
57
+ None
58
+ """
59
+ self.llm_settings = llm_settings
60
+ self.agent_model = agent_model or llm_settings.AGENT_MODEL
61
+ self.agent_tools = agent_tools
62
+
63
+ super().__init__(*args, **kwargs)
64
+
65
+ # Run search migration if search or agent is enabled
66
+ if self.llm_settings.SEARCH_ENABLED or self.llm_settings.AGENT_ENABLED:
67
+ logger.info("Running search migration")
68
+ try:
69
+ from orchestrator.db import db
70
+ from orchestrator.search.llm_migration import run_migration
71
+
72
+ with db.engine.begin() as connection:
73
+ run_migration(connection)
74
+ except ImportError as e:
75
+ logger.error(
76
+ "Unable to run search migration. Please install search dependencies: "
77
+ "`pip install orchestrator-core[search]`",
78
+ error=str(e),
79
+ )
80
+ raise
81
+
82
+ # Mount agent endpoint if agent is enabled
83
+ if self.llm_settings.AGENT_ENABLED:
84
+ logger.info("Initializing agent features", model=self.agent_model)
85
+ try:
86
+ from orchestrator.search.agent import build_agent_router
87
+
88
+ agent_app = build_agent_router(self.agent_model, self.agent_tools)
89
+ self.mount("/agent", agent_app)
90
+ except ImportError as e:
91
+ logger.error(
92
+ "Unable to initialize agent features. Please install agent dependencies: "
93
+ "`pip install orchestrator-core[agent]`",
94
+ error=str(e),
95
+ )
96
+ raise
97
+
98
+
99
+ main_typer_app = typer.Typer()
100
+ main_typer_app.add_typer(cli_app, name="orchestrator", help="The orchestrator CLI commands")
101
+
102
+ if __name__ == "__main__":
103
+ main_typer_app()
@@ -30,6 +30,7 @@ from orchestrator.api.api_v1.endpoints import (
30
30
  workflows,
31
31
  ws,
32
32
  )
33
+ from orchestrator.llm_settings import llm_settings
33
34
  from orchestrator.security import authorize
34
35
 
35
36
  api_router = APIRouter()
@@ -75,11 +76,22 @@ api_router.include_router(user.router, prefix="/user", tags=["Core", "User"], de
75
76
  api_router.include_router(
76
77
  settings.router, prefix="/settings", tags=["Core", "Settings"], dependencies=[Depends(authorize)]
77
78
  )
78
- api_router.include_router(settings.ws_router, prefix="/settings", tags=["Core", "Settings"])
79
+ api_router.include_router(
80
+ settings.ws_router, prefix="/settings", tags=["Core", "Settings"]
81
+ ) # Auth on the websocket is handled in the Websocket Manager
79
82
  api_router.include_router(health.router, prefix="/health", tags=["Core"])
80
83
  api_router.include_router(
81
84
  translations.router,
82
85
  prefix="/translations",
83
86
  tags=["Core", "Translations"],
84
87
  )
85
- api_router.include_router(ws.router, prefix="/ws", tags=["Core", "Events"])
88
+ api_router.include_router(
89
+ ws.router, prefix="/ws", tags=["Core", "Events"]
90
+ ) # Auth on the websocket is handled in the Websocket Manager
91
+
92
+ if llm_settings.SEARCH_ENABLED:
93
+ from orchestrator.api.api_v1.endpoints import search
94
+
95
+ api_router.include_router(
96
+ search.router, prefix="/search", tags=["Core", "Search"], dependencies=[Depends(authorize)]
97
+ )
@@ -0,0 +1,296 @@
1
+ # Copyright 2019-2025 SURF, GÉANT.
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+
14
+ from typing import Any, Literal, overload
15
+
16
+ from fastapi import APIRouter, HTTPException, Query, status
17
+ from sqlalchemy import case, select
18
+ from sqlalchemy.orm import selectinload
19
+
20
+ from orchestrator.db import (
21
+ ProcessTable,
22
+ ProductTable,
23
+ WorkflowTable,
24
+ db,
25
+ )
26
+ from orchestrator.domain.base import SubscriptionModel
27
+ from orchestrator.domain.context_cache import cache_subscription_models
28
+ from orchestrator.schemas.search import (
29
+ PageInfoSchema,
30
+ PathsResponse,
31
+ ProcessSearchResult,
32
+ ProcessSearchSchema,
33
+ ProductSearchResult,
34
+ ProductSearchSchema,
35
+ SearchResultsSchema,
36
+ SubscriptionSearchResult,
37
+ WorkflowSearchResult,
38
+ WorkflowSearchSchema,
39
+ )
40
+ from orchestrator.search.core.exceptions import InvalidCursorError
41
+ from orchestrator.search.core.types import EntityType, UIType
42
+ from orchestrator.search.filters.definitions import generate_definitions
43
+ from orchestrator.search.indexing.registry import ENTITY_CONFIG_REGISTRY
44
+ from orchestrator.search.retrieval import execute_search
45
+ from orchestrator.search.retrieval.builder import build_paths_query, create_path_autocomplete_lquery, process_path_rows
46
+ from orchestrator.search.retrieval.pagination import (
47
+ create_next_page_cursor,
48
+ process_pagination_cursor,
49
+ )
50
+ from orchestrator.search.retrieval.validation import is_lquery_syntactically_valid
51
+ from orchestrator.search.schemas.parameters import (
52
+ BaseSearchParameters,
53
+ ProcessSearchParameters,
54
+ ProductSearchParameters,
55
+ SubscriptionSearchParameters,
56
+ WorkflowSearchParameters,
57
+ )
58
+ from orchestrator.search.schemas.results import SearchResult, TypeDefinition
59
+ from orchestrator.services.subscriptions import format_special_types
60
+
61
+ router = APIRouter()
62
+
63
+
64
+ def _create_search_result_item(
65
+ entity: WorkflowTable | ProductTable | ProcessTable, entity_type: EntityType, search_info: SearchResult
66
+ ) -> WorkflowSearchResult | ProductSearchResult | ProcessSearchResult | None:
67
+ match entity_type:
68
+ case EntityType.WORKFLOW:
69
+ workflow_data = WorkflowSearchSchema.model_validate(entity)
70
+ return WorkflowSearchResult(
71
+ workflow=workflow_data,
72
+ score=search_info.score,
73
+ perfect_match=search_info.perfect_match,
74
+ matching_field=search_info.matching_field,
75
+ )
76
+ case EntityType.PRODUCT:
77
+ product_data = ProductSearchSchema.model_validate(entity)
78
+ return ProductSearchResult(
79
+ product=product_data,
80
+ score=search_info.score,
81
+ perfect_match=search_info.perfect_match,
82
+ matching_field=search_info.matching_field,
83
+ )
84
+ case EntityType.PROCESS:
85
+ process_data = ProcessSearchSchema.model_validate(entity)
86
+ return ProcessSearchResult(
87
+ process=process_data,
88
+ score=search_info.score,
89
+ perfect_match=search_info.perfect_match,
90
+ matching_field=search_info.matching_field,
91
+ )
92
+ case _:
93
+ return None
94
+
95
+
96
+ @overload
97
+ async def _perform_search_and_fetch(
98
+ search_params: BaseSearchParameters,
99
+ entity_type: Literal[EntityType.WORKFLOW],
100
+ eager_loads: list[Any],
101
+ cursor: str | None = None,
102
+ ) -> SearchResultsSchema[WorkflowSearchResult]: ...
103
+
104
+
105
+ @overload
106
+ async def _perform_search_and_fetch(
107
+ search_params: BaseSearchParameters,
108
+ entity_type: Literal[EntityType.PRODUCT],
109
+ eager_loads: list[Any],
110
+ cursor: str | None = None,
111
+ ) -> SearchResultsSchema[ProductSearchResult]: ...
112
+
113
+
114
+ @overload
115
+ async def _perform_search_and_fetch(
116
+ search_params: BaseSearchParameters,
117
+ entity_type: Literal[EntityType.PROCESS],
118
+ eager_loads: list[Any],
119
+ cursor: str | None = None,
120
+ ) -> SearchResultsSchema[ProcessSearchResult]: ...
121
+
122
+
123
+ async def _perform_search_and_fetch(
124
+ search_params: BaseSearchParameters,
125
+ entity_type: EntityType,
126
+ eager_loads: list[Any],
127
+ cursor: str | None = None,
128
+ ) -> SearchResultsSchema[Any]:
129
+ try:
130
+ pagination_params = await process_pagination_cursor(cursor, search_params)
131
+ except InvalidCursorError:
132
+ raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid pagination cursor")
133
+
134
+ search_response = await execute_search(
135
+ search_params=search_params,
136
+ db_session=db.session,
137
+ pagination_params=pagination_params,
138
+ )
139
+ if not search_response.results:
140
+ return SearchResultsSchema(search_metadata=search_response.metadata)
141
+
142
+ next_page_cursor = create_next_page_cursor(search_response.results, pagination_params, search_params.limit)
143
+ has_next_page = next_page_cursor is not None
144
+ page_info = PageInfoSchema(has_next_page=has_next_page, next_page_cursor=next_page_cursor)
145
+
146
+ config = ENTITY_CONFIG_REGISTRY[entity_type]
147
+ entity_ids = [res.entity_id for res in search_response.results]
148
+ pk_column = getattr(config.table, config.pk_name)
149
+ ordering_case = case({entity_id: i for i, entity_id in enumerate(entity_ids)}, value=pk_column)
150
+
151
+ stmt = select(config.table).options(*eager_loads).filter(pk_column.in_(entity_ids)).order_by(ordering_case)
152
+ entities = db.session.scalars(stmt).all()
153
+
154
+ search_info_map = {res.entity_id: res for res in search_response.results}
155
+ data = []
156
+ for entity in entities:
157
+ entity_id = getattr(entity, config.pk_name)
158
+ search_info = search_info_map.get(str(entity_id))
159
+ if not search_info:
160
+ continue
161
+
162
+ search_result_item = _create_search_result_item(entity, entity_type, search_info)
163
+ if search_result_item:
164
+ data.append(search_result_item)
165
+
166
+ return SearchResultsSchema(data=data, page_info=page_info, search_metadata=search_response.metadata)
167
+
168
+
169
+ @router.post(
170
+ "/subscriptions",
171
+ response_model=SearchResultsSchema[SubscriptionSearchResult],
172
+ )
173
+ async def search_subscriptions(
174
+ search_params: SubscriptionSearchParameters,
175
+ cursor: str | None = None,
176
+ ) -> SearchResultsSchema[SubscriptionSearchResult]:
177
+ try:
178
+ pagination_params = await process_pagination_cursor(cursor, search_params)
179
+ except InvalidCursorError:
180
+ raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid pagination cursor")
181
+
182
+ search_response = await execute_search(
183
+ search_params=search_params,
184
+ db_session=db.session,
185
+ pagination_params=pagination_params,
186
+ )
187
+
188
+ if not search_response.results:
189
+ return SearchResultsSchema(search_metadata=search_response.metadata)
190
+
191
+ next_page_cursor = create_next_page_cursor(search_response.results, pagination_params, search_params.limit)
192
+ has_next_page = next_page_cursor is not None
193
+ page_info = PageInfoSchema(has_next_page=has_next_page, next_page_cursor=next_page_cursor)
194
+
195
+ search_info_map = {res.entity_id: res for res in search_response.results}
196
+
197
+ with cache_subscription_models():
198
+ subscriptions_data = {
199
+ sub_id: SubscriptionModel.from_subscription(sub_id).model_dump(exclude_unset=False)
200
+ for sub_id in search_info_map
201
+ }
202
+
203
+ results_data = [
204
+ SubscriptionSearchResult(
205
+ subscription=format_special_types(subscriptions_data[sub_id]),
206
+ score=search_info.score,
207
+ perfect_match=search_info.perfect_match,
208
+ matching_field=search_info.matching_field,
209
+ )
210
+ for sub_id, search_info in search_info_map.items()
211
+ ]
212
+
213
+ return SearchResultsSchema(data=results_data, page_info=page_info, search_metadata=search_response.metadata)
214
+
215
+
216
+ @router.post("/workflows", response_model=SearchResultsSchema[WorkflowSearchResult])
217
+ async def search_workflows(
218
+ search_params: WorkflowSearchParameters,
219
+ cursor: str | None = None,
220
+ ) -> SearchResultsSchema[WorkflowSearchResult]:
221
+ return await _perform_search_and_fetch(
222
+ search_params=search_params,
223
+ entity_type=EntityType.WORKFLOW,
224
+ eager_loads=[selectinload(WorkflowTable.products)],
225
+ cursor=cursor,
226
+ )
227
+
228
+
229
+ @router.post("/products", response_model=SearchResultsSchema[ProductSearchResult])
230
+ async def search_products(
231
+ search_params: ProductSearchParameters,
232
+ cursor: str | None = None,
233
+ ) -> SearchResultsSchema[ProductSearchResult]:
234
+ return await _perform_search_and_fetch(
235
+ search_params=search_params,
236
+ entity_type=EntityType.PRODUCT,
237
+ eager_loads=[
238
+ selectinload(ProductTable.workflows),
239
+ selectinload(ProductTable.fixed_inputs),
240
+ selectinload(ProductTable.product_blocks),
241
+ ],
242
+ cursor=cursor,
243
+ )
244
+
245
+
246
+ @router.post("/processes", response_model=SearchResultsSchema[ProcessSearchResult])
247
+ async def search_processes(
248
+ search_params: ProcessSearchParameters,
249
+ cursor: str | None = None,
250
+ ) -> SearchResultsSchema[ProcessSearchResult]:
251
+ return await _perform_search_and_fetch(
252
+ search_params=search_params,
253
+ entity_type=EntityType.PROCESS,
254
+ eager_loads=[
255
+ selectinload(ProcessTable.workflow),
256
+ ],
257
+ cursor=cursor,
258
+ )
259
+
260
+
261
+ @router.get(
262
+ "/paths",
263
+ response_model=PathsResponse,
264
+ response_model_exclude_none=True,
265
+ )
266
+ async def list_paths(
267
+ prefix: str = Query("", min_length=0),
268
+ q: str | None = Query(None, description="Query for path suggestions"),
269
+ entity_type: EntityType = Query(EntityType.SUBSCRIPTION),
270
+ limit: int = Query(10, ge=1, le=10),
271
+ ) -> PathsResponse:
272
+
273
+ if prefix:
274
+ lquery_pattern = create_path_autocomplete_lquery(prefix)
275
+
276
+ if not is_lquery_syntactically_valid(lquery_pattern, db.session):
277
+ raise HTTPException(
278
+ status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
279
+ detail=f"Prefix '{prefix}' creates an invalid search pattern.",
280
+ )
281
+ stmt = build_paths_query(entity_type=entity_type, prefix=prefix, q=q)
282
+ stmt = stmt.limit(limit)
283
+ rows = db.session.execute(stmt).all()
284
+
285
+ leaves, components = process_path_rows(rows)
286
+ return PathsResponse(leaves=leaves, components=components)
287
+
288
+
289
+ @router.get(
290
+ "/definitions",
291
+ response_model=dict[UIType, TypeDefinition],
292
+ response_model_exclude_none=True,
293
+ )
294
+ async def get_definitions() -> dict[UIType, TypeDefinition]:
295
+ """Provide a static definition of operators and schemas for each UI type."""
296
+ return generate_definitions()
orchestrator/app.py CHANGED
@@ -90,6 +90,22 @@ class OrchestratorCore(FastAPI):
90
90
  base_settings: AppSettings = app_settings,
91
91
  **kwargs: Any,
92
92
  ) -> None:
93
+ """Initialize the Orchestrator.
94
+
95
+ Args:
96
+ title: Name of the application.
97
+ description: Description of the application.
98
+ openapi_url: Location of the OpenAPI endpoint.
99
+ docs_url: Location of the docs endpoint.
100
+ redoc_url: Location of the redoc endpoint.
101
+ version: Version of the application.
102
+ default_response_class: Override the default response class.
103
+ base_settings: Settings for the application.
104
+ **kwargs: Any additional keyword arguments are sent to the
105
+
106
+ Returns:
107
+ None
108
+ """
93
109
  initialise_logging(LOGGER_OVERRIDES)
94
110
  init_model_loaders()
95
111
  if base_settings.ENABLE_GRAPHQL_STATS_EXTENSION:
@@ -163,6 +179,22 @@ class OrchestratorCore(FastAPI):
163
179
  release: str | None = GIT_COMMIT_HASH,
164
180
  **sentry_kwargs: Any,
165
181
  ) -> None:
182
+ """Register sentry to your application.
183
+
184
+ Sentry is an application monitoring toolkit.
185
+
186
+ Args:
187
+ sentry_dsn: The location where sentry traces are posted to.
188
+ trace_sample_rate: The sample rate
189
+ server_name: The name of the application
190
+ environment: Production or development
191
+ release: Version of the application
192
+ **sentry_kwargs: Any sentry keyword arguments
193
+
194
+ Returns:
195
+ None
196
+
197
+ """
166
198
  logger.info("Adding Sentry middleware to app", app=self.title)
167
199
  if self.base_settings.EXECUTOR == ExecutorType.WORKER:
168
200
  from sentry_sdk.integrations.celery import CeleryIntegration
orchestrator/cli/main.py CHANGED
@@ -13,13 +13,34 @@
13
13
 
14
14
  import typer
15
15
 
16
- from orchestrator.cli import database, generate, scheduler
16
+ from orchestrator.cli import (
17
+ database,
18
+ generate,
19
+ scheduler,
20
+ )
21
+ from orchestrator.llm_settings import llm_settings
17
22
 
18
23
  app = typer.Typer()
19
24
  app.add_typer(scheduler.app, name="scheduler", help="Access all the scheduler functions")
20
25
  app.add_typer(database.app, name="db", help="Interact with the application database")
21
26
  app.add_typer(generate.app, name="generate", help="Generate products, workflows and other artifacts")
22
27
 
28
+ if llm_settings.SEARCH_ENABLED:
29
+ from orchestrator.cli.search import index_llm, resize_embedding, search_explore, speedtest
30
+
31
+ app.add_typer(index_llm.app, name="index", help="(Re-)Index the search table.")
32
+ app.add_typer(search_explore.app, name="search", help="Try out different search types.")
33
+ app.add_typer(
34
+ resize_embedding.app,
35
+ name="embedding",
36
+ help="Resize the vector dimension of the embedding column in the search table.",
37
+ )
38
+ app.add_typer(
39
+ speedtest.app,
40
+ name="speedtest",
41
+ help="Search performance testing and analysis.",
42
+ )
43
+
23
44
 
24
45
  if __name__ == "__main__":
25
46
  app()
@@ -0,0 +1,32 @@
1
+ # Copyright 2019-2020 SURF.
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+
14
+ import typer
15
+
16
+ from orchestrator.cli.search import index_llm, resize_embedding, search_explore, speedtest
17
+
18
+
19
+ def register_commands(app: typer.Typer) -> None:
20
+ """Register all LLM/search related commands to the main app."""
21
+ app.add_typer(index_llm.app, name="index", help="(Re-)Index the search table.")
22
+ app.add_typer(search_explore.app, name="search", help="Try out different search types.")
23
+ app.add_typer(
24
+ resize_embedding.app,
25
+ name="embedding",
26
+ help="Resize the vector dimension of the embedding column in the search table.",
27
+ )
28
+ app.add_typer(
29
+ speedtest.app,
30
+ name="speedtest",
31
+ help="Search performance testing and analysis.",
32
+ )
@@ -0,0 +1,73 @@
1
+ import typer
2
+
3
+ from orchestrator.search.core.types import EntityType
4
+ from orchestrator.search.indexing import run_indexing_for_entity
5
+
6
+ app = typer.Typer(
7
+ name="index",
8
+ help="Index search indexes",
9
+ )
10
+
11
+
12
+ @app.command("subscriptions")
13
+ def subscriptions_command(
14
+ subscription_id: str | None = typer.Option(None, help="UUID (default = all)"),
15
+ dry_run: bool = typer.Option(False, help="No DB writes"),
16
+ force_index: bool = typer.Option(False, help="Force re-index (ignore hash cache)"),
17
+ ) -> None:
18
+ """Index subscription_search_index."""
19
+ run_indexing_for_entity(
20
+ entity_kind=EntityType.SUBSCRIPTION,
21
+ entity_id=subscription_id,
22
+ dry_run=dry_run,
23
+ force_index=force_index,
24
+ )
25
+
26
+
27
+ @app.command("products")
28
+ def products_command(
29
+ product_id: str | None = typer.Option(None, help="UUID (default = all)"),
30
+ dry_run: bool = typer.Option(False, help="No DB writes"),
31
+ force_index: bool = typer.Option(False, help="Force re-index (ignore hash cache)"),
32
+ ) -> None:
33
+ """Index product_search_index."""
34
+ run_indexing_for_entity(
35
+ entity_kind=EntityType.PRODUCT,
36
+ entity_id=product_id,
37
+ dry_run=dry_run,
38
+ force_index=force_index,
39
+ )
40
+
41
+
42
+ @app.command("processes")
43
+ def processes_command(
44
+ process_id: str | None = typer.Option(None, help="UUID (default = all)"),
45
+ dry_run: bool = typer.Option(False, help="No DB writes"),
46
+ force_index: bool = typer.Option(False, help="Force re-index (ignore hash cache)"),
47
+ ) -> None:
48
+ """Index process_search_index."""
49
+ run_indexing_for_entity(
50
+ entity_kind=EntityType.PROCESS,
51
+ entity_id=process_id,
52
+ dry_run=dry_run,
53
+ force_index=force_index,
54
+ )
55
+
56
+
57
+ @app.command("workflows")
58
+ def workflows_command(
59
+ workflow_id: str | None = typer.Option(None, help="UUID (default = all)"),
60
+ dry_run: bool = typer.Option(False, help="No DB writes"),
61
+ force_index: bool = typer.Option(False, help="Force re-index (ignore hash cache)"),
62
+ ) -> None:
63
+ """Index workflow_search_index."""
64
+ run_indexing_for_entity(
65
+ entity_kind=EntityType.WORKFLOW,
66
+ entity_id=workflow_id,
67
+ dry_run=dry_run,
68
+ force_index=force_index,
69
+ )
70
+
71
+
72
+ if __name__ == "__main__":
73
+ app()