-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
920a2e0
commit ad545d1
Showing
14 changed files
with
247 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
cortex-js/src/infrastructure/database/mysql-database.providers.ts
This file was deleted.
Oops, something went wrong.
7 changes: 4 additions & 3 deletions
7
cortex-js/src/infrastructure/database/providers/assistant.providers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { AssistantEntity } from '@/infrastructure/entities/assistant.entity'; | ||
import { DataSource } from 'typeorm'; | ||
import { Sequelize } from 'sequelize-typescript'; | ||
|
||
export const assistantProviders = [ | ||
{ | ||
provide: 'ASSISTANT_REPOSITORY', | ||
useFactory: (dataSource: DataSource) => | ||
dataSource.getRepository(AssistantEntity), | ||
useFactory: async(sequelize: Sequelize) =>{ | ||
return sequelize.getRepository(AssistantEntity); | ||
}, | ||
inject: ['DATA_SOURCE'], | ||
}, | ||
]; |
9 changes: 5 additions & 4 deletions
9
cortex-js/src/infrastructure/database/providers/message.providers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { MessageEntity } from '@/infrastructure/entities/message.entity'; | ||
import { DataSource } from 'typeorm'; | ||
import { MessageEntity } from "@/infrastructure/entities/message.entity"; | ||
import { Sequelize } from "sequelize-typescript"; | ||
|
||
export const messageProviders = [ | ||
{ | ||
provide: 'MESSAGE_REPOSITORY', | ||
useFactory: (dataSource: DataSource) => | ||
dataSource.getRepository(MessageEntity), | ||
useFactory: async(sequelize: Sequelize) =>{ | ||
return sequelize.getRepository(MessageEntity); | ||
}, | ||
inject: ['DATA_SOURCE'], | ||
}, | ||
]; |
8 changes: 5 additions & 3 deletions
8
cortex-js/src/infrastructure/database/providers/thread.providers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { ThreadEntity } from '@/infrastructure/entities/thread.entity'; | ||
import { DataSource } from 'typeorm'; | ||
import { Sequelize } from 'sequelize-typescript'; | ||
|
||
export const threadProviders = [ | ||
{ | ||
provide: 'THREAD_REPOSITORY', | ||
useFactory: (dataSource: DataSource) => | ||
dataSource.getRepository(ThreadEntity), | ||
useFactory: async(sequelize: Sequelize) =>{ | ||
return sequelize.getRepository(ThreadEntity); | ||
}, | ||
inject: ['DATA_SOURCE'], | ||
}, | ||
]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 56 additions & 17 deletions
73
cortex-js/src/infrastructure/entities/assistant.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,90 @@ | ||
import { Table, Column, Model, PrimaryKey, DataType } from 'sequelize-typescript'; | ||
import { Assistant } from '@/domain/models/assistant.interface'; | ||
import type { | ||
AssistantToolResources, | ||
AssistantResponseFormatOption, | ||
} from '@/domain/models/assistant.interface'; | ||
import { Column, Entity, PrimaryColumn } from 'typeorm'; | ||
|
||
@Entity('assistants') | ||
export class AssistantEntity implements Assistant { | ||
@PrimaryColumn({ type: String }) | ||
@Table({ tableName: 'assistants', timestamps: false}) | ||
export class AssistantEntity extends Model implements Assistant { | ||
@PrimaryKey | ||
@Column({ | ||
type: DataType.STRING, | ||
}) | ||
id: string; | ||
|
||
@Column({ type: String, nullable: true }) | ||
@Column({ | ||
type: DataType.STRING, | ||
allowNull: true, | ||
}) | ||
avatar?: string; | ||
|
||
@Column({ type: String }) | ||
@Column({ | ||
type: DataType.STRING, | ||
defaultValue: 'assistant', | ||
}) | ||
object: 'assistant'; | ||
|
||
@Column({ type: Number }) | ||
@Column({ | ||
type: DataType.INTEGER, | ||
}) | ||
created_at: number; | ||
|
||
@Column({ type: String, nullable: true }) | ||
@Column({ | ||
type: DataType.STRING, | ||
allowNull: true, | ||
}) | ||
name: string | null; | ||
|
||
@Column({ type: String, nullable: true }) | ||
@Column({ | ||
type: DataType.STRING, | ||
allowNull: true, | ||
}) | ||
description: string | null; | ||
|
||
@Column({ type: String }) | ||
@Column({ | ||
type: DataType.STRING, | ||
}) | ||
model: string; | ||
|
||
@Column({ type: String, nullable: true }) | ||
@Column({ | ||
type: DataType.STRING, | ||
allowNull: true, | ||
}) | ||
instructions: string | null; | ||
|
||
@Column({ type: 'simple-json' }) | ||
@Column({ | ||
type: DataType.JSON, | ||
}) | ||
tools: any; | ||
|
||
@Column({ type: 'simple-json', nullable: true }) | ||
@Column({ | ||
type: DataType.JSON, | ||
allowNull: true, | ||
}) | ||
metadata: any | null; | ||
|
||
@Column({ type: Number, nullable: true }) | ||
@Column({ | ||
type: DataType.FLOAT, | ||
allowNull: true, | ||
}) | ||
top_p: number | null; | ||
|
||
@Column({ type: Number, nullable: true }) | ||
@Column({ | ||
type: DataType.FLOAT, | ||
allowNull: true, | ||
}) | ||
temperature: number | null; | ||
|
||
@Column({ type: 'simple-json', nullable: true }) | ||
@Column({ | ||
type: DataType.JSON, | ||
allowNull: true, | ||
}) | ||
response_format: AssistantResponseFormatOption | null; | ||
|
||
@Column({ type: 'simple-json', nullable: true }) | ||
@Column({ | ||
type: DataType.JSON, | ||
allowNull: true, | ||
}) | ||
tool_resources: AssistantToolResources | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,88 @@ | ||
import { Table, Column, Model, PrimaryKey, DataType } from 'sequelize-typescript'; | ||
import type { | ||
Message, | ||
MessageContent, | ||
MessageIncompleteDetails, | ||
MessageAttachment, | ||
} from '@/domain/models/message.interface'; | ||
import { Column, Entity, PrimaryColumn } from 'typeorm'; | ||
|
||
@Entity('messages') | ||
export class MessageEntity implements Message { | ||
@PrimaryColumn({ type: String }) | ||
@Table({ tableName: 'messages', timestamps: false}) | ||
export class MessageEntity extends Model implements Message { | ||
@PrimaryKey | ||
@Column({ | ||
type: DataType.STRING, | ||
}) | ||
id: string; | ||
|
||
@Column({ type: String }) | ||
@Column({ | ||
type: DataType.STRING, | ||
defaultValue: 'thread.message', | ||
}) | ||
object: 'thread.message'; | ||
|
||
@Column({ type: String }) | ||
@Column({ | ||
type: DataType.STRING, | ||
}) | ||
thread_id: string; | ||
|
||
@Column({ type: String, nullable: true }) | ||
@Column({ | ||
type: DataType.STRING, | ||
allowNull: true, | ||
}) | ||
assistant_id: string | null; | ||
|
||
@Column({ type: String }) | ||
@Column({ | ||
type: DataType.STRING, | ||
}) | ||
role: 'user' | 'assistant'; | ||
|
||
@Column({ type: String }) | ||
@Column({ | ||
type: DataType.STRING, | ||
}) | ||
status: 'in_progress' | 'incomplete' | 'completed'; | ||
|
||
@Column({ type: 'simple-json', nullable: true }) | ||
@Column({ | ||
type: DataType.JSON, | ||
allowNull: true, | ||
}) | ||
metadata: any | null; | ||
|
||
@Column({ type: String, nullable: true }) | ||
@Column({ | ||
type: DataType.STRING, | ||
allowNull: true, | ||
}) | ||
run_id: string | null; | ||
|
||
@Column({ type: Number, nullable: true }) | ||
@Column({ | ||
type: DataType.INTEGER, | ||
allowNull: true, | ||
}) | ||
completed_at: number | null; | ||
|
||
@Column({ type: 'simple-json' }) | ||
@Column({ | ||
type: DataType.JSON, | ||
}) | ||
content: MessageContent[]; | ||
|
||
@Column({ type: 'simple-json', nullable: true }) | ||
@Column({ | ||
type: DataType.JSON, | ||
allowNull: true, | ||
}) | ||
incomplete_details: MessageIncompleteDetails | null; | ||
|
||
@Column({ type: Number }) | ||
@Column({ | ||
type: DataType.INTEGER, | ||
}) | ||
created_at: number; | ||
|
||
@Column({ type: 'simple-json' }) | ||
@Column({ | ||
type: DataType.JSON, | ||
}) | ||
attachments: MessageAttachment[]; | ||
|
||
@Column({ type: Number, nullable: true }) | ||
@Column({ | ||
type: DataType.INTEGER, | ||
allowNull: true, | ||
}) | ||
incomplete_at: number | null; | ||
} |
Oops, something went wrong.