File tree Expand file tree Collapse file tree 3 files changed +81
-9
lines changed Expand file tree Collapse file tree 3 files changed +81
-9
lines changed Original file line number Diff line number Diff line change 302302 },
303303 "responses" : {
304304 "200" : {
305- "description" : " Successful Response " ,
305+ "description" : " Feedback received and stored " ,
306306 "content" : {
307307 "application/json" : {
308308 "schema" : {
309309 "$ref" : " #/components/schemas/FeedbackResponse"
310310 }
311311 }
312- },
313- "response" : " Feedback received and stored"
312+ }
314313 },
315- "400 " : {
314+ "401 " : {
316315 "description" : " Missing or invalid credentials provided by client" ,
317316 "content" : {
318317 "application/json" : {
323322 }
324323 },
325324 "403" : {
326- "description" : " User is not authorized " ,
325+ "description" : " Client does not have permission to access resource " ,
327326 "content" : {
328327 "application/json" : {
329328 "schema" : {
332331 }
333332 }
334333 },
334+ "500" : {
335+ "description" : " User feedback can not be stored" ,
336+ "content" : {
337+ "application/json" : {
338+ "schema" : {
339+ "$ref" : " #/components/schemas/ErrorResponse"
340+ }
341+ }
342+ }
343+ },
335344 "422" : {
336345 "description" : " Validation Error" ,
337346 "content" : {
11811190 "title" : " DatabaseConfiguration" ,
11821191 "description" : " Database configuration."
11831192 },
1193+ "ErrorResponse" : {
1194+ "properties" : {
1195+ "detail" : {
1196+ "additionalProperties" : {
1197+ "type" : " string"
1198+ },
1199+ "type" : " object" ,
1200+ "title" : " Detail"
1201+ }
1202+ },
1203+ "type" : " object" ,
1204+ "required" : [
1205+ " detail"
1206+ ],
1207+ "title" : " ErrorResponse" ,
1208+ "description" : " Model representing error response for query endpoint." ,
1209+ "examples" : [
1210+ {
1211+ "detail" : {
1212+ "cause" : " Failed to handle request to https://bam-api.res.ibm.com/v2/text" ,
1213+ "response" : " Error while validation question"
1214+ }
1215+ },
1216+ {
1217+ "detail" : {
1218+ "cause" : " Invalid conversation ID 1237-e89b-12d3-a456-426614174000" ,
1219+ "response" : " Error retrieving conversation history"
1220+ }
1221+ }
1222+ ]
1223+ },
11841224 "FeedbackCategory" : {
11851225 "type" : " string" ,
11861226 "enum" : [
Original file line number Diff line number Diff line change 1111from auth .interface import AuthTuple
1212from configuration import configuration
1313from models .responses import (
14+ ErrorResponse ,
1415 FeedbackResponse ,
1516 StatusResponse ,
1617 UnauthorizedResponse ,
2324router = APIRouter (prefix = "/feedback" , tags = ["feedback" ])
2425auth_dependency = get_auth_dependency ()
2526
26- # Response for the feedback endpoint
2727feedback_response : dict [int | str , dict [str , Any ]] = {
28- 200 : {"response" : "Feedback received and stored" },
29- 400 : {
28+ 200 : {
29+ "description" : "Feedback received and stored" ,
30+ "model" : FeedbackResponse ,
31+ },
32+ 401 : {
3033 "description" : "Missing or invalid credentials provided by client" ,
3134 "model" : UnauthorizedResponse ,
3235 },
3336 403 : {
34- "description" : "User is not authorized " ,
37+ "description" : "Client does not have permission to access resource " ,
3538 "model" : ForbiddenResponse ,
3639 },
40+ 500 : {
41+ "description" : "User feedback can not be stored" ,
42+ "model" : ErrorResponse ,
43+ },
3744}
3845
3946
Original file line number Diff line number Diff line change @@ -470,3 +470,28 @@ class ConversationsListResponse(BaseModel):
470470 ]
471471 }
472472 }
473+
474+
475+ class ErrorResponse (BaseModel ):
476+ """Model representing error response for query endpoint."""
477+
478+ detail : dict [str , str ]
479+
480+ model_config = {
481+ "json_schema_extra" : {
482+ "examples" : [
483+ {
484+ "detail" : {
485+ "response" : "Error while validation question" ,
486+ "cause" : "Failed to handle request to https://bam-api.res.ibm.com/v2/text" ,
487+ },
488+ },
489+ {
490+ "detail" : {
491+ "response" : "Error retrieving conversation history" ,
492+ "cause" : "Invalid conversation ID 1237-e89b-12d3-a456-426614174000" ,
493+ },
494+ },
495+ ]
496+ }
497+ }
You can’t perform that action at this time.
0 commit comments