Skip to content

Commit 552704c

Browse files
authored
Merge pull request lightspeed-core#791 from tisnik/lcore-460-sequence-diagram-for-query-endpoint
LCORE-460: sequence diagram for query endpoint
2 parents 65acb98 + a3dc0ff commit 552704c

3 files changed

Lines changed: 210 additions & 0 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ The service includes comprehensive user data collection capabilities for various
3434
* [Llama Stack version check](#llama-stack-version-check)
3535
* [User data collection](#user-data-collection)
3636
* [System prompt](#system-prompt)
37+
* [System Prompt Path](#system-prompt-path)
38+
* [System Prompt Literal](#system-prompt-literal)
39+
* [Custom Profile](#custom-profile)
3740
* [Control model/provider overrides via authorization](#control-modelprovider-overrides-via-authorization)
3841
* [Safety Shields](#safety-shields)
3942
* [Authentication](#authentication)
@@ -75,6 +78,8 @@ The service includes comprehensive user data collection capabilities for various
7578
* [Project structure](#project-structure)
7679
* [Configuration classes](#configuration-classes)
7780
* [REST API](#rest-api)
81+
* [Sequence diagrams](#sequence-diagrams)
82+
* [Query endpoint REST API handler](#query-endpoint-rest-api-handler)
7883

7984
<!-- vim-markdown-toc -->
8085

@@ -889,3 +894,9 @@ For complete integration setup, deployment options, and configuration details, s
889894
## REST API
890895
891896
![REST API](docs/rest_api.png)
897+
898+
## Sequence diagrams
899+
900+
### Query endpoint REST API handler
901+
902+
![Query endpoint](docs/query_endpoint.svg)

docs/query_endpoint.puml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@startuml
2+
3+
participant Client
4+
participant Endpoint as "Query Endpoint handler"
5+
participant Auth
6+
participant LlamaStack as "Llama Stack Client"
7+
participant Cache as Cache
8+
9+
Client->>Endpoint: POST /query + attachments
10+
Endpoint->>Auth: Validate auth & permissions
11+
Auth-->>Endpoint: Authorized ✓
12+
Endpoint->>Auth: Check config & token quota
13+
Auth-->>Endpoint: Config valid, tokens available
14+
Endpoint->>DB: Retrieve user conversation (optional)
15+
DB-->>Endpoint: UserConversation or None
16+
Endpoint->>Endpoint: Select model/provider from hints/config
17+
Endpoint->>LlamaStack: Get model capabilities
18+
LlamaStack-->>Endpoint: Capabilities response
19+
Endpoint->>Endpoint: Build system prompt, toolgroups, MCP headers
20+
Endpoint->>LlamaStack: Create turn (agent interaction)
21+
LlamaStack-->>Endpoint: Turn response + tool calls + RAG chunks
22+
Endpoint->>Endpoint: Parse metadata & referenced documents
23+
Endpoint->>Endpoint: Transform to QueryResponse
24+
Endpoint->>DB: Persist conversation metadata (model, topic, count)
25+
Endpoint->>Cache: Store conversation with timing metadata
26+
Endpoint-->>Client: Return QueryResponse + token metrics
27+
28+
alt Connection Error
29+
LlamaStack-->>Endpoint: APIConnectionError
30+
Endpoint-->>Client: HTTP 500
31+
end
32+
33+
alt Quota Exceeded
34+
Auth-->>Endpoint: Rate limit violation
35+
Endpoint-->>Client: HTTP 429
36+
end
37+
38+
alt Invalid Request
39+
Endpoint-->>Client: Missing/invalid conversation or attachments
40+
Endpoint-->>Client: HTTP 400/403/404
41+
end
42+
43+
@enduml

0 commit comments

Comments
 (0)