You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The system consists of a .NET 8 minimal API backend and a React + Vite frontend. The backend exposes REST endpoints for connections, providers, settings and vector indexing, plus an SSE chat endpoint. The SQL generation pipeline uses OpenAI function calling to invoke SqlBox tools which search schema, fetch table metadata, produce parameterized SQL and optionally generate ECharts options.
33
+
The system consists of a .NET 8 minimal API backend and a React + Vite frontend. The backend exposes REST endpoints for connections, providers, settings and vector indexing, plus an SSE chat endpoint. The SQL generation pipeline uses OpenAI function calling to invoke a generate_sql tool; the agent produces parameterized SQL and can generate ECharts options with data placeholders that are later injected with real data.
-Hosting and wiring in [Program.cs](src/SQLAgent.Hosting/Program.cs)
47
+
-Minimal host and wiring in [Program.cs](src/SQLAgent.Hosting/Program.cs)
45
48
- Endpoint mapping in [EndpointRouteBuilderExtensions.cs](src/SQLAgent.Hosting/Extensions/EndpointRouteBuilderExtensions.cs)
46
-
- SSE types in [SSEMessage.cs](src/SQLAgent.Hosting/Dto/SSEMessage.cs)
47
-
- SQL agent facade in [SqlBoxClient.cs](src/SQLAgent/Facade/SqlBoxClient.cs)
48
-
- Vector indexing and retrieval in [EmbeddingSchemaIndexer.cs](src/SQLAgent/Infrastructure/Defaults/EmbeddingSchemaIndexer.cs) and [VectorSchemaRetriever.cs](src/SQLAgent/Infrastructure/Defaults/VectorSchemaRetriever.cs)
49
+
- SSE contract/types in [SSEMessage.cs](src/SQLAgent.Hosting/Dto/SSEMessage.cs)
50
+
- SQL agent facade in [SQLAgentClient.cs](src/SQLAgent/Facade/SQLAgentClient.cs)
51
+
- Vector store (SQLite-vec) and embedder wiring in Infrastructure
49
52
50
53
### SSE data flow
51
54
@@ -54,22 +57,22 @@ sequenceDiagram
54
57
participant UI
55
58
participant API
56
59
participant LLM
57
-
participant SqlBox
58
-
UI->>API: POST apichatcompletion
59
-
API->>LLM: messages with toolgenerate_sql
60
-
LLM-->>API: tool_callgenerate_sql
61
-
API->>SqlBox: Execute question
62
-
SqlBox->>DB: query
63
-
SqlBox-->>API: sql and chart option
64
-
API-->>UI: delta streaming
65
-
API-->>UI: blocksql data chart
60
+
participant Agent
61
+
UI->>API: POST /api/chat/completion (SSE)
62
+
API->>LLM: messages + tool(generate_sql)
63
+
LLM-->>API: tool_call(generate_sql) [stream]
64
+
API->>Agent: Execute natural language question
65
+
Agent->>DB: Query (parameterized)
66
+
Agent-->>API: sql and optional echarts option
67
+
API-->>UI: delta streaming (text)
68
+
API-->>UI: block(sql/chart)
66
69
API-->>UI: done
67
70
```
68
71
69
-
SSE message types
72
+
SSE message types (see [SSEMessage.cs](src/SQLAgent.Hosting/Dto/SSEMessage.cs))
Note: Current server streams SQL and optional ECharts option. Data blocks can be added later if needed.
98
+
88
99
## Quickstart
89
100
90
101
Prerequisites
@@ -95,61 +106,66 @@ Prerequisites
95
106
96
107
Backend
97
108
98
-
-Configure ports. Default project uses 18080 via [launchSettings.json](src/SQLAgent.Hosting/Properties/launchSettings.json). If you prefer 5218, change applicationUrl and Urls and update the frontend proxy accordingly.
99
-
- Run
109
+
- Default port is 18080 as configured in [launchSettings.json](src/SQLAgent.Hosting/Properties/launchSettings.json)
110
+
- Run the hosting project:
100
111
101
112
```bash
102
113
dotnet run --project src/SQLAgent.Hosting/SQLAgent.Hosting.csproj
103
114
```
104
115
105
116
Frontend
106
117
107
-
-Ensure the dev proxy in [web/vite.config.ts](web/vite.config.ts) points to backend url
108
-
-Optionally set VITE_API_BASE_URL to override default /api
109
-
- Install and run
118
+
-Dev server defaults to 5173
119
+
-The dev proxy for API is defined in [web/vite.config.ts](web/vite.config.ts). If you change backend port, update the proxy target or set VITE_API_BASE_URL.
120
+
- Install and run:
110
121
111
122
```bash
112
123
cd web
113
124
pnpm install
114
125
pnpm dev
115
126
```
116
127
117
-
Visithttp://localhost:5173 and open Providers and Connections to configure.
128
+
Openhttp://localhost:5173 and configure Providers and Connections first.
118
129
119
130
## Configuration
120
131
121
132
System settings
122
133
123
-
- The backend reads and persists settings at runtime via [MapSettingsApis()](src/SQLAgent.Hosting/Extensions/EndpointRouteBuilderExtensions.cs:106)
124
-
- Recommended values
134
+
- The backend exposes GET/PUT /api/settings (merged with an optional settings.json at content root). Mapping is in [EndpointRouteBuilderExtensions.MapSettingsApis()](src/SQLAgent.Hosting/Extensions/EndpointRouteBuilderExtensions.cs:106)
135
+
- Recommended settings.json:
125
136
126
137
```json
127
138
{
128
139
"EmbeddingProviderId": "openai",
129
140
"EmbeddingModel": "text-embedding-3-small",
130
141
"VectorDbPath": "Data Source=vectors.db",
131
142
"VectorCollection": "table_vectors",
132
-
"DistanceMetric": "Cosine",
133
-
"AutoCreateCollection": true
143
+
"AutoCreateCollection": true,
144
+
"VectorCacheExpireMinutes": 60,
145
+
"DefaultChatProviderId": "openai",
146
+
"DefaultChatModel": "gpt-4o-mini"
134
147
}
135
148
```
136
149
137
150
AI providers
138
151
139
-
- POST /api/providers with an OpenAI key. Example payload
152
+
- POST /api/providers with your OpenAI (or compatible) key. Input schema expects availableModels as an array.
0 commit comments