mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
feat: Open AI assistants implemented
This commit is contained in:
parent
29b9e688a8
commit
51749e8712
@ -1,5 +1,9 @@
|
||||
# 2.0.2-beta (beta)
|
||||
|
||||
### Feature
|
||||
|
||||
* Open AI assistants implemented
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed the function of saving or not saving data in the database
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -56,8 +56,8 @@ export const openaiCredsSchema: JSONSchema7 = {
|
||||
properties: {
|
||||
apiKey: { type: 'string' },
|
||||
},
|
||||
required: ['enabled', 'apiKey'],
|
||||
...isNotEmpty('enabled', 'apiKey'),
|
||||
required: ['apiKey'],
|
||||
...isNotEmpty('apiKey'),
|
||||
};
|
||||
|
||||
export const openaiStatusSchema: JSONSchema7 = {
|
||||
|
@ -6,6 +6,7 @@ import { authGuard } from '../guards/auth.guard';
|
||||
import { instanceExistsGuard, instanceLoggedGuard } from '../guards/instance.guard';
|
||||
import Telemetry from '../guards/telemetry.guard';
|
||||
import { ChatwootRouter } from '../integrations/chatwoot/routes/chatwoot.router';
|
||||
import { OpenaiRouter } from '../integrations/openai/routes/openai.router';
|
||||
import { RabbitmqRouter } from '../integrations/rabbitmq/routes/rabbitmq.router';
|
||||
import { S3Router } from '../integrations/s3/routes/s3.router';
|
||||
import { SqsRouter } from '../integrations/sqs/routes/sqs.router';
|
||||
@ -70,6 +71,7 @@ router
|
||||
.use('/proxy', new ProxyRouter(...guards).router)
|
||||
.use('/label', new LabelRouter(...guards).router)
|
||||
.use('/s3', new S3Router(...guards).router)
|
||||
.use('/openai', new OpenaiRouter(...guards).router)
|
||||
.get('/webhook/meta', async (req, res) => {
|
||||
if (req.query['hub.verify_token'] === configService.get<WaBusiness>('WA_BUSINESS').TOKEN_WEBHOOK)
|
||||
res.send(req.query['hub.challenge']);
|
||||
|
@ -26,6 +26,7 @@ import { SettingsDto } from '../dto/settings.dto';
|
||||
import { WebhookDto } from '../dto/webhook.dto';
|
||||
import { ChatwootDto } from '../integrations/chatwoot/dto/chatwoot.dto';
|
||||
import { ChatwootService } from '../integrations/chatwoot/services/chatwoot.service';
|
||||
import { OpenaiService } from '../integrations/openai/services/openai.service';
|
||||
import { RabbitmqDto } from '../integrations/rabbitmq/dto/rabbitmq.dto';
|
||||
import { getAMQP, removeQueues } from '../integrations/rabbitmq/libs/amqp.server';
|
||||
import { SqsDto } from '../integrations/sqs/dto/sqs.dto';
|
||||
@ -68,6 +69,8 @@ export class ChannelStartupService {
|
||||
|
||||
public typebotService = new TypebotService(waMonitor, this.configService, this.prismaRepository);
|
||||
|
||||
public openaiService = new OpenaiService(waMonitor, this.configService, this.prismaRepository);
|
||||
|
||||
public setInstance(instance: InstanceDto) {
|
||||
this.logger.setInstance(instance.instanceName);
|
||||
|
||||
|
@ -69,6 +69,7 @@ import {
|
||||
ConfigSessionPhone,
|
||||
Database,
|
||||
Log,
|
||||
Openai,
|
||||
ProviderSession,
|
||||
QrCode,
|
||||
S3,
|
||||
@ -1164,6 +1165,17 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.configService.get<Openai>('OPENAI').ENABLED) {
|
||||
if (type === 'notify') {
|
||||
if (messageRaw.messageType !== 'reactionMessage')
|
||||
await this.openaiService.sendOpenai(
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
messageRaw.key.remoteJid,
|
||||
messageRaw,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const contact = await this.prismaRepository.contact.findFirst({
|
||||
where: { remoteJid: received.key.remoteJid, instanceId: this.instanceId },
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user