feat: implement chat and conversation history management with database schema and API endpoints
All checks were successful
Build and Release / release (push) Successful in 1m30s

This commit is contained in:
2026-05-08 21:03:26 +07:00
parent 4d4640c20a
commit 600246426b
17 changed files with 1306 additions and 33 deletions

View File

@@ -462,6 +462,72 @@ const docTemplate = `{
}
}
},
"/chatbot/history": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get chatbot history for the current user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Chatbot"
],
"summary": "Get chatbot history",
"parameters": [
{
"type": "string",
"description": "Cursor ID for pagination",
"name": "cursor",
"in": "query"
},
{
"type": "integer",
"description": "Limit number of items returned, default 10",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"allOf": [
{
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/history-api_internal_dtos_response.GetChatbotHistoryResponse"
}
}
}
]
}
},
"400": {
"description": "Invalid request",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
}
},
"/entities": {
"get": {
"description": "Search entities with cursor pagination",
@@ -4208,12 +4274,6 @@ const docTemplate = `{
"$ref": "#/definitions/history-api_internal_dtos_request.EntityWikiLinkSnapshot"
}
},
"entity_wikis": {
"type": "array",
"items": {
"$ref": "#/definitions/history-api_internal_dtos_request.EntityWikiLinkSnapshot"
}
},
"geometries": {
"type": "array",
"items": {
@@ -4378,8 +4438,7 @@ const docTemplate = `{
"history-api_internal_dtos_request.EntitySnapshot": {
"type": "object",
"required": [
"id",
"name"
"id"
],
"properties": {
"base_hash": {
@@ -4452,7 +4511,8 @@ const docTemplate = `{
"type": "string",
"enum": [
"reference",
"delete"
"delete",
"binding"
]
},
"wiki_id": {
@@ -4586,14 +4646,21 @@ const docTemplate = `{
},
"geometry_id": {
"type": "string"
},
"operation": {
"type": "string",
"enum": [
"reference",
"delete",
"binding"
]
}
}
},
"history-api_internal_dtos_request.GeometrySnapshot": {
"type": "object",
"required": [
"id",
"type"
"id"
],
"properties": {
"base_hash": {
@@ -4926,6 +4993,26 @@ const docTemplate = `{
}
}
},
"history-api_internal_dtos_response.ChatbotHistoryDto": {
"type": "object",
"properties": {
"answer": {
"type": "string"
},
"created_at": {
"type": "string"
},
"id": {
"type": "string"
},
"question": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"history-api_internal_dtos_response.CommonResponse": {
"type": "object",
"properties": {
@@ -4939,6 +5026,20 @@ const docTemplate = `{
}
}
},
"history-api_internal_dtos_response.GetChatbotHistoryResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/history-api_internal_dtos_response.ChatbotHistoryDto"
}
},
"pre_cursor": {
"type": "string"
}
}
},
"history-api_internal_dtos_response.PaginatedResponse": {
"type": "object",
"properties": {

View File

@@ -455,6 +455,72 @@
}
}
},
"/chatbot/history": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get chatbot history for the current user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Chatbot"
],
"summary": "Get chatbot history",
"parameters": [
{
"type": "string",
"description": "Cursor ID for pagination",
"name": "cursor",
"in": "query"
},
{
"type": "integer",
"description": "Limit number of items returned, default 10",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"allOf": [
{
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/history-api_internal_dtos_response.GetChatbotHistoryResponse"
}
}
}
]
}
},
"400": {
"description": "Invalid request",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
}
},
"/entities": {
"get": {
"description": "Search entities with cursor pagination",
@@ -4201,12 +4267,6 @@
"$ref": "#/definitions/history-api_internal_dtos_request.EntityWikiLinkSnapshot"
}
},
"entity_wikis": {
"type": "array",
"items": {
"$ref": "#/definitions/history-api_internal_dtos_request.EntityWikiLinkSnapshot"
}
},
"geometries": {
"type": "array",
"items": {
@@ -4371,8 +4431,7 @@
"history-api_internal_dtos_request.EntitySnapshot": {
"type": "object",
"required": [
"id",
"name"
"id"
],
"properties": {
"base_hash": {
@@ -4445,7 +4504,8 @@
"type": "string",
"enum": [
"reference",
"delete"
"delete",
"binding"
]
},
"wiki_id": {
@@ -4579,14 +4639,21 @@
},
"geometry_id": {
"type": "string"
},
"operation": {
"type": "string",
"enum": [
"reference",
"delete",
"binding"
]
}
}
},
"history-api_internal_dtos_request.GeometrySnapshot": {
"type": "object",
"required": [
"id",
"type"
"id"
],
"properties": {
"base_hash": {
@@ -4919,6 +4986,26 @@
}
}
},
"history-api_internal_dtos_response.ChatbotHistoryDto": {
"type": "object",
"properties": {
"answer": {
"type": "string"
},
"created_at": {
"type": "string"
},
"id": {
"type": "string"
},
"question": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"history-api_internal_dtos_response.CommonResponse": {
"type": "object",
"properties": {
@@ -4932,6 +5019,20 @@
}
}
},
"history-api_internal_dtos_response.GetChatbotHistoryResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/history-api_internal_dtos_response.ChatbotHistoryDto"
}
},
"pre_cursor": {
"type": "string"
}
}
},
"history-api_internal_dtos_response.PaginatedResponse": {
"type": "object",
"properties": {

View File

@@ -80,10 +80,6 @@ definitions:
items:
$ref: '#/definitions/history-api_internal_dtos_request.EntityWikiLinkSnapshot'
type: array
entity_wikis:
items:
$ref: '#/definitions/history-api_internal_dtos_request.EntityWikiLinkSnapshot'
type: array
geometries:
items:
$ref: '#/definitions/history-api_internal_dtos_request.GeometrySnapshot'
@@ -232,7 +228,6 @@ definitions:
type: number
required:
- id
- name
type: object
history-api_internal_dtos_request.EntityWikiLinkSnapshot:
properties:
@@ -247,6 +242,7 @@ definitions:
enum:
- reference
- delete
- binding
type: string
wiki_id:
type: string
@@ -338,6 +334,12 @@ definitions:
type: string
geometry_id:
type: string
operation:
enum:
- reference
- delete
- binding
type: string
required:
- entity_id
- geometry_id
@@ -380,7 +382,6 @@ definitions:
type: string
required:
- id
- type
type: object
history-api_internal_dtos_request.MediaBulkDeleteDto:
properties:
@@ -577,6 +578,19 @@ definitions:
- id
- title
type: object
history-api_internal_dtos_response.ChatbotHistoryDto:
properties:
answer:
type: string
created_at:
type: string
id:
type: string
question:
type: string
user_id:
type: string
type: object
history-api_internal_dtos_response.CommonResponse:
properties:
data: {}
@@ -586,6 +600,15 @@ definitions:
status:
type: boolean
type: object
history-api_internal_dtos_response.GetChatbotHistoryResponse:
properties:
items:
items:
$ref: '#/definitions/history-api_internal_dtos_response.ChatbotHistoryDto'
type: array
pre_cursor:
type: string
type: object
history-api_internal_dtos_response.PaginatedResponse:
properties:
data: {}
@@ -962,6 +985,45 @@ paths:
summary: Ask the AI chatbot
tags:
- Chatbot
/chatbot/history:
get:
consumes:
- application/json
description: Get chatbot history for the current user
parameters:
- description: Cursor ID for pagination
in: query
name: cursor
type: string
- description: Limit number of items returned, default 10
in: query
name: limit
type: integer
produces:
- application/json
responses:
"200":
description: Successful response
schema:
allOf:
- $ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
- properties:
data:
$ref: '#/definitions/history-api_internal_dtos_response.GetChatbotHistoryResponse'
type: object
"400":
description: Invalid request
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
security:
- BearerAuth: []
summary: Get chatbot history
tags:
- Chatbot
/entities:
get:
consumes: