Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,7 @@ from qa_txt import llm
|
|
12 |
# from trans import trans
|
13 |
import pathlib
|
14 |
import gradio as gr
|
|
|
15 |
from langchain.agents import (
|
16 |
create_react_agent,
|
17 |
AgentExecutor,
|
@@ -19,6 +20,8 @@ from langchain.agents import (
|
|
19 |
)
|
20 |
from langchain import hub
|
21 |
|
|
|
|
|
22 |
|
23 |
file_text = pathlib.Path('intents_v2.txt').read_text()
|
24 |
|
@@ -130,4 +133,15 @@ def data_gov_ma(message, history):
|
|
130 |
except ValueError as e:
|
131 |
return "Je suis désolé, je n'ai pas compris votre question.Pourriez-vous la reformuler s'il vous plaît ?"
|
132 |
|
133 |
-
gr.ChatInterface(data_gov_ma).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
# from trans import trans
|
13 |
import pathlib
|
14 |
import gradio as gr
|
15 |
+
import threading, time
|
16 |
from langchain.agents import (
|
17 |
create_react_agent,
|
18 |
AgentExecutor,
|
|
|
20 |
)
|
21 |
from langchain import hub
|
22 |
|
23 |
+
from gradio_client import Client
|
24 |
+
|
25 |
|
26 |
file_text = pathlib.Path('intents_v2.txt').read_text()
|
27 |
|
|
|
133 |
except ValueError as e:
|
134 |
return "Je suis désolé, je n'ai pas compris votre question.Pourriez-vous la reformuler s'il vous plaît ?"
|
135 |
|
136 |
+
gr.ChatInterface(data_gov_ma).launch()
|
137 |
+
|
138 |
+
|
139 |
+
|
140 |
+
def keep_alive():
|
141 |
+
while True:
|
142 |
+
gr.ChatInterface(data_gov_ma).launch()
|
143 |
+
time.sleep(60*60*24) # Pause for 24 hours
|
144 |
+
|
145 |
+
# Créer et lancer le thread
|
146 |
+
thread = threading.Thread(target=keep_alive)
|
147 |
+
thread.start()
|