Skip to content

Commit 8a8e1f1

Browse files
authored
Merge pull request lightspeed-core#1676 from asimurka/move_error_responses
LCORE-1880: Replaced successful responses and common models
2 parents 6af0a2a + 53ff338 commit 8a8e1f1

118 files changed

Lines changed: 2915 additions & 2633 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/openapi.json

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6176,8 +6176,7 @@
61766176
"content": {
61776177
"text/event-stream": {
61786178
"schema": {
6179-
"type": "string",
6180-
"format": "text/event-stream"
6179+
"type": "string"
61816180
},
61826181
"example": "data: {\"event\": \"start\", \"data\": {\"conversation_id\": \"123e4567-e89b-12d3-a456-426614174000\", \"request_id\": \"123e4567-e89b-12d3-a456-426614174001\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 0, \"token\": \"No Violation\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 1, \"token\": \"\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 2, \"token\": \"Hello\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 3, \"token\": \"!\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 4, \"token\": \" How\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 5, \"token\": \" can\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 6, \"token\": \" I\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 7, \"token\": \" assist\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 8, \"token\": \" you\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 9, \"token\": \" today\"}}\n\ndata: {\"event\": \"token\", \"data\": {\"id\": 10, \"token\": \"?\"}}\n\ndata: {\"event\": \"turn_complete\", \"data\": {\"token\": \"Hello! How can I assist you today?\"}}\n\ndata: {\"event\": \"end\", \"data\": {\"referenced_documents\": [], \"truncated\": null, \"input_tokens\": 11, \"output_tokens\": 19}, \"available_quotas\": {}}\n\n"
61836182
}
@@ -12048,7 +12047,7 @@
1204812047
"configuration"
1204912048
],
1205012049
"title": "ConfigurationResponse",
12051-
"description": "Success response model for the config endpoint.",
12050+
"description": "Success response model for the config endpoint.\n\nAttributes:\n configuration: Parsed application configuration returned to the client.",
1205212051
"examples": [
1205312052
{
1205412053
"configuration": {
@@ -12624,7 +12623,7 @@
1262412623
"message"
1262512624
],
1262612625
"title": "ConversationUpdateResponse",
12627-
"description": "Model representing a response for updating a conversation topic summary.\n\nAttributes:\n conversation_id: The conversation ID (UUID) that was updated.\n success: Whether the update was successful.\n message: A message about the update result.\n\nExample:\n ```python\n update_response = ConversationUpdateResponse(\n conversation_id=\"123e4567-e89b-12d3-a456-426614174000\",\n success=True,\n message=\"Topic summary updated successfully\",\n )\n ```",
12626+
"description": "Model representing a response for updating a conversation topic summary.\n\nAttributes:\n conversation_id: The conversation ID (UUID) that was updated.\n success: Whether the update was successful.\n message: A message about the update result.",
1262812627
"examples": [
1262912628
{
1263012629
"conversation_id": "123e4567-e89b-12d3-a456-426614174000",
@@ -13012,7 +13011,7 @@
1301213011
"response"
1301313012
],
1301413013
"title": "FeedbackResponse",
13015-
"description": "Model representing a response to a feedback request.\n\nAttributes:\n response: The response of the feedback request.\n\nExample:\n ```python\n feedback_response = FeedbackResponse(response=\"feedback received\")\n ```",
13014+
"description": "Model representing a response to a feedback request.\n\nAttributes:\n response: The response of the feedback request.",
1301613015
"examples": [
1301713016
{
1301813017
"response": "feedback received"
@@ -13050,7 +13049,7 @@
1305013049
"status"
1305113050
],
1305213051
"title": "FeedbackStatusUpdateResponse",
13053-
"description": "Model representing a response to a feedback status update request.\n\nAttributes:\n status: The previous and current status of the service and who updated it.\n\nExample:\n ```python\n status_response = StatusResponse(\n status={\n \"previous_status\": true,\n \"updated_status\": false,\n \"updated_by\": \"user/test\",\n \"timestamp\": \"2023-03-15 12:34:56\"\n },\n )\n ```",
13052+
"description": "Model representing a response to a feedback status update request.\n\nAttributes:\n status: The previous and current status of the service and who updated it.",
1305413053
"examples": [
1305513054
{
1305613055
"status": {
@@ -13424,7 +13423,7 @@
1342413423
"llama_stack_version"
1342513424
],
1342613425
"title": "InfoResponse",
13427-
"description": "Model representing a response to an info request.\n\nAttributes:\n name: Service name.\n service_version: Service version.\n llama_stack_version: Llama Stack version.\n\nExample:\n ```python\n info_response = InfoResponse(\n name=\"Lightspeed Stack\",\n service_version=\"1.0.0\",\n llama_stack_version=\"0.2.22\",\n )\n ```",
13426+
"description": "Model representing a response to an info request.\n\nAttributes:\n name: Service name.\n service_version: Service version.\n llama_stack_version: Llama Stack version.",
1342813427
"examples": [
1342913428
{
1343013429
"llama_stack_version": "1.0.0",
@@ -13639,7 +13638,7 @@
1363913638
"alive"
1364013639
],
1364113640
"title": "LivenessResponse",
13642-
"description": "Model representing a response to a liveness request.\n\nAttributes:\n alive: If app is alive.\n\nExample:\n ```python\n liveness_response = LivenessResponse(alive=True)\n ```",
13641+
"description": "Model representing a response to a liveness request.\n\nAttributes:\n alive: If app is alive.",
1364313642
"examples": [
1364413643
{
1364513644
"alive": true
@@ -13726,7 +13725,7 @@
1372613725
},
1372713726
"type": "object",
1372813727
"title": "MCPClientAuthOptionsResponse",
13729-
"description": "Response containing MCP servers that accept client-provided authorization.",
13728+
"description": "Response containing MCP servers that accept client-provided authorization.\n\nAttributes:\n servers: MCP servers that declare client authentication headers.",
1373013729
"examples": [
1373113730
{
1373213731
"servers": [
@@ -13821,7 +13820,7 @@
1382113820
"message"
1382213821
],
1382313822
"title": "MCPServerDeleteResponse",
13824-
"description": "Response for a successful MCP server deletion.",
13823+
"description": "Response for a successful MCP server deletion.\n\nAttributes:\n name: Deleted MCP server name.\n message: Status message.",
1382513824
"examples": [
1382613825
{
1382713826
"message": "MCP server 'test-mcp-server' unregistered successfully",
@@ -13879,7 +13878,7 @@
1387913878
},
1388013879
"type": "object",
1388113880
"title": "MCPServerListResponse",
13882-
"description": "Response listing all registered MCP servers.",
13881+
"description": "Response listing all registered MCP servers.\n\nAttributes:\n servers: All registered MCP servers (static and dynamic).",
1388313882
"examples": [
1388413883
{
1388513884
"servers": [
@@ -14063,7 +14062,7 @@
1406314062
"message"
1406414063
],
1406514064
"title": "MCPServerRegistrationResponse",
14066-
"description": "Response for a successful MCP server registration.",
14065+
"description": "Response for a successful MCP server registration.\n\nAttributes:\n name: Registered MCP server name.\n url: Registered MCP server URL.\n provider_id: MCP provider identification.\n message: Status message.",
1406714066
"examples": [
1406814067
{
1406914068
"message": "MCP server 'mcp-integration-tools' registered successfully",
@@ -16494,7 +16493,7 @@
1649416493
"response"
1649516494
],
1649616495
"title": "PromptDeleteResponse",
16497-
"description": "Result of deleting a stored prompt (always HTTP 200, like conversations v2).",
16496+
"description": "Result of deleting a stored prompt (always HTTP 200, like conversations v2).\n\nAttributes:\n prompt_id: Prompt identifier that was passed to delete.\n deleted: Whether the prompt was deleted successfully\n response: Human readable response",
1649816497
"examples": [
1649916498
{
1650016499
"label": "deleted",
@@ -16573,7 +16572,7 @@
1657316572
"version"
1657416573
],
1657516574
"title": "PromptResourceResponse",
16576-
"description": "A stored prompt template as returned by Llama Stack.",
16575+
"description": "A stored prompt template as returned by Llama Stack.\n\nAttributes:\n prompt_id: Prompt identifier from Llama Stack.\n version: Version number for this prompt.\n is_default: Whether this version is the default.\n prompt: Prompt text with placeholders.\n variables: Variable names used in the template.",
1657716576
"examples": [
1657816577
{
1657916578
"is_default": true,
@@ -16711,7 +16710,7 @@
1671116710
"additionalProperties": false,
1671216711
"type": "object",
1671316712
"title": "PromptsListResponse",
16714-
"description": "List of stored prompt templates returned by Llama Stack.",
16713+
"description": "List of stored prompt templates returned by Llama Stack.\n\nAttributes:\n data: Prompt entries as returned by the Llama Stack list API.",
1671516714
"examples": [
1671616715
{
1671716716
"data": [
@@ -17184,7 +17183,7 @@
1718417183
"truncated": {
1718517184
"type": "boolean",
1718617185
"title": "Truncated",
17187-
"description": "Deprecated:Whether conversation history was truncated",
17186+
"description": "Deprecated: whether conversation history was truncated",
1718817187
"default": false,
1718917188
"examples": [
1719017189
false,
@@ -17767,7 +17766,7 @@
1776717766
"providers"
1776817767
],
1776917768
"title": "ReadinessResponse",
17770-
"description": "Model representing response to a readiness request.\n\nAttributes:\n ready: If service is ready.\n reason: The reason for the readiness.\n providers: List of unhealthy providers in case of readiness failure.\n\nExample:\n ```python\n readiness_response = ReadinessResponse(\n ready=False,\n reason=\"Service is not ready\",\n providers=[\n ProviderHealthStatus(\n provider_id=\"ollama\",\n status=\"unhealthy\",\n message=\"Server is unavailable\"\n )\n ]\n )\n ```",
17769+
"description": "Model representing response to a readiness request.\n\nAttributes:\n ready: If service is ready.\n reason: The reason for the readiness.\n providers: List of unhealthy providers in case of readiness failure.",
1777117770
"examples": [
1777217771
{
1777317772
"providers": [],
@@ -19392,7 +19391,7 @@
1939219391
"status"
1939319392
],
1939419393
"title": "StatusResponse",
19395-
"description": "Model representing a response to a status request.\n\nAttributes:\n functionality: The functionality of the service.\n status: The status of the service.\n\nExample:\n ```python\n status_response = StatusResponse(\n functionality=\"feedback\",\n status={\"enabled\": True},\n )\n ```",
19394+
"description": "Model representing a response to a status request.\n\nAttributes:\n functionality: The functionality of the service.\n status: The status of the service.",
1939619395
"examples": [
1939719396
{
1939819397
"functionality": "feedback",
@@ -19460,7 +19459,7 @@
1946019459
"message"
1946119460
],
1946219461
"title": "StreamingInterruptResponse",
19463-
"description": "Model representing a response to a streaming interrupt request.\n\nAttributes:\n request_id: The streaming request ID targeted by the interrupt call.\n interrupted: Whether an in-progress stream was interrupted.\n message: Human-readable interruption status message.\n\nExample:\n ```python\n response = StreamingInterruptResponse(\n request_id=\"123e4567-e89b-12d3-a456-426614174000\",\n interrupted=True,\n message=\"Streaming request interrupted\",\n )\n ```",
19462+
"description": "Model representing a response to a streaming interrupt request.\n\nAttributes:\n request_id: The streaming request ID targeted by the interrupt call.\n interrupted: Whether an in-progress stream was interrupted.\n message: Human-readable interruption status message.",
1946419463
"examples": [
1946519464
{
1946619465
"interrupted": true,

src/app/endpoints/authorized.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
from authentication import get_auth_dependency
88
from authentication.interface import AuthTuple
99
from log import get_logger
10-
from models.api.responses import (
11-
UNAUTHORIZED_OPENAPI_EXAMPLES,
10+
from models.api.responses.constants import UNAUTHORIZED_OPENAPI_EXAMPLES
11+
from models.api.responses.error import (
1212
ForbiddenResponse,
1313
ServiceUnavailableResponse,
1414
UnauthorizedResponse,
1515
)
16-
from models.responses import (
17-
AuthorizedResponse,
18-
)
16+
from models.api.responses.successful import AuthorizedResponse
1917

2018
logger = get_logger(__name__)
2119
router = APIRouter(tags=["authorized"])

src/app/endpoints/config.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@
99
from authorization.middleware import authorize
1010
from configuration import configuration
1111
from log import get_logger
12-
from models.api.responses import (
13-
UNAUTHORIZED_OPENAPI_EXAMPLES,
12+
from models.api.responses.constants import UNAUTHORIZED_OPENAPI_EXAMPLES
13+
from models.api.responses.error import (
1414
ForbiddenResponse,
1515
InternalServerErrorResponse,
1616
ServiceUnavailableResponse,
1717
UnauthorizedResponse,
1818
)
19+
from models.api.responses.successful import ConfigurationResponse
1920
from models.config import Action
20-
from models.responses import (
21-
ConfigurationResponse,
22-
)
2321
from utils.endpoints import check_configuration_loaded
2422

2523
logger = get_logger(__name__)

src/app/endpoints/conversations_v1.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@
1616
from client import AsyncLlamaStackClientHolder
1717
from configuration import configuration
1818
from log import get_logger
19-
from models.api.responses import (
20-
UNAUTHORIZED_OPENAPI_EXAMPLES,
19+
from models.api.responses.constants import UNAUTHORIZED_OPENAPI_EXAMPLES
20+
from models.api.responses.error import (
2121
BadRequestResponse,
2222
ForbiddenResponse,
2323
InternalServerErrorResponse,
2424
NotFoundResponse,
2525
ServiceUnavailableResponse,
2626
UnauthorizedResponse,
2727
)
28-
from models.config import Action
29-
from models.database.conversations import (
30-
UserConversation,
31-
)
32-
from models.requests import ConversationUpdateRequest
33-
from models.responses import (
28+
from models.api.responses.successful import (
3429
ConversationDeleteResponse,
35-
ConversationDetails,
3630
ConversationResponse,
3731
ConversationsListResponse,
3832
ConversationUpdateResponse,
3933
)
34+
from models.common import ConversationDetails
35+
from models.config import Action
36+
from models.database.conversations import (
37+
UserConversation,
38+
)
39+
from models.requests import ConversationUpdateRequest
4040
from utils.conversations import (
4141
build_conversation_turns_from_items,
4242
get_all_conversation_items,

src/app/endpoints/conversations_v2.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,28 @@
88
from authorization.middleware import authorize
99
from configuration import configuration
1010
from log import get_logger
11-
from models.api.responses import (
12-
UNAUTHORIZED_OPENAPI_EXAMPLES,
11+
from models.api.responses.constants import UNAUTHORIZED_OPENAPI_EXAMPLES
12+
from models.api.responses.error import (
1313
BadRequestResponse,
1414
ForbiddenResponse,
1515
InternalServerErrorResponse,
1616
NotFoundResponse,
1717
ServiceUnavailableResponse,
1818
UnauthorizedResponse,
1919
)
20-
from models.cache_entry import CacheEntry
21-
from models.config import Action
22-
from models.requests import ConversationUpdateRequest
23-
from models.responses import (
20+
from models.api.responses.successful import (
2421
ConversationDeleteResponse,
2522
ConversationResponse,
2623
ConversationsListResponseV2,
27-
ConversationTurn,
2824
ConversationUpdateResponse,
25+
)
26+
from models.cache_entry import CacheEntry
27+
from models.common import (
28+
ConversationTurn,
2929
Message,
3030
)
31+
from models.config import Action
32+
from models.requests import ConversationUpdateRequest
3133
from utils.endpoints import check_configuration_loaded
3234
from utils.suid import check_suid
3335

src/app/endpoints/feedback.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
from authorization.middleware import authorize
1414
from configuration import configuration
1515
from log import get_logger
16-
from models.api.responses import (
17-
UNAUTHORIZED_OPENAPI_EXAMPLES,
16+
from models.api.responses.constants import UNAUTHORIZED_OPENAPI_EXAMPLES
17+
from models.api.responses.error import (
1818
ForbiddenResponse,
1919
InternalServerErrorResponse,
2020
NotFoundResponse,
2121
ServiceUnavailableResponse,
2222
UnauthorizedResponse,
2323
)
24-
from models.config import Action
25-
from models.requests import FeedbackRequest, FeedbackStatusUpdateRequest
26-
from models.responses import (
24+
from models.api.responses.successful import (
2725
FeedbackResponse,
2826
FeedbackStatusUpdateResponse,
2927
StatusResponse,
3028
)
29+
from models.config import Action
30+
from models.requests import FeedbackRequest, FeedbackStatusUpdateRequest
3131
from utils.endpoints import check_configuration_loaded, retrieve_conversation
3232
from utils.suid import get_suid
3333

src/app/endpoints/health.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
from client import AsyncLlamaStackClientHolder
1818
from configuration import configuration
1919
from log import get_logger
20-
from models.api.responses import (
21-
UNAUTHORIZED_OPENAPI_EXAMPLES,
20+
from models.api.responses.constants import UNAUTHORIZED_OPENAPI_EXAMPLES
21+
from models.api.responses.error import (
2222
ForbiddenResponse,
2323
ServiceUnavailableResponse,
2424
UnauthorizedResponse,
2525
)
26-
from models.config import Action
27-
from models.responses import (
26+
from models.api.responses.successful import (
2827
LivenessResponse,
29-
ProviderHealthStatus,
3028
ReadinessResponse,
3129
)
30+
from models.common import ProviderHealthStatus
31+
from models.config import Action
3232

3333
logger = get_logger(__name__)
3434
router = APIRouter(tags=["health"])

src/app/endpoints/info.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@
1111
from client import AsyncLlamaStackClientHolder
1212
from configuration import configuration
1313
from log import get_logger
14-
from models.api.responses import (
15-
UNAUTHORIZED_OPENAPI_EXAMPLES,
14+
from models.api.responses.constants import UNAUTHORIZED_OPENAPI_EXAMPLES
15+
from models.api.responses.error import (
1616
ForbiddenResponse,
1717
ServiceUnavailableResponse,
1818
UnauthorizedResponse,
1919
)
20+
from models.api.responses.successful import InfoResponse
2021
from models.config import Action
21-
from models.responses import (
22-
InfoResponse,
23-
)
2422
from version import __version__
2523

2624
logger = get_logger(__name__)

src/app/endpoints/mcp_auth.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@
1010
from authorization.middleware import authorize
1111
from configuration import configuration
1212
from log import get_logger
13-
from models.api.responses import (
14-
UNAUTHORIZED_OPENAPI_EXAMPLES,
13+
from models.api.responses.constants import UNAUTHORIZED_OPENAPI_EXAMPLES
14+
from models.api.responses.error import (
1515
ForbiddenResponse,
1616
InternalServerErrorResponse,
1717
ServiceUnavailableResponse,
1818
UnauthorizedResponse,
1919
)
20+
from models.api.responses.successful import MCPClientAuthOptionsResponse
21+
from models.common import MCPServerAuthInfo
2022
from models.config import Action
21-
from models.responses import (
22-
MCPClientAuthOptionsResponse,
23-
MCPServerAuthInfo,
24-
)
2523
from utils.endpoints import check_configuration_loaded
2624

2725
logger = get_logger(__name__)

0 commit comments

Comments
 (0)