Skip to content

Commit 0015b72

Browse files
lirenheRenhe Li
andauthored
Update TypeSpec definitions to match backend API implementation (#13775)
* Update TypeSpec definitions to match backend API implementation - Updated TenantID union with all 10 tenant IDs from Go backend - Updated Source union with all 25 data sources from Go backend - Fixed Intention model to include all fields (spec_type, needs_rag_processing, question_scope, service_type) - Added missing fields to CompletionRequest (intention) and CompletionResponse (reasoning_progress, route_tenant) - Fixed authentication: changed from X-API-Key to optional Bearer token - Added package.json and tspconfig.yaml to enable TypeSpec compilation - Added .gitignore to exclude node_modules and tsp-output * update server link * Fix ErrorResponse model to match APIError structure from Go backend * Add SimpleErrorResponse for feedback API. * update package.json * merge main and adopt authoring code change --------- Co-authored-by: Renhe Li <renhel@microsoft.com> Co-authored-by: ReleaseHelper <ReleaseHelper>
1 parent f78a067 commit 0015b72

File tree

7 files changed

+1518
-37
lines changed

7 files changed

+1518
-37
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
tsp-output/

tools/sdk-ai-bots/azure-sdk-qa-bot-backend/tsp/main.tsp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ using TypeSpec.Versioning;
1111

1212
@service({
1313
title: "Azure SDK QA Assistant Service",
14-
version: "0.0.1"
1514
})
16-
@server("https://azuresdkbot-azuresdkbot-dev-czhxctdndmfdb5hq.eastasia-01.azurewebsites.net", "Development server")
17-
@server("https://azuresdkbot-dqh7g6btekbfa3hh.eastasia-01.azurewebsites.net", "Production server")
15+
@server("https://azuresdkqabot-dev-server-hrcrckaad5gcedcv.westus2-01.azurewebsites.net", "Development server")
16+
@server("https://azuresdkqabot-test-server-cbdbh2gva6h7hrfr.westus2-01.azurewebsites.net", "Testing server")
17+
@server("https://azuresdkqabot-server-c8czabhzhweadwgu.westus2-01.azurewebsites.net", "Production server")
1818
@versioned(Versions)
1919
namespace AzureSDK.QAAssistant;
2020

tools/sdk-ai-bots/azure-sdk-qa-bot-backend/tsp/model.tsp

Lines changed: 192 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,38 @@ namespace AzureSDK.QAAssistant;
88

99
@doc("Available tenant IDs for the QA bot service")
1010
union TenantID {
11-
@doc("Default TypeSpec QA bot")
12-
TypespecQABot: "typespec_qa_bot",
11+
@doc("Default Azure SDK QA bot")
12+
AzureSDKQaBot: "azure_sdk_qa_bot",
1313

1414
@doc("TypeSpec extension bot")
1515
TypeSpecExtension: "typespec_extension",
1616

1717
@doc("Python channel QA bot")
1818
PythonChannelQaBot: "python_channel_qa_bot",
19+
20+
@doc(".NET channel QA bot")
21+
DotnetChannelQaBot: "dotnet_channel_qa_bot",
22+
23+
@doc("Azure SDK onboarding bot")
24+
AzureSDKOnboarding: "azure_sdk_onboarding",
25+
26+
@doc("Golang channel QA bot")
27+
GolangChannelQaBot: "golang_channel_qa_bot",
28+
29+
@doc("Java channel QA bot")
30+
JavaChannelQaBot: "java_channel_qa_bot",
31+
32+
@doc("JavaScript channel QA bot")
33+
JavaScriptChannelQaBot: "javascript_channel_qa_bot",
34+
35+
@doc("General QA bot")
36+
GeneralQaBot: "general_qa_bot",
37+
38+
@doc("API spec review bot")
39+
APISpecReviewBot: "api_spec_review_bot",
40+
41+
@doc("Azure TypeSpec authoring bot")
42+
AzureTypespecAuthoring: "azure_typespec_authoring",
1943
}
2044

2145
@doc("Available data sources for knowledge retrieval")
@@ -43,6 +67,51 @@ union Source {
4367

4468
@doc("Azure Resource Manager RPC")
4569
AzureResourceManagerRPC: "azure_resource_manager_rpc",
70+
71+
@doc("TypeSpec migration documentation")
72+
TypeSpecMigration: "static_typespec_migration_docs",
73+
74+
@doc("Azure SDK documentation engineering")
75+
AzureSDKDocsEng: "azure-sdk-docs-eng",
76+
77+
@doc("Azure SDK internal wiki")
78+
AzureSDKInternalWiki: "azure-sdk-internal-wiki",
79+
80+
@doc("Azure SDK guidelines")
81+
AzureSDKGuidelines: "azure-sdk-guidelines",
82+
83+
@doc("TypeSpec Azure HTTP specs")
84+
TypeSpecAzureHttpSpecs: "typespec_azure_http_specs",
85+
86+
@doc("TypeSpec HTTP specs")
87+
TypeSpecHttpSpecs: "typespec_http_specs",
88+
89+
@doc("Azure SDK for Go documentation")
90+
AzureSDKForGoDocs: "azure_sdk_for_go_docs",
91+
92+
@doc("Static Azure documentation")
93+
StaticAzureDocs: "static_azure_docs",
94+
95+
@doc("TypeSpec to Swagger mapping")
96+
StaticTypeSpecToSwaggerMapping: "static_typespec_to_swagger_mapping",
97+
98+
@doc("Azure SDK for Java documentation")
99+
AzureSDKForJavaDocs: "azure_sdk_for_java_docs",
100+
101+
@doc("Azure SDK for Java wiki")
102+
AzureSDKForJavaWiki: "azure_sdk_for_java_wiki",
103+
104+
@doc("Autorest Java documentation")
105+
AutorestJavaDocs: "autorest_java_docs",
106+
107+
@doc("Azure SDK for JavaScript documentation")
108+
AzureSDKForJavaScriptDocs: "azure_sdk_for_js_docs",
109+
110+
@doc("Azure SDK for JavaScript wiki")
111+
AzureSDKForJavaScriptWiki: "azure_sdk_for_js_wiki",
112+
113+
@doc("Azure SDK for .NET documentation")
114+
AzureSDKForNetDocs: "azure_sdk_for_net_docs",
46115
}
47116

48117
@doc("Message roles in the conversation")
@@ -64,6 +133,9 @@ union AdditionalInfoType {
64133

65134
@doc("Image content")
66135
Image: "image",
136+
137+
@doc("Text content")
138+
Text: "text",
67139
}
68140

69141
@doc("User reaction types for feedback")
@@ -75,9 +147,9 @@ union Reaction {
75147
Bad: "bad",
76148
}
77149

78-
@doc("Question categorization for intent analysis")
79-
union QuestionCategory {
80-
@doc("Unknown category")
150+
@doc("Question scope for intent analysis")
151+
union QuestionScope {
152+
@doc("Unknown scope")
81153
Unknown: "unknown",
82154

83155
@doc("Branded question (specific to Azure/Microsoft products)")
@@ -87,6 +159,18 @@ union QuestionCategory {
87159
Unbranded: "unbranded",
88160
}
89161

162+
@doc("Service type for filtering")
163+
union ServiceType {
164+
@doc("Unknown service type")
165+
Unknown: "unknown",
166+
167+
@doc("Data plane service")
168+
DataPlane: "data-plane",
169+
170+
@doc("Management plane service")
171+
ManagementPlane: "management-plane",
172+
}
173+
90174
@doc("A message in the conversation")
91175
model Message {
92176
@doc("The role of the message sender")
@@ -95,9 +179,6 @@ model Message {
95179
@doc("The content of the message")
96180
content: string;
97181

98-
@doc("The raw content of the message, used for searching")
99-
raw_content?: string;
100-
101182
@doc("The name of the message sender, used for system messages")
102183
name?: string;
103184
}
@@ -130,25 +211,31 @@ model AdditionalInfo {
130211
}
131212

132213
@doc("Intent analysis result for the question")
133-
model IntensionResult {
214+
model Intention {
134215
@doc("The question to ask the agent")
135216
question: string;
136217

137218
@doc("The category of the question")
138-
category: QuestionCategory;
219+
category: string;
220+
221+
@doc("The type of the spec, such as typespec, azure rest api, etc.")
222+
spec_type?: string;
223+
224+
@doc("Whether to invoke RAG workflow")
225+
needs_rag_processing: boolean;
226+
227+
@doc("The scope of the question")
228+
question_scope?: QuestionScope;
229+
230+
@doc("The service type for filtering")
231+
service_type?: ServiceType;
139232
}
140233

141234
@doc("Request for chat completion")
142235
model CompletionRequest {
143236
@doc("The tenant ID of the agent")
144237
tenant_id: TenantID;
145238

146-
@doc("The prompt template to use for the agent")
147-
prompt_template?: string;
148-
149-
@doc("The arguments to use for the prompt template")
150-
prompt_template_arguments?: string;
151-
152239
@doc("The number of top K documents to search for the answer. Default is 10")
153240
top_k?: int32;
154241

@@ -169,6 +256,9 @@ model CompletionRequest {
169256

170257
@doc("Additional information to provide to the agent, such as links or images")
171258
additional_infos?: AdditionalInfo[];
259+
260+
@doc("Optional intention fields that override LLM intention recognition results")
261+
intention?: Intention;
172262
}
173263

174264
@doc("Response from chat completion")
@@ -189,7 +279,13 @@ model CompletionResponse {
189279
full_context?: string;
190280

191281
@doc("The intention analysis of the question")
192-
intension?: IntensionResult;
282+
intention?: Intention;
283+
284+
@doc("The reasoning progress of generating the answer")
285+
reasoning?: string;
286+
287+
@doc("The tenant ID the question is routed to")
288+
route_tenant?: TenantID;
193289
}
194290

195291
@doc("Request for submitting feedback")
@@ -224,23 +320,90 @@ model FeedbackResponse {
224320
// Empty response model
225321
}
226322

227-
@doc("Error response")
323+
@doc("Simple error response used by feedback API")
228324
@error
229-
model ErrorResponse {
325+
model SimpleErrorResponse {
230326
@doc("Error message")
231327
error: string;
232328
}
233329

234-
@doc("Unauthorized error response")
235-
@error
236-
model UnauthorizedError {
237-
@doc("Error message indicating authentication failure")
238-
error: "Unauthorized - API key is missing or invalid";
330+
@doc("Error codes for the service")
331+
union ErrorCode {
332+
// Client Error Codes (4xx)
333+
@doc("Invalid request format or parameters")
334+
InvalidRequest: "INVALID_REQUEST",
335+
336+
@doc("Message field is missing")
337+
MissingMessage: "MISSING_MESSAGE",
338+
339+
@doc("Message content is empty")
340+
EmptyContent: "EMPTY_CONTENT",
341+
342+
@doc("Invalid tenant ID provided")
343+
InvalidTenantID: "INVALID_TENANT_ID",
344+
345+
@doc("Authentication failed")
346+
Unauthorized: "UNAUTHORIZED",
347+
348+
// Server Error Codes (5xx)
349+
@doc("Service initialization failed")
350+
ServiceInitFailure: "SERVICE_INIT_FAILURE",
351+
352+
@doc("LLM service call failed")
353+
LLMServiceFailure: "LLM_SERVICE_FAILURE",
354+
355+
@doc("LLM rate limit exceeded")
356+
LLMRateLimitFailure: "LLM_RATE_LIMIT_FAILURE",
357+
358+
@doc("Search service call failed")
359+
SearchFailure: "SEARCH_FAILURE",
360+
361+
@doc("Internal server error")
362+
InternalError: "INTERNAL_ERROR",
363+
}
364+
365+
@doc("Error category for monitoring and alerting")
366+
union ErrorCategory {
367+
@doc("Validation error")
368+
Validation: "validation",
369+
370+
@doc("Authentication error")
371+
Authentication: "authentication",
372+
373+
@doc("Authorization error")
374+
Authorization: "authorization",
375+
376+
@doc("Rate limit error")
377+
RateLimit: "rate limit",
378+
379+
@doc("Service error")
380+
Service: "service",
381+
382+
@doc("Dependency error")
383+
Dependency: "dependency",
384+
385+
@doc("Internal error")
386+
Internal: "internal",
239387
}
240388

241-
@doc("API Key authentication scheme")
242-
model ApiKeyAuth {
243-
@doc("API key for authentication")
244-
@header("X-API-Key")
245-
apiKey: string;
389+
@doc("Structured API error response")
390+
@error
391+
model ErrorResponse {
392+
@doc("Error code identifying the type of error")
393+
code: ErrorCode;
394+
395+
@doc("Human-readable error message")
396+
message: string;
397+
398+
@doc("Error category for monitoring and alerting")
399+
category: ErrorCategory;
400+
401+
@doc("Additional error details")
402+
details?: unknown;
403+
404+
@doc("Request ID for tracing")
405+
request_id?: string;
406+
407+
@doc("Timestamp when the error occurred")
408+
timestamp?: string;
246409
}

0 commit comments

Comments
 (0)