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-cache": "^5.1.2",
|
||||||
"node-mime-types": "^1.1.0",
|
"node-mime-types": "^1.1.0",
|
||||||
"node-windows": "^1.0.0-beta.8",
|
"node-windows": "^1.0.0-beta.8",
|
||||||
|
"openai": "^4.52.7",
|
||||||
"parse-bmfont-xml": "^1.1.4",
|
"parse-bmfont-xml": "^1.1.4",
|
||||||
"pg": "^8.11.3",
|
"pg": "^8.11.3",
|
||||||
"pino": "^8.11.0",
|
"pino": "^8.11.0",
|
||||||
|
@ -47,36 +47,41 @@ enum TriggerOperator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Instance {
|
model Instance {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
name String @unique @db.VarChar(255)
|
name String @unique @db.VarChar(255)
|
||||||
connectionStatus InstanceConnectionStatus @default(open)
|
connectionStatus InstanceConnectionStatus @default(open)
|
||||||
ownerJid String? @db.VarChar(100)
|
ownerJid String? @db.VarChar(100)
|
||||||
profileName String? @db.VarChar(100)
|
profileName String? @db.VarChar(100)
|
||||||
profilePicUrl String? @db.VarChar(500)
|
profilePicUrl String? @db.VarChar(500)
|
||||||
integration String? @db.VarChar(100)
|
integration String? @db.VarChar(100)
|
||||||
number String? @db.VarChar(100)
|
number String? @db.VarChar(100)
|
||||||
businessId String? @db.VarChar(100)
|
businessId String? @db.VarChar(100)
|
||||||
token String? @unique @db.VarChar(255)
|
token String? @unique @db.VarChar(255)
|
||||||
clientName String? @db.VarChar(100)
|
clientName String? @db.VarChar(100)
|
||||||
createdAt DateTime? @default(now()) @db.Timestamp
|
createdAt DateTime? @default(now()) @db.Timestamp
|
||||||
updatedAt DateTime? @updatedAt @db.Timestamp
|
updatedAt DateTime? @updatedAt @db.Timestamp
|
||||||
Chat Chat[]
|
Chat Chat[]
|
||||||
Contact Contact[]
|
Contact Contact[]
|
||||||
Message Message[]
|
Message Message[]
|
||||||
Webhook Webhook?
|
Webhook Webhook?
|
||||||
Chatwoot Chatwoot?
|
Chatwoot Chatwoot?
|
||||||
Label Label[]
|
Label Label[]
|
||||||
Proxy Proxy?
|
Proxy Proxy?
|
||||||
Setting Setting?
|
Setting Setting?
|
||||||
Rabbitmq Rabbitmq?
|
Rabbitmq Rabbitmq?
|
||||||
Sqs Sqs?
|
Sqs Sqs?
|
||||||
Websocket Websocket?
|
Websocket Websocket?
|
||||||
Typebot Typebot[]
|
Typebot Typebot[]
|
||||||
Session Session?
|
Session Session?
|
||||||
MessageUpdate MessageUpdate[]
|
MessageUpdate MessageUpdate[]
|
||||||
TypebotSession TypebotSession[]
|
TypebotSession TypebotSession[]
|
||||||
TypebotSetting TypebotSetting?
|
TypebotSetting TypebotSetting?
|
||||||
Media Media[]
|
Media Media[]
|
||||||
|
OpenaiCreds OpenaiCreds?
|
||||||
|
OpenaiAssistant OpenaiAssistant[]
|
||||||
|
OpenaiAssistantThread OpenaiAssistantThread[]
|
||||||
|
OpenaiChatCompletion OpenaiChatCompletion[]
|
||||||
|
OpenaiChatCompletionSession OpenaiChatCompletionSession[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model Session {
|
model Session {
|
||||||
@ -109,26 +114,30 @@ model Contact {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Message {
|
model Message {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
key Json @db.JsonB
|
key Json @db.JsonB
|
||||||
pushName String? @db.VarChar(100)
|
pushName String? @db.VarChar(100)
|
||||||
participant String? @db.VarChar(100)
|
participant String? @db.VarChar(100)
|
||||||
messageType String @db.VarChar(100)
|
messageType String @db.VarChar(100)
|
||||||
message Json @db.JsonB
|
message Json @db.JsonB
|
||||||
contextInfo Json? @db.JsonB
|
contextInfo Json? @db.JsonB
|
||||||
source DeviceMessage
|
source DeviceMessage
|
||||||
messageTimestamp Int @db.Integer
|
messageTimestamp Int @db.Integer
|
||||||
chatwootMessageId Int? @db.Integer
|
chatwootMessageId Int? @db.Integer
|
||||||
chatwootInboxId Int? @db.Integer
|
chatwootInboxId Int? @db.Integer
|
||||||
chatwootConversationId Int? @db.Integer
|
chatwootConversationId Int? @db.Integer
|
||||||
chatwootContactInboxSourceId String? @db.VarChar(100)
|
chatwootContactInboxSourceId String? @db.VarChar(100)
|
||||||
chatwootIsRead Boolean? @db.Boolean
|
chatwootIsRead Boolean? @db.Boolean
|
||||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||||
instanceId String
|
instanceId String
|
||||||
typebotSessionId String?
|
typebotSessionId String?
|
||||||
MessageUpdate MessageUpdate[]
|
MessageUpdate MessageUpdate[]
|
||||||
TypebotSession TypebotSession? @relation(fields: [typebotSessionId], references: [id])
|
TypebotSession TypebotSession? @relation(fields: [typebotSessionId], references: [id])
|
||||||
Media Media?
|
Media Media?
|
||||||
|
OpenaiAssistantThread OpenaiAssistantThread? @relation(fields: [openaiAssistantThreadId], references: [id])
|
||||||
|
openaiAssistantThreadId String?
|
||||||
|
OpenaiChatCompletionSession OpenaiChatCompletionSession? @relation(fields: [openaiChatCompletionSessionId], references: [id])
|
||||||
|
openaiChatCompletionSessionId String?
|
||||||
}
|
}
|
||||||
|
|
||||||
model MessageUpdate {
|
model MessageUpdate {
|
||||||
@ -325,3 +334,89 @@ model Media {
|
|||||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||||
instanceId String
|
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