orchestrator-core 4.4.1__py3-none-any.whl → 4.5.0a3__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.
- orchestrator/__init__.py +26 -2
- orchestrator/agentic_app.py +84 -0
- orchestrator/api/api_v1/api.py +10 -0
- orchestrator/api/api_v1/endpoints/search.py +290 -0
- orchestrator/app.py +32 -0
- orchestrator/cli/index_llm.py +73 -0
- orchestrator/cli/main.py +22 -1
- orchestrator/cli/resize_embedding.py +135 -0
- orchestrator/cli/search_explore.py +208 -0
- orchestrator/cli/speedtest.py +151 -0
- orchestrator/db/models.py +37 -1
- orchestrator/devtools/populator.py +16 -0
- orchestrator/llm_settings.py +51 -0
- orchestrator/log_config.py +1 -0
- orchestrator/migrations/helpers.py +1 -1
- orchestrator/migrations/versions/schema/2025-08-12_52b37b5b2714_search_index_model_for_llm_integration.py +95 -0
- orchestrator/schemas/search.py +130 -0
- orchestrator/schemas/workflow.py +1 -0
- orchestrator/search/__init__.py +12 -0
- orchestrator/search/agent/__init__.py +21 -0
- orchestrator/search/agent/agent.py +60 -0
- orchestrator/search/agent/prompts.py +100 -0
- orchestrator/search/agent/state.py +21 -0
- orchestrator/search/agent/tools.py +258 -0
- orchestrator/search/core/__init__.py +12 -0
- orchestrator/search/core/embedding.py +73 -0
- orchestrator/search/core/exceptions.py +36 -0
- orchestrator/search/core/types.py +296 -0
- orchestrator/search/core/validators.py +40 -0
- orchestrator/search/docs/index.md +37 -0
- orchestrator/search/docs/running_local_text_embedding_inference.md +45 -0
- orchestrator/search/filters/__init__.py +40 -0
- orchestrator/search/filters/base.py +280 -0
- orchestrator/search/filters/date_filters.py +88 -0
- orchestrator/search/filters/definitions.py +107 -0
- orchestrator/search/filters/ltree_filters.py +56 -0
- orchestrator/search/filters/numeric_filter.py +73 -0
- orchestrator/search/indexing/__init__.py +16 -0
- orchestrator/search/indexing/indexer.py +336 -0
- orchestrator/search/indexing/registry.py +101 -0
- orchestrator/search/indexing/tasks.py +66 -0
- orchestrator/search/indexing/traverse.py +334 -0
- orchestrator/search/retrieval/__init__.py +16 -0
- orchestrator/search/retrieval/builder.py +123 -0
- orchestrator/search/retrieval/engine.py +158 -0
- orchestrator/search/retrieval/exceptions.py +90 -0
- orchestrator/search/retrieval/pagination.py +96 -0
- orchestrator/search/retrieval/retrievers/__init__.py +26 -0
- orchestrator/search/retrieval/retrievers/base.py +122 -0
- orchestrator/search/retrieval/retrievers/fuzzy.py +94 -0
- orchestrator/search/retrieval/retrievers/hybrid.py +188 -0
- orchestrator/search/retrieval/retrievers/semantic.py +94 -0
- orchestrator/search/retrieval/retrievers/structured.py +39 -0
- orchestrator/search/retrieval/utils.py +120 -0
- orchestrator/search/retrieval/validation.py +152 -0
- orchestrator/search/schemas/__init__.py +12 -0
- orchestrator/search/schemas/parameters.py +129 -0
- orchestrator/search/schemas/results.py +77 -0
- orchestrator/services/settings_env_variables.py +2 -2
- orchestrator/settings.py +1 -1
- orchestrator/workflows/tasks/validate_products.py +1 -1
- {orchestrator_core-4.4.1.dist-info → orchestrator_core-4.5.0a3.dist-info}/METADATA +9 -4
- {orchestrator_core-4.4.1.dist-info → orchestrator_core-4.5.0a3.dist-info}/RECORD +65 -16
- {orchestrator_core-4.4.1.dist-info → orchestrator_core-4.5.0a3.dist-info}/WHEEL +0 -0
- {orchestrator_core-4.4.1.dist-info → orchestrator_core-4.5.0a3.dist-info}/licenses/LICENSE +0 -0
orchestrator/__init__.py
CHANGED
|
@@ -13,15 +13,39 @@
|
|
|
13
13
|
|
|
14
14
|
"""This is the orchestrator workflow engine."""
|
|
15
15
|
|
|
16
|
-
__version__ = "4.
|
|
16
|
+
__version__ = "4.5.0a3"
|
|
17
17
|
|
|
18
|
-
|
|
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.LLM_ENABLED:
|
|
29
|
+
try:
|
|
30
|
+
from importlib import import_module
|
|
31
|
+
|
|
32
|
+
import_module("pydantic_ai")
|
|
33
|
+
from orchestrator.agentic_app import AgenticOrchestratorCore as OrchestratorCore
|
|
34
|
+
|
|
35
|
+
except ImportError:
|
|
36
|
+
logger.error(
|
|
37
|
+
"Unable to import 'pydantic_ai' module, please install the orchestrator with llm dependencies. `pip install orchestrator-core[llm]",
|
|
38
|
+
)
|
|
39
|
+
exit(1)
|
|
40
|
+
else:
|
|
41
|
+
from orchestrator.app import OrchestratorCore # type: ignore[assignment]
|
|
42
|
+
|
|
20
43
|
from orchestrator.workflow import begin, conditional, done, focussteps, inputstep, retrystep, step, steplens, workflow
|
|
21
44
|
|
|
22
45
|
__all__ = [
|
|
23
46
|
"OrchestratorCore",
|
|
24
47
|
"app_settings",
|
|
48
|
+
"llm_settings",
|
|
25
49
|
"step",
|
|
26
50
|
"inputstep",
|
|
27
51
|
"workflow",
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""The main application module.
|
|
3
|
+
|
|
4
|
+
This module contains the main `AgenticOrchestratorCore` class for the `FastAPI` backend and
|
|
5
|
+
provides the ability to run the CLI.
|
|
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 Any
|
|
20
|
+
|
|
21
|
+
import typer
|
|
22
|
+
from pydantic_ai.models.openai import OpenAIModel
|
|
23
|
+
from pydantic_ai.toolsets import FunctionToolset
|
|
24
|
+
from structlog import get_logger
|
|
25
|
+
|
|
26
|
+
from orchestrator.app import OrchestratorCore
|
|
27
|
+
from orchestrator.cli.main import app as cli_app
|
|
28
|
+
from orchestrator.llm_settings import LLMSettings, llm_settings
|
|
29
|
+
|
|
30
|
+
logger = get_logger(__name__)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class AgenticOrchestratorCore(OrchestratorCore):
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
*args: Any,
|
|
37
|
+
llm_model: OpenAIModel | str = "gpt-4o-mini",
|
|
38
|
+
llm_settings: LLMSettings = llm_settings,
|
|
39
|
+
agent_tools: list[FunctionToolset] | None = None,
|
|
40
|
+
**kwargs: Any,
|
|
41
|
+
) -> None:
|
|
42
|
+
"""Initialize the `AgenticOrchestratorCore` class.
|
|
43
|
+
|
|
44
|
+
This class takes the same arguments as the `OrchestratorCore` class.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
*args: All the normal arguments passed to the `OrchestratorCore` class.
|
|
48
|
+
llm_model: An OpenAI model class or string, not limited to OpenAI models (gpt-4o-mini etc)
|
|
49
|
+
llm_settings: A class of settings for the LLM
|
|
50
|
+
agent_tools: A list of tools that can be used by the agent
|
|
51
|
+
**kwargs: Additional arguments passed to the `OrchestratorCore` class.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
None
|
|
55
|
+
"""
|
|
56
|
+
self.llm_model = llm_model
|
|
57
|
+
self.agent_tools = agent_tools
|
|
58
|
+
self.llm_settings = llm_settings
|
|
59
|
+
|
|
60
|
+
super().__init__(*args, **kwargs)
|
|
61
|
+
|
|
62
|
+
logger.info("Mounting the agent")
|
|
63
|
+
self.register_llm_integration()
|
|
64
|
+
|
|
65
|
+
def register_llm_integration(self) -> None:
|
|
66
|
+
"""Mount the Agent endpoint.
|
|
67
|
+
|
|
68
|
+
This helper mounts the agent endpoint on the application.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
None
|
|
72
|
+
|
|
73
|
+
"""
|
|
74
|
+
from orchestrator.search.agent import build_agent_app
|
|
75
|
+
|
|
76
|
+
agent_app = build_agent_app(self.llm_model, self.agent_tools)
|
|
77
|
+
self.mount("/agent", agent_app)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
main_typer_app = typer.Typer()
|
|
81
|
+
main_typer_app.add_typer(cli_app, name="orchestrator", help="The orchestrator CLI commands")
|
|
82
|
+
|
|
83
|
+
if __name__ == "__main__":
|
|
84
|
+
main_typer_app()
|
orchestrator/api/api_v1/api.py
CHANGED
|
@@ -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()
|
|
@@ -83,3 +84,12 @@ api_router.include_router(
|
|
|
83
84
|
tags=["Core", "Translations"],
|
|
84
85
|
)
|
|
85
86
|
api_router.include_router(ws.router, prefix="/ws", tags=["Core", "Events"])
|
|
87
|
+
|
|
88
|
+
if llm_settings.LLM_ENABLED:
|
|
89
|
+
from orchestrator.api.api_v1.endpoints import search
|
|
90
|
+
|
|
91
|
+
api_router.include_router(
|
|
92
|
+
search.router,
|
|
93
|
+
prefix="/search",
|
|
94
|
+
tags=["Core", "Search"],
|
|
95
|
+
)
|
|
@@ -0,0 +1,290 @@
|
|
|
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.schemas.search import (
|
|
28
|
+
PageInfoSchema,
|
|
29
|
+
PathsResponse,
|
|
30
|
+
ProcessSearchResult,
|
|
31
|
+
ProcessSearchSchema,
|
|
32
|
+
ProductSearchResult,
|
|
33
|
+
ProductSearchSchema,
|
|
34
|
+
SearchResultsSchema,
|
|
35
|
+
SubscriptionSearchResult,
|
|
36
|
+
WorkflowSearchResult,
|
|
37
|
+
WorkflowSearchSchema,
|
|
38
|
+
)
|
|
39
|
+
from orchestrator.search.core.exceptions import InvalidCursorError
|
|
40
|
+
from orchestrator.search.core.types import EntityType, UIType
|
|
41
|
+
from orchestrator.search.filters.definitions import generate_definitions
|
|
42
|
+
from orchestrator.search.indexing.registry import ENTITY_CONFIG_REGISTRY
|
|
43
|
+
from orchestrator.search.retrieval import execute_search
|
|
44
|
+
from orchestrator.search.retrieval.builder import build_paths_query, create_path_autocomplete_lquery, process_path_rows
|
|
45
|
+
from orchestrator.search.retrieval.pagination import (
|
|
46
|
+
create_next_page_cursor,
|
|
47
|
+
process_pagination_cursor,
|
|
48
|
+
)
|
|
49
|
+
from orchestrator.search.retrieval.validation import is_lquery_syntactically_valid
|
|
50
|
+
from orchestrator.search.schemas.parameters import (
|
|
51
|
+
BaseSearchParameters,
|
|
52
|
+
ProcessSearchParameters,
|
|
53
|
+
ProductSearchParameters,
|
|
54
|
+
SubscriptionSearchParameters,
|
|
55
|
+
WorkflowSearchParameters,
|
|
56
|
+
)
|
|
57
|
+
from orchestrator.search.schemas.results import SearchResult, TypeDefinition
|
|
58
|
+
from orchestrator.services.subscriptions import format_special_types
|
|
59
|
+
|
|
60
|
+
router = APIRouter()
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _create_search_result_item(
|
|
64
|
+
entity: WorkflowTable | ProductTable | ProcessTable, entity_type: EntityType, search_info: SearchResult
|
|
65
|
+
) -> WorkflowSearchResult | ProductSearchResult | ProcessSearchResult | None:
|
|
66
|
+
match entity_type:
|
|
67
|
+
case EntityType.WORKFLOW:
|
|
68
|
+
workflow_data = WorkflowSearchSchema.model_validate(entity)
|
|
69
|
+
return WorkflowSearchResult(
|
|
70
|
+
workflow=workflow_data,
|
|
71
|
+
score=search_info.score,
|
|
72
|
+
perfect_match=search_info.perfect_match,
|
|
73
|
+
matching_field=search_info.matching_field,
|
|
74
|
+
)
|
|
75
|
+
case EntityType.PRODUCT:
|
|
76
|
+
product_data = ProductSearchSchema.model_validate(entity)
|
|
77
|
+
return ProductSearchResult(
|
|
78
|
+
product=product_data,
|
|
79
|
+
score=search_info.score,
|
|
80
|
+
perfect_match=search_info.perfect_match,
|
|
81
|
+
matching_field=search_info.matching_field,
|
|
82
|
+
)
|
|
83
|
+
case EntityType.PROCESS:
|
|
84
|
+
process_data = ProcessSearchSchema.model_validate(entity)
|
|
85
|
+
return ProcessSearchResult(
|
|
86
|
+
process=process_data,
|
|
87
|
+
score=search_info.score,
|
|
88
|
+
perfect_match=search_info.perfect_match,
|
|
89
|
+
matching_field=search_info.matching_field,
|
|
90
|
+
)
|
|
91
|
+
case _:
|
|
92
|
+
return None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@overload
|
|
96
|
+
async def _perform_search_and_fetch(
|
|
97
|
+
search_params: BaseSearchParameters,
|
|
98
|
+
entity_type: Literal[EntityType.WORKFLOW],
|
|
99
|
+
eager_loads: list[Any],
|
|
100
|
+
cursor: str | None = None,
|
|
101
|
+
) -> SearchResultsSchema[WorkflowSearchResult]: ...
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@overload
|
|
105
|
+
async def _perform_search_and_fetch(
|
|
106
|
+
search_params: BaseSearchParameters,
|
|
107
|
+
entity_type: Literal[EntityType.PRODUCT],
|
|
108
|
+
eager_loads: list[Any],
|
|
109
|
+
cursor: str | None = None,
|
|
110
|
+
) -> SearchResultsSchema[ProductSearchResult]: ...
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@overload
|
|
114
|
+
async def _perform_search_and_fetch(
|
|
115
|
+
search_params: BaseSearchParameters,
|
|
116
|
+
entity_type: Literal[EntityType.PROCESS],
|
|
117
|
+
eager_loads: list[Any],
|
|
118
|
+
cursor: str | None = None,
|
|
119
|
+
) -> SearchResultsSchema[ProcessSearchResult]: ...
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
async def _perform_search_and_fetch(
|
|
123
|
+
search_params: BaseSearchParameters,
|
|
124
|
+
entity_type: EntityType,
|
|
125
|
+
eager_loads: list[Any],
|
|
126
|
+
cursor: str | None = None,
|
|
127
|
+
) -> SearchResultsSchema[Any]:
|
|
128
|
+
try:
|
|
129
|
+
pagination_params = await process_pagination_cursor(cursor, search_params)
|
|
130
|
+
except InvalidCursorError:
|
|
131
|
+
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid pagination cursor")
|
|
132
|
+
|
|
133
|
+
search_response = await execute_search(
|
|
134
|
+
search_params=search_params,
|
|
135
|
+
db_session=db.session,
|
|
136
|
+
pagination_params=pagination_params,
|
|
137
|
+
)
|
|
138
|
+
if not search_response.results:
|
|
139
|
+
return SearchResultsSchema(search_metadata=search_response.metadata)
|
|
140
|
+
|
|
141
|
+
next_page_cursor = create_next_page_cursor(search_response.results, pagination_params, search_params.limit)
|
|
142
|
+
has_next_page = next_page_cursor is not None
|
|
143
|
+
page_info = PageInfoSchema(has_next_page=has_next_page, next_page_cursor=next_page_cursor)
|
|
144
|
+
|
|
145
|
+
config = ENTITY_CONFIG_REGISTRY[entity_type]
|
|
146
|
+
entity_ids = [res.entity_id for res in search_response.results]
|
|
147
|
+
pk_column = getattr(config.table, config.pk_name)
|
|
148
|
+
ordering_case = case({entity_id: i for i, entity_id in enumerate(entity_ids)}, value=pk_column)
|
|
149
|
+
|
|
150
|
+
stmt = select(config.table).options(*eager_loads).filter(pk_column.in_(entity_ids)).order_by(ordering_case)
|
|
151
|
+
entities = db.session.scalars(stmt).all()
|
|
152
|
+
|
|
153
|
+
search_info_map = {res.entity_id: res for res in search_response.results}
|
|
154
|
+
data = []
|
|
155
|
+
for entity in entities:
|
|
156
|
+
entity_id = getattr(entity, config.pk_name)
|
|
157
|
+
search_info = search_info_map.get(str(entity_id))
|
|
158
|
+
if not search_info:
|
|
159
|
+
continue
|
|
160
|
+
|
|
161
|
+
search_result_item = _create_search_result_item(entity, entity_type, search_info)
|
|
162
|
+
if search_result_item:
|
|
163
|
+
data.append(search_result_item)
|
|
164
|
+
|
|
165
|
+
return SearchResultsSchema(data=data, page_info=page_info, search_metadata=search_response.metadata)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@router.post(
|
|
169
|
+
"/subscriptions",
|
|
170
|
+
response_model=SearchResultsSchema[SubscriptionSearchResult],
|
|
171
|
+
)
|
|
172
|
+
async def search_subscriptions(
|
|
173
|
+
search_params: SubscriptionSearchParameters,
|
|
174
|
+
cursor: str | None = None,
|
|
175
|
+
) -> SearchResultsSchema[SubscriptionSearchResult]:
|
|
176
|
+
try:
|
|
177
|
+
pagination_params = await process_pagination_cursor(cursor, search_params)
|
|
178
|
+
except InvalidCursorError:
|
|
179
|
+
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid pagination cursor")
|
|
180
|
+
|
|
181
|
+
search_response = await execute_search(
|
|
182
|
+
search_params=search_params,
|
|
183
|
+
db_session=db.session,
|
|
184
|
+
pagination_params=pagination_params,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
if not search_response.results:
|
|
188
|
+
return SearchResultsSchema(search_metadata=search_response.metadata)
|
|
189
|
+
|
|
190
|
+
next_page_cursor = create_next_page_cursor(search_response.results, pagination_params, search_params.limit)
|
|
191
|
+
has_next_page = next_page_cursor is not None
|
|
192
|
+
page_info = PageInfoSchema(has_next_page=has_next_page, next_page_cursor=next_page_cursor)
|
|
193
|
+
|
|
194
|
+
search_info_map = {res.entity_id: res for res in search_response.results}
|
|
195
|
+
results_data = []
|
|
196
|
+
for sub_id, search_info in search_info_map.items():
|
|
197
|
+
subscription_model = SubscriptionModel.from_subscription(sub_id)
|
|
198
|
+
sub_data = subscription_model.model_dump(exclude_unset=False)
|
|
199
|
+
search_result_item = SubscriptionSearchResult(
|
|
200
|
+
subscription=format_special_types(sub_data),
|
|
201
|
+
score=search_info.score,
|
|
202
|
+
perfect_match=search_info.perfect_match,
|
|
203
|
+
matching_field=search_info.matching_field,
|
|
204
|
+
)
|
|
205
|
+
results_data.append(search_result_item)
|
|
206
|
+
|
|
207
|
+
return SearchResultsSchema(data=results_data, page_info=page_info, search_metadata=search_response.metadata)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
@router.post("/workflows", response_model=SearchResultsSchema[WorkflowSearchResult])
|
|
211
|
+
async def search_workflows(
|
|
212
|
+
search_params: WorkflowSearchParameters,
|
|
213
|
+
cursor: str | None = None,
|
|
214
|
+
) -> SearchResultsSchema[WorkflowSearchResult]:
|
|
215
|
+
return await _perform_search_and_fetch(
|
|
216
|
+
search_params=search_params,
|
|
217
|
+
entity_type=EntityType.WORKFLOW,
|
|
218
|
+
eager_loads=[selectinload(WorkflowTable.products)],
|
|
219
|
+
cursor=cursor,
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@router.post("/products", response_model=SearchResultsSchema[ProductSearchResult])
|
|
224
|
+
async def search_products(
|
|
225
|
+
search_params: ProductSearchParameters,
|
|
226
|
+
cursor: str | None = None,
|
|
227
|
+
) -> SearchResultsSchema[ProductSearchResult]:
|
|
228
|
+
return await _perform_search_and_fetch(
|
|
229
|
+
search_params=search_params,
|
|
230
|
+
entity_type=EntityType.PRODUCT,
|
|
231
|
+
eager_loads=[
|
|
232
|
+
selectinload(ProductTable.workflows),
|
|
233
|
+
selectinload(ProductTable.fixed_inputs),
|
|
234
|
+
selectinload(ProductTable.product_blocks),
|
|
235
|
+
],
|
|
236
|
+
cursor=cursor,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
@router.post("/processes", response_model=SearchResultsSchema[ProcessSearchResult])
|
|
241
|
+
async def search_processes(
|
|
242
|
+
search_params: ProcessSearchParameters,
|
|
243
|
+
cursor: str | None = None,
|
|
244
|
+
) -> SearchResultsSchema[ProcessSearchResult]:
|
|
245
|
+
return await _perform_search_and_fetch(
|
|
246
|
+
search_params=search_params,
|
|
247
|
+
entity_type=EntityType.PROCESS,
|
|
248
|
+
eager_loads=[
|
|
249
|
+
selectinload(ProcessTable.workflow),
|
|
250
|
+
],
|
|
251
|
+
cursor=cursor,
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
@router.get(
|
|
256
|
+
"/paths",
|
|
257
|
+
response_model=PathsResponse,
|
|
258
|
+
response_model_exclude_none=True,
|
|
259
|
+
)
|
|
260
|
+
async def list_paths(
|
|
261
|
+
prefix: str = Query("", min_length=0),
|
|
262
|
+
q: str | None = Query(None, description="Query for path suggestions"),
|
|
263
|
+
entity_type: EntityType = Query(EntityType.SUBSCRIPTION),
|
|
264
|
+
limit: int = Query(10, ge=1, le=10),
|
|
265
|
+
) -> PathsResponse:
|
|
266
|
+
|
|
267
|
+
if prefix:
|
|
268
|
+
lquery_pattern = create_path_autocomplete_lquery(prefix)
|
|
269
|
+
|
|
270
|
+
if not is_lquery_syntactically_valid(lquery_pattern, db.session):
|
|
271
|
+
raise HTTPException(
|
|
272
|
+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
|
273
|
+
detail=f"Prefix '{prefix}' creates an invalid search pattern.",
|
|
274
|
+
)
|
|
275
|
+
stmt = build_paths_query(entity_type=entity_type, prefix=prefix, q=q)
|
|
276
|
+
stmt = stmt.limit(limit)
|
|
277
|
+
rows = db.session.execute(stmt).all()
|
|
278
|
+
|
|
279
|
+
leaves, components = process_path_rows(rows)
|
|
280
|
+
return PathsResponse(leaves=leaves, components=components)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
@router.get(
|
|
284
|
+
"/definitions",
|
|
285
|
+
response_model=dict[UIType, TypeDefinition],
|
|
286
|
+
response_model_exclude_none=True,
|
|
287
|
+
)
|
|
288
|
+
async def get_definitions() -> dict[UIType, TypeDefinition]:
|
|
289
|
+
"""Provide a static definition of operators and schemas for each UI type."""
|
|
290
|
+
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
|
|
@@ -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()
|
orchestrator/cli/main.py
CHANGED
|
@@ -13,13 +13,34 @@
|
|
|
13
13
|
|
|
14
14
|
import typer
|
|
15
15
|
|
|
16
|
-
from orchestrator.cli import
|
|
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.LLM_ENABLED:
|
|
29
|
+
from orchestrator.cli 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()
|