mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	chore: update schemas related to Unleash AI chat (#8463)
https://linear.app/unleash/issue/2-2779/store-conversations-in-the-database Updates schemas related to Unleash AI chat and renames the `chat` column to `messages` to ensure everything aligns nicely.
This commit is contained in:
		
							parent
							
								
									131e608885
								
							
						
					
					
						commit
						3f8d4c3538
					
				| @ -4,6 +4,7 @@ export const aiChatMessageSchema = { | |||||||
|     $id: '#/components/schemas/aiChatMessageSchema', |     $id: '#/components/schemas/aiChatMessageSchema', | ||||||
|     type: 'object', |     type: 'object', | ||||||
|     description: 'Describes an Unleash AI chat message.', |     description: 'Describes an Unleash AI chat message.', | ||||||
|  |     additionalProperties: false, | ||||||
|     required: ['role', 'content'], |     required: ['role', 'content'], | ||||||
|     properties: { |     properties: { | ||||||
|         role: { |         role: { | ||||||
|  | |||||||
							
								
								
									
										20
									
								
								src/lib/openapi/spec/ai-chat-new-message-schema.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/lib/openapi/spec/ai-chat-new-message-schema.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | |||||||
|  | import type { FromSchema } from 'json-schema-to-ts'; | ||||||
|  | 
 | ||||||
|  | export const aiChatNewMessageSchema = { | ||||||
|  |     $id: '#/components/schemas/aiChatNewMessageSchema', | ||||||
|  |     type: 'object', | ||||||
|  |     description: 'Describes a new Unleash AI chat message sent by the user.', | ||||||
|  |     required: ['message'], | ||||||
|  |     properties: { | ||||||
|  |         message: { | ||||||
|  |             type: 'string', | ||||||
|  |             description: 'The message content.', | ||||||
|  |             example: 'What is your purpose?', | ||||||
|  |         }, | ||||||
|  |     }, | ||||||
|  |     components: { | ||||||
|  |         schemas: {}, | ||||||
|  |     }, | ||||||
|  | } as const; | ||||||
|  | 
 | ||||||
|  | export type AIChatNewMessageSchema = FromSchema<typeof aiChatNewMessageSchema>; | ||||||
| @ -5,8 +5,27 @@ export const aiChatSchema = { | |||||||
|     $id: '#/components/schemas/aiChatSchema', |     $id: '#/components/schemas/aiChatSchema', | ||||||
|     type: 'object', |     type: 'object', | ||||||
|     description: 'Describes an Unleash AI chat.', |     description: 'Describes an Unleash AI chat.', | ||||||
|     required: ['messages'], |     additionalProperties: false, | ||||||
|  |     required: ['id', 'userId', 'createdAt', 'messages'], | ||||||
|     properties: { |     properties: { | ||||||
|  |         id: { | ||||||
|  |             type: 'string', | ||||||
|  |             pattern: '^[0-9]+$', // BigInt
 | ||||||
|  |             description: | ||||||
|  |                 "The chat's ID. Chat IDs are incrementing integers. In other words, a more recently created chat will always have a higher ID than an older one. This ID is represented as a string since it is a BigInt.", | ||||||
|  |             example: '7', | ||||||
|  |         }, | ||||||
|  |         userId: { | ||||||
|  |             type: 'integer', | ||||||
|  |             description: 'The ID of the user that the chat belongs to.', | ||||||
|  |             example: 7, | ||||||
|  |         }, | ||||||
|  |         createdAt: { | ||||||
|  |             type: 'string', | ||||||
|  |             format: 'date-time', | ||||||
|  |             description: 'The date and time of when the chat was created.', | ||||||
|  |             example: '2023-12-27T13:37:00+01:00', | ||||||
|  |         }, | ||||||
|         messages: { |         messages: { | ||||||
|             type: 'array', |             type: 'array', | ||||||
|             description: |             description: | ||||||
|  | |||||||
| @ -15,6 +15,7 @@ export * from './advanced-playground-feature-schema'; | |||||||
| export * from './advanced-playground-request-schema'; | export * from './advanced-playground-request-schema'; | ||||||
| export * from './advanced-playground-response-schema'; | export * from './advanced-playground-response-schema'; | ||||||
| export * from './ai-chat-message-schema'; | export * from './ai-chat-message-schema'; | ||||||
|  | export * from './ai-chat-new-message-schema'; | ||||||
| export * from './ai-chat-schema'; | export * from './ai-chat-schema'; | ||||||
| export * from './api-token-schema'; | export * from './api-token-schema'; | ||||||
| export * from './api-tokens-schema'; | export * from './api-tokens-schema'; | ||||||
|  | |||||||
| @ -0,0 +1,17 @@ | |||||||
|  | exports.up = function (db, cb) { | ||||||
|  |     db.runSql( | ||||||
|  |         ` | ||||||
|  |         ALTER TABLE ai_chats RENAME COLUMN chat TO messages; | ||||||
|  |         `,
 | ||||||
|  |         cb, | ||||||
|  |     ); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | exports.down = function (db, cb) { | ||||||
|  |     db.runSql( | ||||||
|  |         ` | ||||||
|  |         ALTER TABLE ai_chats RENAME COLUMN messages TO chat; | ||||||
|  |         `,
 | ||||||
|  |         cb, | ||||||
|  |     ); | ||||||
|  | }; | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user