-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrest_functions.py
More file actions
89 lines (64 loc) · 2.16 KB
/
rest_functions.py
File metadata and controls
89 lines (64 loc) · 2.16 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
import Indicators.get_data
from functions import input_history
from AIs.gemini_chatbot import GeminiAI
from AIs.gemini_search_folders import SearchFoldersAI
from AIs.gemini_secretary_prompt import SecretaryAI
import json
user_ias = {}
def process_message_function(request):
message = request.form.get('message')
if not message:
return "Mensagem inválida", 400
username = request.form.get('username')
if 'SITE' in username:
username = request.remote_addr
if username not in user_ias:
user_ias[username] = GeminiAI()
response = user_ias[username].send_message(message)
try:
input_history(username, message, response)
except Exception as e:
print(str(e))
return response
def quit_system_function(request):
username = request.form.get('username')
if 'SITE' in username:
username = request.remote_addr
try:
del user_ias[username]
return f'Usuário {username} deletado com sucesso!'
except KeyError:
return 'Usuário inexistente'
except Exception as e:
print(str(e))
return 'Ocorreu um erro ao deletar o usuário.'
def search_file_function(request):
message = request.form.get('message')
if not message:
return "Mensagem inválida", 400
search = SearchFoldersAI()
return search.send_message(message)
def search_secretary_procedure_function(request):
path = request.form.get('path')
filename = request.form.get('filename')
if not filename:
return "Nome de arquivo inválido", 400
search = SecretaryAI()
return search.send_message(path, filename)
def get_json_file(filename: str):
try:
return json.load(open(filename, "r", encoding="utf-8"))
except Exception as e:
print(str(e))
return []
def update():
try:
Indicators.get_data.atualizar_stocks()
Indicators.get_data.atualizar_atendimento_ov()
Indicators.get_data.atualizar_efficiency()
Indicators.get_data.mesclar_dados()
Indicators.get_data.resumir_info()
return 'Sucesso'
except Exception as e:
return f'Ocorreu o erro: {str(e)} ao atualizar!'
update()