add openai assistant

This commit is contained in:
Henry
2023-11-07 20:45:25 +00:00
parent 12fb5a3a3b
commit 0f293e5a59
24 changed files with 1443 additions and 21 deletions
@@ -0,0 +1,24 @@
/* eslint-disable */
import { Entity, Column, CreateDateColumn, UpdateDateColumn, PrimaryGeneratedColumn } from 'typeorm'
import { IAssistant } from '../../Interface'
@Entity()
export class Assistant implements IAssistant {
@PrimaryGeneratedColumn('uuid')
id: string
@Column({ type: 'text' })
details: string
@Column()
credential: string
@Column({ nullable: true })
iconSrc?: string
@CreateDateColumn()
createdDate: Date
@UpdateDateColumn()
updatedDate: Date
}
@@ -2,10 +2,12 @@ import { ChatFlow } from './ChatFlow'
import { ChatMessage } from './ChatMessage'
import { Credential } from './Credential'
import { Tool } from './Tool'
import { Assistant } from './Assistant'
export const entities = {
ChatFlow,
ChatMessage,
Credential,
Tool
Tool,
Assistant
}
@@ -0,0 +1,21 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddAssistantEntity1699325775451 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE IF NOT EXISTS \`assistant\` (
\`id\` varchar(36) NOT NULL,
\`credential\` varchar(255) NOT NULL,
\`details\` text NOT NULL,
\`iconSrc\` varchar(255) DEFAULT NULL,
\`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
\`updatedDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
PRIMARY KEY (\`id\`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;`
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE assistant`)
}
}
@@ -6,6 +6,7 @@ import { ModifyTool1694001465232 } from './1694001465232-ModifyTool'
import { AddApiConfig1694099200729 } from './1694099200729-AddApiConfig'
import { AddAnalytic1694432361423 } from './1694432361423-AddAnalytic'
import { AddChatHistory1694658767766 } from './1694658767766-AddChatHistory'
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
export const mysqlMigrations = [
Init1693840429259,
@@ -15,5 +16,6 @@ export const mysqlMigrations = [
ModifyTool1694001465232,
AddApiConfig1694099200729,
AddAnalytic1694432361423,
AddChatHistory1694658767766
AddChatHistory1694658767766,
AddAssistantEntity1699325775451
]
@@ -0,0 +1,21 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddAssistantEntity1699325775451 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE IF NOT EXISTS assistant (
id uuid NOT NULL DEFAULT uuid_generate_v4(),
"credential" varchar NOT NULL,
"details" text NOT NULL,
"iconSrc" varchar NULL,
"createdDate" timestamp NOT NULL DEFAULT now(),
"updatedDate" timestamp NOT NULL DEFAULT now(),
CONSTRAINT "PK_3c7cea7a044ac4c92764576cdbf" PRIMARY KEY (id)
);`
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE assistant`)
}
}
@@ -6,6 +6,7 @@ import { ModifyTool1693997339912 } from './1693997339912-ModifyTool'
import { AddApiConfig1694099183389 } from './1694099183389-AddApiConfig'
import { AddAnalytic1694432361423 } from './1694432361423-AddAnalytic'
import { AddChatHistory1694658756136 } from './1694658756136-AddChatHistory'
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
export const postgresMigrations = [
Init1693891895163,
@@ -15,5 +16,6 @@ export const postgresMigrations = [
ModifyTool1693997339912,
AddApiConfig1694099183389,
AddAnalytic1694432361423,
AddChatHistory1694658756136
AddChatHistory1694658756136,
AddAssistantEntity1699325775451
]
@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddAssistantEntity1699325775451 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE IF NOT EXISTS "assistant" ("id" varchar PRIMARY KEY NOT NULL, "details" text NOT NULL, "credential" varchar NOT NULL, "iconSrc" varchar, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));`
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE assistant`)
}
}
@@ -6,6 +6,7 @@ import { ModifyTool1693924207475 } from './1693924207475-ModifyTool'
import { AddApiConfig1694090982460 } from './1694090982460-AddApiConfig'
import { AddAnalytic1694432361423 } from './1694432361423-AddAnalytic'
import { AddChatHistory1694657778173 } from './1694657778173-AddChatHistory'
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
export const sqliteMigrations = [
Init1693835579790,
@@ -15,5 +16,6 @@ export const sqliteMigrations = [
ModifyTool1693924207475,
AddApiConfig1694090982460,
AddAnalytic1694432361423,
AddChatHistory1694657778173
AddChatHistory1694657778173,
AddAssistantEntity1699325775451
]