lightspeed-stack 0.1.2__tar.gz → 0.1.3__tar.gz
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.
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/PKG-INFO +2 -2
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/README.md +1 -1
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/pyproject.toml +1 -1
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/conversations.py +10 -5
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/health.py +7 -6
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/query.py +34 -22
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/streaming_query.py +36 -23
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/models/requests.py +3 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/test_results/.coverage.integration +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/test_results/.coverage.unit +0 -0
- lightspeed_stack-0.1.3/tests/test_results/coverage_integration.json +1 -0
- lightspeed_stack-0.1.3/tests/test_results/coverage_unit.json +1 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/test_results/junit_integration.xml +1 -1
- lightspeed_stack-0.1.3/tests/test_results/junit_unit.xml +1 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_health.py +11 -11
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_query.py +302 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_streaming_query.py +313 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/models/test_config.py +48 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/test_client.py +12 -2
- lightspeed_stack-0.1.2/tests/test_results/coverage_integration.json +0 -1
- lightspeed_stack-0.1.2/tests/test_results/coverage_unit.json +0 -1
- lightspeed_stack-0.1.2/tests/test_results/junit_unit.xml +0 -1
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/LICENSE +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/.ruff_cache/.gitignore +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/.ruff_cache/0.9.1/5703048272820174433 +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/.ruff_cache/0.9.1/9961612457335986079 +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/.ruff_cache/CACHEDIR.TAG +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/authorized.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/config.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/feedback.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/info.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/metrics.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/models.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/endpoints/root.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/main.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/app/routers.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/auth/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/auth/interface.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/auth/jwk_token.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/auth/k8s.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/auth/noop.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/auth/noop_with_token.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/auth/utils.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/metrics/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/metrics/utils.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/models/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/models/config.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/models/responses.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/runners/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/runners/data_collector.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/runners/uvicorn.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/services/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/services/data_collector.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/.ruff_cache/.gitignore +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/.ruff_cache/0.9.1/18446581155718949728 +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/.ruff_cache/0.9.1/4991844299736624256 +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/.ruff_cache/CACHEDIR.TAG +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/checks.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/common.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/endpoints.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/mcp_headers.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/suid.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/src/utils/types.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/configuration/lightspeed-stack.yaml +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/configuration/minimal-stack.yaml +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/configuration/password +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/configuration/run.yaml +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/configuration/server.crt +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/configuration/server.key +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/.pdm-python +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/.ruff_cache/.gitignore +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/.ruff_cache/0.9.1/6949908709306621198 +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/.ruff_cache/CACHEDIR.TAG +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/features/environment.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/features/llm_interface.feature +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/features/rest_api.feature +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/features/smoketests.feature +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/features/steps/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/features/steps/common.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/features/steps/common_http.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/features/steps/llm_query_response.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/gen_scenario_list.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/test_api.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/test_list.txt +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/e2e/utils/utils.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/integration/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/integration/test_configuration.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/integration/test_version.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_authorized.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_config.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_conversations.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_feedback.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_info.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_metrics.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_models.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/endpoints/test_root.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/app/test_routers.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/auth/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/auth/test_auth.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/auth/test_jwk_token.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/auth/test_k8s.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/auth/test_noop.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/auth/test_noop_with_token.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/auth/test_utils.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/metrics/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/metrics/test_utis.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/models/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/models/test_requests.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/models/test_responses.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/runners/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/runners/test_data_collector_runner.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/runners/test_uvicorn_runner.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/services/test_data_collector.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/test_configuration.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/test_lightspeed_stack.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/test_log.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/utils/__init__.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/utils/test_checks.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/utils/test_common.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/utils/test_endpoints.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/utils/test_mcp_headers.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/utils/test_suid.py +0 -0
- {lightspeed_stack-0.1.2 → lightspeed_stack-0.1.3}/tests/unit/utils/test_types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lightspeed-stack
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: LLM tooling stack
|
|
5
5
|
Keywords: LLM,RAG
|
|
6
6
|
Maintainer-Email: =?utf-8?b?UGF2ZWwgVGnFoW5vdnNrw70=?= <tisnik@centrum.cz>
|
|
@@ -236,7 +236,7 @@ Description-Content-Type: text/markdown
|
|
|
236
236
|
[](https://github.com/lightspeed-core/lightspeed-stack/blob/main/LICENSE)
|
|
237
237
|
[](https://www.python.org/)
|
|
238
238
|
[](https://www.python.org/)
|
|
239
|
-
[](https://github.com/lightspeed-core/lightspeed-stack/releases/tag/0.1.
|
|
239
|
+
[](https://github.com/lightspeed-core/lightspeed-stack/releases/tag/0.1.3)
|
|
240
240
|
|
|
241
241
|
Lightspeed Core Stack (LCS) is an AI-powered assistant that provides answers to product questions using backend LLM services, agents, and RAG databases.
|
|
242
242
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://github.com/lightspeed-core/lightspeed-stack/blob/main/LICENSE)
|
|
7
7
|
[](https://www.python.org/)
|
|
8
8
|
[](https://www.python.org/)
|
|
9
|
-
[](https://github.com/lightspeed-core/lightspeed-stack/releases/tag/0.1.
|
|
9
|
+
[](https://github.com/lightspeed-core/lightspeed-stack/releases/tag/0.1.3)
|
|
10
10
|
|
|
11
11
|
Lightspeed Core Stack (LCS) is an AI-powered assistant that provides answers to product questions using backend LLM services, agents, and RAG databases.
|
|
12
12
|
|
|
@@ -23,11 +23,16 @@ conversation_id_to_agent_id: dict[str, str] = {}
|
|
|
23
23
|
conversation_responses: dict[int | str, dict[str, Any]] = {
|
|
24
24
|
200: {
|
|
25
25
|
"conversation_id": "123e4567-e89b-12d3-a456-426614174000",
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
"chat_history": [
|
|
27
|
+
{
|
|
28
|
+
"messages": [
|
|
29
|
+
{"content": "Hi", "type": "user"},
|
|
30
|
+
{"content": "Hello!", "type": "assistant"},
|
|
31
|
+
],
|
|
32
|
+
"started_at": "2024-01-01T00:00:00Z",
|
|
33
|
+
"completed_at": "2024-01-01T00:00:05Z",
|
|
34
|
+
}
|
|
35
|
+
],
|
|
31
36
|
},
|
|
32
37
|
404: {
|
|
33
38
|
"detail": {
|
|
@@ -11,7 +11,7 @@ from typing import Any
|
|
|
11
11
|
from llama_stack.providers.datatypes import HealthStatus
|
|
12
12
|
|
|
13
13
|
from fastapi import APIRouter, status, Response
|
|
14
|
-
from client import
|
|
14
|
+
from client import AsyncLlamaStackClientHolder
|
|
15
15
|
from models.responses import (
|
|
16
16
|
LivenessResponse,
|
|
17
17
|
ReadinessResponse,
|
|
@@ -22,16 +22,17 @@ logger = logging.getLogger(__name__)
|
|
|
22
22
|
router = APIRouter(tags=["health"])
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def get_providers_health_statuses() -> list[ProviderHealthStatus]:
|
|
25
|
+
async def get_providers_health_statuses() -> list[ProviderHealthStatus]:
|
|
26
26
|
"""Check health of all providers.
|
|
27
27
|
|
|
28
28
|
Returns:
|
|
29
29
|
List of provider health statuses.
|
|
30
30
|
"""
|
|
31
31
|
try:
|
|
32
|
-
client =
|
|
32
|
+
client = AsyncLlamaStackClientHolder().get_client()
|
|
33
33
|
|
|
34
|
-
providers =
|
|
34
|
+
# providers = []
|
|
35
|
+
providers = await client.providers.list()
|
|
35
36
|
logger.debug("Found %d providers", len(providers))
|
|
36
37
|
|
|
37
38
|
health_results = [
|
|
@@ -69,9 +70,9 @@ get_readiness_responses: dict[int | str, dict[str, Any]] = {
|
|
|
69
70
|
|
|
70
71
|
|
|
71
72
|
@router.get("/readiness", responses=get_readiness_responses)
|
|
72
|
-
def readiness_probe_get_method(response: Response) -> ReadinessResponse:
|
|
73
|
+
async def readiness_probe_get_method(response: Response) -> ReadinessResponse:
|
|
73
74
|
"""Ready status of service with provider health details."""
|
|
74
|
-
provider_statuses = get_providers_health_statuses()
|
|
75
|
+
provider_statuses = await get_providers_health_statuses()
|
|
75
76
|
|
|
76
77
|
# Check if any provider is unhealthy (not counting not_implemented as unhealthy)
|
|
77
78
|
unhealthy_providers = [
|
|
@@ -80,6 +80,7 @@ def get_agent( # pylint: disable=too-many-arguments,too-many-positional-argumen
|
|
|
80
80
|
available_input_shields: list[str],
|
|
81
81
|
available_output_shields: list[str],
|
|
82
82
|
conversation_id: str | None,
|
|
83
|
+
no_tools: bool = False,
|
|
83
84
|
) -> tuple[Agent, str]:
|
|
84
85
|
"""Get existing agent or create a new one with session persistence."""
|
|
85
86
|
if conversation_id is not None:
|
|
@@ -99,7 +100,7 @@ def get_agent( # pylint: disable=too-many-arguments,too-many-positional-argumen
|
|
|
99
100
|
instructions=system_prompt,
|
|
100
101
|
input_shields=available_input_shields if available_input_shields else [],
|
|
101
102
|
output_shields=available_output_shields if available_output_shields else [],
|
|
102
|
-
tool_parser=GraniteToolParser.get_parser(model_id),
|
|
103
|
+
tool_parser=None if no_tools else GraniteToolParser.get_parser(model_id),
|
|
103
104
|
enable_session_persistence=True,
|
|
104
105
|
)
|
|
105
106
|
conversation_id = agent.create_session(get_suid())
|
|
@@ -288,36 +289,47 @@ def retrieve_response( # pylint: disable=too-many-locals
|
|
|
288
289
|
available_input_shields,
|
|
289
290
|
available_output_shields,
|
|
290
291
|
query_request.conversation_id,
|
|
292
|
+
query_request.no_tools or False,
|
|
291
293
|
)
|
|
292
294
|
|
|
293
|
-
#
|
|
294
|
-
if
|
|
295
|
+
# bypass tools and MCP servers if no_tools is True
|
|
296
|
+
if query_request.no_tools:
|
|
295
297
|
mcp_headers = {}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
298
|
+
agent.extra_headers = {}
|
|
299
|
+
toolgroups = None
|
|
300
|
+
else:
|
|
301
|
+
# preserve compatibility when mcp_headers is not provided
|
|
302
|
+
if mcp_headers is None:
|
|
303
|
+
mcp_headers = {}
|
|
304
|
+
mcp_headers = handle_mcp_headers_with_toolgroups(mcp_headers, configuration)
|
|
305
|
+
if not mcp_headers and token:
|
|
306
|
+
for mcp_server in configuration.mcp_servers:
|
|
307
|
+
mcp_headers[mcp_server.url] = {
|
|
308
|
+
"Authorization": f"Bearer {token}",
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
agent.extra_headers = {
|
|
312
|
+
"X-LlamaStack-Provider-Data": json.dumps(
|
|
313
|
+
{
|
|
314
|
+
"mcp_headers": mcp_headers,
|
|
315
|
+
}
|
|
316
|
+
),
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
vector_db_ids = [vector_db.identifier for vector_db in client.vector_dbs.list()]
|
|
320
|
+
toolgroups = (get_rag_toolgroups(vector_db_ids) or []) + [
|
|
321
|
+
mcp_server.name for mcp_server in configuration.mcp_servers
|
|
322
|
+
]
|
|
323
|
+
# Convert empty list to None for consistency with existing behavior
|
|
324
|
+
if not toolgroups:
|
|
325
|
+
toolgroups = None
|
|
310
326
|
|
|
311
|
-
vector_db_ids = [vector_db.identifier for vector_db in client.vector_dbs.list()]
|
|
312
|
-
toolgroups = (get_rag_toolgroups(vector_db_ids) or []) + [
|
|
313
|
-
mcp_server.name for mcp_server in configuration.mcp_servers
|
|
314
|
-
]
|
|
315
327
|
response = agent.create_turn(
|
|
316
328
|
messages=[UserMessage(role="user", content=query_request.query)],
|
|
317
329
|
session_id=conversation_id,
|
|
318
330
|
documents=query_request.get_documents(),
|
|
319
331
|
stream=False,
|
|
320
|
-
toolgroups=toolgroups
|
|
332
|
+
toolgroups=toolgroups,
|
|
321
333
|
)
|
|
322
334
|
|
|
323
335
|
# Check for validation errors in the response
|
|
@@ -58,6 +58,7 @@ async def get_agent(
|
|
|
58
58
|
available_input_shields: list[str],
|
|
59
59
|
available_output_shields: list[str],
|
|
60
60
|
conversation_id: str | None,
|
|
61
|
+
no_tools: bool = False,
|
|
61
62
|
) -> tuple[AsyncAgent, str]:
|
|
62
63
|
"""Get existing agent or create a new one with session persistence."""
|
|
63
64
|
if conversation_id is not None:
|
|
@@ -76,7 +77,7 @@ async def get_agent(
|
|
|
76
77
|
instructions=system_prompt,
|
|
77
78
|
input_shields=available_input_shields if available_input_shields else [],
|
|
78
79
|
output_shields=available_output_shields if available_output_shields else [],
|
|
79
|
-
tool_parser=GraniteToolParser.get_parser(model_id),
|
|
80
|
+
tool_parser=None if no_tools else GraniteToolParser.get_parser(model_id),
|
|
80
81
|
enable_session_persistence=True,
|
|
81
82
|
)
|
|
82
83
|
conversation_id = await agent.create_session(get_suid())
|
|
@@ -532,41 +533,53 @@ async def retrieve_response(
|
|
|
532
533
|
available_input_shields,
|
|
533
534
|
available_output_shields,
|
|
534
535
|
query_request.conversation_id,
|
|
536
|
+
query_request.no_tools or False,
|
|
535
537
|
)
|
|
536
538
|
|
|
537
|
-
#
|
|
538
|
-
if
|
|
539
|
+
# bypass tools and MCP servers if no_tools is True
|
|
540
|
+
if query_request.no_tools:
|
|
539
541
|
mcp_headers = {}
|
|
542
|
+
agent.extra_headers = {}
|
|
543
|
+
toolgroups = None
|
|
544
|
+
else:
|
|
545
|
+
# preserve compatibility when mcp_headers is not provided
|
|
546
|
+
if mcp_headers is None:
|
|
547
|
+
mcp_headers = {}
|
|
540
548
|
|
|
541
|
-
|
|
549
|
+
mcp_headers = handle_mcp_headers_with_toolgroups(mcp_headers, configuration)
|
|
542
550
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
551
|
+
if not mcp_headers and token:
|
|
552
|
+
for mcp_server in configuration.mcp_servers:
|
|
553
|
+
mcp_headers[mcp_server.url] = {
|
|
554
|
+
"Authorization": f"Bearer {token}",
|
|
555
|
+
}
|
|
548
556
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
557
|
+
agent.extra_headers = {
|
|
558
|
+
"X-LlamaStack-Provider-Data": json.dumps(
|
|
559
|
+
{
|
|
560
|
+
"mcp_headers": mcp_headers,
|
|
561
|
+
}
|
|
562
|
+
),
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
logger.debug("Session ID: %s", conversation_id)
|
|
566
|
+
vector_db_ids = [
|
|
567
|
+
vector_db.identifier for vector_db in await client.vector_dbs.list()
|
|
568
|
+
]
|
|
569
|
+
toolgroups = (get_rag_toolgroups(vector_db_ids) or []) + [
|
|
570
|
+
mcp_server.name for mcp_server in configuration.mcp_servers
|
|
571
|
+
]
|
|
572
|
+
# Convert empty list to None for consistency with existing behavior
|
|
573
|
+
if not toolgroups:
|
|
574
|
+
toolgroups = None
|
|
556
575
|
|
|
557
576
|
logger.debug("Session ID: %s", conversation_id)
|
|
558
|
-
vector_db_ids = [
|
|
559
|
-
vector_db.identifier for vector_db in await client.vector_dbs.list()
|
|
560
|
-
]
|
|
561
|
-
toolgroups = (get_rag_toolgroups(vector_db_ids) or []) + [
|
|
562
|
-
mcp_server.name for mcp_server in configuration.mcp_servers
|
|
563
|
-
]
|
|
564
577
|
response = await agent.create_turn(
|
|
565
578
|
messages=[UserMessage(role="user", content=query_request.query)],
|
|
566
579
|
session_id=conversation_id,
|
|
567
580
|
documents=query_request.get_documents(),
|
|
568
581
|
stream=True,
|
|
569
|
-
toolgroups=toolgroups
|
|
582
|
+
toolgroups=toolgroups,
|
|
570
583
|
)
|
|
571
584
|
|
|
572
585
|
return response, conversation_id
|
|
@@ -69,6 +69,7 @@ class QueryRequest(BaseModel):
|
|
|
69
69
|
model: The optional model.
|
|
70
70
|
system_prompt: The optional system prompt.
|
|
71
71
|
attachments: The optional attachments.
|
|
72
|
+
no_tools: Whether to bypass all tools and MCP servers (default: False).
|
|
72
73
|
|
|
73
74
|
Example:
|
|
74
75
|
```python
|
|
@@ -82,6 +83,7 @@ class QueryRequest(BaseModel):
|
|
|
82
83
|
model: Optional[str] = None
|
|
83
84
|
system_prompt: Optional[str] = None
|
|
84
85
|
attachments: Optional[list[Attachment]] = None
|
|
86
|
+
no_tools: Optional[bool] = False
|
|
85
87
|
# media_type is not used in 'lightspeed-stack' that only supports application/json.
|
|
86
88
|
# the field is kept here to enable compatibility with 'road-core' clients.
|
|
87
89
|
media_type: Optional[str] = None
|
|
@@ -97,6 +99,7 @@ class QueryRequest(BaseModel):
|
|
|
97
99
|
"provider": "openai",
|
|
98
100
|
"model": "model-name",
|
|
99
101
|
"system_prompt": "You are a helpful assistant",
|
|
102
|
+
"no_tools": False,
|
|
100
103
|
"attachments": [
|
|
101
104
|
{
|
|
102
105
|
"attachment_type": "log",
|
|
Binary file
|