-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbase.ts
More file actions
125 lines (118 loc) · 3.59 KB
/
Copy pathbase.ts
File metadata and controls
125 lines (118 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import { GestorArquivos } from "./arquivos.ts";
import { ControladorFluxo } from "./fluxo.ts";
import { InfosConta, InfosRobo, InfosUser } from "./infosUser.ts";
import {
ChatWootInterface,
ControladorInterface,
LivechatInterface,
TelegramInterface,
WhatsappInterface,
} from "./interfaces.ts";
import { GPT } from "./llm.ts";
import { Logger } from "./logger.ts";
import { Conversa } from "./mensagens.ts";
import { PromptNode } from "./prompt.ts";
import { SchedulerMetodos } from "./scheduler.ts";
import { VarsUser } from "./varsUser.ts";
import { FollowUp } from "./follow_up.ts";
import { CRM } from "./crm.ts";
import { PortalAPI } from "./portalApi.ts";
import { MicroAppUtils } from "./utils.ts";
import { MicroappManager } from "./microapp_manager.ts";
export class MicroApp {
llm: GPT;
vars: VarsUser;
infosUser: InfosUser;
infosRobo: InfosRobo;
infosConta: InfosConta;
logger: Logger;
fluxo: ControladorFluxo;
prompt: PromptNode;
gestor_arquivos: GestorArquivos;
conversa: Conversa;
interface_livechat: LivechatInterface;
interface_whatsapp: WhatsappInterface;
interface_chatwoot: ChatWootInterface;
interface_telegram: TelegramInterface;
controlador_interface: ControladorInterface;
metodosagendados: SchedulerMetodos;
fup: FollowUp;
crm: CRM;
portalApi: PortalAPI;
utils: MicroAppUtils;
microapp_manager: MicroappManager;
static __version__ = [0, 35, 0];
static __pipeline__: Record<string, Record<string, any>> = {
preprocessing: {},
ai_function: {},
moderator: {},
postprocessing: {},
exposed: {},
api: {},
};
static __calls__: {
context_id: number;
reject: any;
resolve: any;
}[] = [];
static __bridge__ = {
call: function (params: object) {},
receive: function (
params: {
error_message: string;
type: string;
context_id: number;
value: any;
message?: string;
},
): any {
for (const call of MicroApp.__calls__) {
if (call.context_id !== params.context_id) {
continue;
}
if (params.type === "execution_result") {
if (params.error_message) {
call.reject(params.error_message);
} else {
// TODO: tratar tambem casos como array de objetos
const className = params.value?.__meta__?.name;
if (!className) {
call.resolve(params.value);
return;
}
try {
const obj = eval(`new ${className}()`);
Object.assign(obj, params.value);
call.resolve(obj);
} catch (_err) {
call.resolve(params.value);
}
}
}
}
},
};
constructor() {
this.llm = new GPT();
this.vars = new VarsUser();
this.logger = new Logger();
this.fluxo = new ControladorFluxo();
this.infosUser = new InfosUser();
this.infosRobo = new InfosRobo();
this.infosConta = new InfosConta();
this.prompt = new PromptNode("Mock Root");
this.gestor_arquivos = new GestorArquivos();
this.conversa = new Conversa();
this.interface_livechat = new LivechatInterface();
this.interface_whatsapp = new WhatsappInterface();
this.interface_chatwoot = new ChatWootInterface();
this.interface_telegram = new TelegramInterface();
this.controlador_interface = new ControladorInterface();
this.metodosagendados = new SchedulerMetodos();
this.fup = new FollowUp();
this.crm = new CRM();
this.portalApi = new PortalAPI();
this.utils = new MicroAppUtils();
this.microapp_manager = new MicroappManager();
}
}