Skip to content

Commit

Permalink
chore: update schemas related to Unleash AI chat
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogois committed Oct 16, 2024
1 parent b9ea664 commit 17a1d51
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib/openapi/spec/ai-chat-message-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const aiChatMessageSchema = {
$id: '#/components/schemas/aiChatMessageSchema',
type: 'object',
description: 'Describes an Unleash AI chat message.',
additionalProperties: false,
required: ['role', 'content'],
properties: {
role: {
Expand Down
20 changes: 20 additions & 0 deletions src/lib/openapi/spec/ai-chat-new-message-schema.ts
Original file line number Diff line number Diff line change
@@ -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>;
21 changes: 20 additions & 1 deletion src/lib/openapi/spec/ai-chat-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,27 @@ export const aiChatSchema = {
$id: '#/components/schemas/aiChatSchema',
type: 'object',
description: 'Describes an Unleash AI chat.',
required: ['messages'],
additionalProperties: false,
required: ['id', 'userId', 'createdAt', 'messages'],
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: {
type: 'array',
description:
Expand Down
1 change: 1 addition & 0 deletions src/lib/openapi/spec/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './advanced-playground-feature-schema';
export * from './advanced-playground-request-schema';
export * from './advanced-playground-response-schema';
export * from './ai-chat-message-schema';
export * from './ai-chat-new-message-schema';
export * from './ai-chat-schema';
export * from './api-token-schema';
export * from './api-tokens-schema';
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
);
};

0 comments on commit 17a1d51

Please sign in to comment.