Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 45 additions & 5 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,16 @@
},
"responses": {
"200": {
"description": "Successful Response",
"description": "Feedback received and stored",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FeedbackResponse"
}
}
},
"response": "Feedback received and stored"
}
},
"400": {
"401": {
"description": "Missing or invalid credentials provided by client",
"content": {
"application/json": {
Expand All @@ -323,7 +322,7 @@
}
},
"403": {
"description": "User is not authorized",
"description": "Client does not have permission to access resource",
"content": {
"application/json": {
"schema": {
Expand All @@ -332,6 +331,16 @@
}
}
},
"500": {
"description": "User feedback can not be stored",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
Expand Down Expand Up @@ -1181,6 +1190,37 @@
"title": "DatabaseConfiguration",
"description": "Database configuration."
},
"ErrorResponse": {
"properties": {
"detail": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"title": "Detail"
}
},
"type": "object",
"required": [
"detail"
],
"title": "ErrorResponse",
"description": "Model representing error response for query endpoint.",
"examples": [
{
"detail": {
"cause": "Failed to handle request to https://bam-api.res.ibm.com/v2/text",
"response": "Error while validation question"
}
},
{
"detail": {
"cause": "Invalid conversation ID 1237-e89b-12d3-a456-426614174000",
"response": "Error retrieving conversation history"
}
}
]
},
"FeedbackCategory": {
"type": "string",
"enum": [
Expand Down
15 changes: 11 additions & 4 deletions src/app/endpoints/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from auth.interface import AuthTuple
from configuration import configuration
from models.responses import (
ErrorResponse,
FeedbackResponse,
StatusResponse,
UnauthorizedResponse,
Expand All @@ -23,17 +24,23 @@
router = APIRouter(prefix="/feedback", tags=["feedback"])
auth_dependency = get_auth_dependency()

# Response for the feedback endpoint
feedback_response: dict[int | str, dict[str, Any]] = {
200: {"response": "Feedback received and stored"},
400: {
200: {
"description": "Feedback received and stored",
"model": FeedbackResponse,
},
401: {
"description": "Missing or invalid credentials provided by client",
"model": UnauthorizedResponse,
},
403: {
"description": "User is not authorized",
"description": "Client does not have permission to access resource",
"model": ForbiddenResponse,
},
500: {
"description": "User feedback can not be stored",
"model": ErrorResponse,
},
}


Expand Down
25 changes: 25 additions & 0 deletions src/models/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,3 +470,28 @@ class ConversationsListResponse(BaseModel):
]
}
}


class ErrorResponse(BaseModel):
"""Model representing error response for query endpoint."""

detail: dict[str, str]

model_config = {
"json_schema_extra": {
"examples": [
{
"detail": {
"response": "Error while validation question",
"cause": "Failed to handle request to https://bam-api.res.ibm.com/v2/text",
},
},
{
"detail": {
"response": "Error retrieving conversation history",
"cause": "Invalid conversation ID 1237-e89b-12d3-a456-426614174000",
},
},
]
}
}