mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
feat: started openai integration, added models to the database
This commit introduces a new openai integration in the project, along with necessary changes in the database schema. The package.json file has been updated to include the openai package, and the prisma/postgresql-schema.prisma file has been modified to include OpenaiCreds, OpenaiAssistant, OpenaiAssistantThread, and OpenaiChatCompletion models. These models will handle the integration with OpenAI's API for various tasks. Some of the key changes include: - Addition of OpenaiCreds model to manage API credentials. - Addition of OpenaiAssistant model to handle OpenAI assistant instances. - Addition of OpenaiAssistantThread model to manage OpenAI assistant threads. - Addition of OpenaiChatCompletion model to handle OpenAI chat completions. These changes will enable seamless integration with OpenAI's API and allow for better management of assistant instances, threads, and chat completions.
This commit is contained in:
parent
aa2da01401
commit
5b13de377b
@ -80,6 +80,7 @@
|
||||
"node-cache": "^5.1.2",
|
||||
"node-mime-types": "^1.1.0",
|
||||
"node-windows": "^1.0.0-beta.8",
|
||||
"openai": "^4.52.7",
|
||||
"parse-bmfont-xml": "^1.1.4",
|
||||
"pg": "^8.11.3",
|
||||
"pino": "^8.11.0",
|
||||
|
@ -77,6 +77,11 @@ model Instance {
|
||||
TypebotSession TypebotSession[]
|
||||
TypebotSetting TypebotSetting?
|
||||
Media Media[]
|
||||
OpenaiCreds OpenaiCreds?
|
||||
OpenaiAssistant OpenaiAssistant[]
|
||||
OpenaiAssistantThread OpenaiAssistantThread[]
|
||||
OpenaiChatCompletion OpenaiChatCompletion[]
|
||||
OpenaiChatCompletionSession OpenaiChatCompletionSession[]
|
||||
}
|
||||
|
||||
model Session {
|
||||
@ -129,6 +134,10 @@ model Message {
|
||||
MessageUpdate MessageUpdate[]
|
||||
TypebotSession TypebotSession? @relation(fields: [typebotSessionId], references: [id])
|
||||
Media Media?
|
||||
OpenaiAssistantThread OpenaiAssistantThread? @relation(fields: [openaiAssistantThreadId], references: [id])
|
||||
openaiAssistantThreadId String?
|
||||
OpenaiChatCompletionSession OpenaiChatCompletionSession? @relation(fields: [openaiChatCompletionSessionId], references: [id])
|
||||
openaiChatCompletionSessionId String?
|
||||
}
|
||||
|
||||
model MessageUpdate {
|
||||
@ -325,3 +334,89 @@ model Media {
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String
|
||||
}
|
||||
|
||||
model OpenaiCreds {
|
||||
id String @id @default(cuid())
|
||||
apiKey String @unique @db.VarChar(255)
|
||||
createdAt DateTime? @default(now()) @db.Timestamp
|
||||
updatedAt DateTime @updatedAt @db.Timestamp
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String @unique
|
||||
}
|
||||
|
||||
model OpenaiAssistant {
|
||||
id String @id @default(cuid())
|
||||
assistantId String @unique @db.VarChar(255)
|
||||
expire Int? @default(0) @db.Integer
|
||||
keywordFinish String? @db.VarChar(100)
|
||||
delayMessage Int? @db.Integer
|
||||
unknownMessage String? @db.VarChar(100)
|
||||
listeningFromMe Boolean? @default(false) @db.Boolean
|
||||
stopBotFromMe Boolean? @default(false) @db.Boolean
|
||||
keepOpen Boolean? @default(false) @db.Boolean
|
||||
debounceTime Int? @db.Integer
|
||||
ignoreJids Json?
|
||||
triggerType TriggerType?
|
||||
triggerOperator TriggerOperator?
|
||||
triggerValue String?
|
||||
createdAt DateTime? @default(now()) @db.Timestamp
|
||||
updatedAt DateTime @updatedAt @db.Timestamp
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String
|
||||
OpenaiAssistantThread OpenaiAssistantThread[]
|
||||
}
|
||||
|
||||
model OpenaiAssistantThread {
|
||||
id String @id @default(cuid())
|
||||
threadId String @db.VarChar(255)
|
||||
remoteJid String @db.VarChar(100)
|
||||
status TypebotSessionStatus
|
||||
awaitUser Boolean @default(false) @db.Boolean
|
||||
createdAt DateTime? @default(now()) @db.Timestamp
|
||||
updatedAt DateTime @updatedAt @db.Timestamp
|
||||
OpenaiAssistant OpenaiAssistant @relation(fields: [openaiAssistantId], references: [id], onDelete: Cascade)
|
||||
openaiAssistantId String
|
||||
Message Message[]
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String
|
||||
}
|
||||
|
||||
model OpenaiChatCompletion {
|
||||
id String @id @default(cuid())
|
||||
model String @db.VarChar(100)
|
||||
systemMessages Json? @db.JsonB
|
||||
assistantMessages Json? @db.JsonB
|
||||
userMessages Json? @db.JsonB
|
||||
maxTokens Int? @db.Integer
|
||||
expire Int? @default(0) @db.Integer
|
||||
keywordFinish String? @db.VarChar(100)
|
||||
delayMessage Int? @db.Integer
|
||||
unknownMessage String? @db.VarChar(100)
|
||||
listeningFromMe Boolean? @default(false) @db.Boolean
|
||||
stopBotFromMe Boolean? @default(false) @db.Boolean
|
||||
keepOpen Boolean? @default(false) @db.Boolean
|
||||
debounceTime Int? @db.Integer
|
||||
ignoreJids Json?
|
||||
triggerType TriggerType?
|
||||
triggerOperator TriggerOperator?
|
||||
triggerValue String?
|
||||
createdAt DateTime? @default(now()) @db.Timestamp
|
||||
updatedAt DateTime @updatedAt @db.Timestamp
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String
|
||||
OpenaiChatCompletionSession OpenaiChatCompletionSession[]
|
||||
}
|
||||
|
||||
model OpenaiChatCompletionSession {
|
||||
id String @id @default(cuid())
|
||||
remoteJid String @db.VarChar(100)
|
||||
sessionId String @db.VarChar(100)
|
||||
status TypebotSessionStatus
|
||||
createdAt DateTime? @default(now()) @db.Timestamp
|
||||
updatedAt DateTime @updatedAt @db.Timestamp
|
||||
OpenaiChatCompletion OpenaiChatCompletion @relation(fields: [openaiChatCompletionId], references: [id], onDelete: Cascade)
|
||||
openaiChatCompletionId String
|
||||
Message Message[]
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user