Spaces:
Runtime error
Runtime error
Commit
Β·
ee8e0ef
1
Parent(s):
6aa2bf0
some fixes with finishing
Browse files
gradio_app/interacton_with_swarm.py
CHANGED
@@ -220,4 +220,4 @@ def read_swarm_logs():
|
|
220 |
|
221 |
def execute_swarm(smarm_ui_status):
|
222 |
_ = run_swarm() # when it finishes, it will set SWARM_IS_RUNNING to False
|
223 |
-
|
|
|
220 |
|
221 |
def execute_swarm(smarm_ui_status):
|
222 |
_ = run_swarm() # when it finishes, it will set SWARM_IS_RUNNING to False
|
223 |
+
raise TimeoutError("Swarm timed out. Please try again.")
|
gradio_app/interface.py
CHANGED
@@ -11,6 +11,7 @@ sys.path.append(str(root_dir))
|
|
11 |
from gradio_app.interacton_with_swarm import *
|
12 |
|
13 |
SWARM_IS_RUNNING = False
|
|
|
14 |
|
15 |
def display_logs():
|
16 |
return read_swarm_logs()
|
@@ -19,7 +20,7 @@ def display_output():
|
|
19 |
return read_swarm_output()
|
20 |
|
21 |
def swarm_interface(swarm_role, swarm_global_goal, swarm_goals, n_managers, n_analysts, n_googlers):
|
22 |
-
global SWARM_IS_RUNNING
|
23 |
# please, don't judge me for this hardcoding. it's 3am and it's the first time i use gradio =)))
|
24 |
# Call the necessary set_ functions with the user inputs
|
25 |
set_swarm_role(swarm_role)
|
@@ -32,12 +33,14 @@ def swarm_interface(swarm_role, swarm_global_goal, swarm_goals, n_managers, n_an
|
|
32 |
]
|
33 |
set_swarm_agents_config(agents_config)
|
34 |
|
35 |
-
|
36 |
-
|
37 |
SWARM_IS_RUNNING = True
|
|
|
38 |
print(f"Swarm is running. SWARM_IS_RUNNING = {SWARM_IS_RUNNING}")
|
39 |
|
40 |
def create_gradio_interface():
|
|
|
41 |
title = """
|
42 |
<h1 align="center">ππ Swarm Intelligence ππ</h1>
|
43 |
<div align="center">
|
@@ -100,6 +103,7 @@ def create_gradio_interface():
|
|
100 |
return display_logs(), display_output()
|
101 |
|
102 |
def submit_callback(swarm_role, swarm_global_goal, swarm_goals, n_managers, n_analysts, n_googlers):
|
|
|
103 |
print(f"Swarm is running. SWARM_IS_RUNNING = {SWARM_IS_RUNNING}")
|
104 |
if not SWARM_IS_RUNNING:
|
105 |
swarm_interface(swarm_role, swarm_global_goal, swarm_goals, n_managers, n_analysts, n_googlers)
|
|
|
11 |
from gradio_app.interacton_with_swarm import *
|
12 |
|
13 |
SWARM_IS_RUNNING = False
|
14 |
+
SWARM_THREAD = None
|
15 |
|
16 |
def display_logs():
|
17 |
return read_swarm_logs()
|
|
|
20 |
return read_swarm_output()
|
21 |
|
22 |
def swarm_interface(swarm_role, swarm_global_goal, swarm_goals, n_managers, n_analysts, n_googlers):
|
23 |
+
global SWARM_IS_RUNNING, SWARM_THREAD
|
24 |
# please, don't judge me for this hardcoding. it's 3am and it's the first time i use gradio =)))
|
25 |
# Call the necessary set_ functions with the user inputs
|
26 |
set_swarm_role(swarm_role)
|
|
|
33 |
]
|
34 |
set_swarm_agents_config(agents_config)
|
35 |
|
36 |
+
SWARM_THREAD = threading.Thread(target=execute_swarm, args=(SWARM_IS_RUNNING,))
|
37 |
+
SWARM_THREAD.start()
|
38 |
SWARM_IS_RUNNING = True
|
39 |
+
|
40 |
print(f"Swarm is running. SWARM_IS_RUNNING = {SWARM_IS_RUNNING}")
|
41 |
|
42 |
def create_gradio_interface():
|
43 |
+
global SWARM_IS_RUNNING, SWARM_THREAD
|
44 |
title = """
|
45 |
<h1 align="center">ππ Swarm Intelligence ππ</h1>
|
46 |
<div align="center">
|
|
|
103 |
return display_logs(), display_output()
|
104 |
|
105 |
def submit_callback(swarm_role, swarm_global_goal, swarm_goals, n_managers, n_analysts, n_googlers):
|
106 |
+
SWARM_IS_RUNNING = SWARM_THREAD.is_alive()
|
107 |
print(f"Swarm is running. SWARM_IS_RUNNING = {SWARM_IS_RUNNING}")
|
108 |
if not SWARM_IS_RUNNING:
|
109 |
swarm_interface(swarm_role, swarm_global_goal, swarm_goals, n_managers, n_analysts, n_googlers)
|