Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,19 @@
|
|
1 |
import os
|
|
|
2 |
import random
|
3 |
import gradio as gr
|
4 |
from datetime import datetime
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# ==== Environment Setup ====
|
9 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
10 |
os.environ["MKL_THREADING_LAYER"] = "GNU"
|
11 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
12 |
-
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
13 |
|
14 |
# ==== UI Content ====
|
15 |
DESCRIPTION = '''
|
@@ -78,24 +82,6 @@ if __name__ == "__main__":
|
|
78 |
def handle_chat(message, history, temperature, max_new_tokens, max_tokens, multi_agent, conversation, max_round):
|
79 |
return agent.run_gradio_chat(message, history, temperature, max_new_tokens, max_tokens, multi_agent, conversation, max_round)
|
80 |
|
81 |
-
def update_model_parameters(enable_finish, enable_rag, enable_summary,
|
82 |
-
init_rag_num, step_rag_num, skip_last_k,
|
83 |
-
summary_mode, summary_skip_last_k, summary_context_length,
|
84 |
-
force_finish, seed):
|
85 |
-
return agent.update_parameters(
|
86 |
-
enable_finish=enable_finish,
|
87 |
-
enable_rag=enable_rag,
|
88 |
-
enable_summary=enable_summary,
|
89 |
-
init_rag_num=init_rag_num,
|
90 |
-
step_rag_num=step_rag_num,
|
91 |
-
skip_last_k=skip_last_k,
|
92 |
-
summary_mode=summary_mode,
|
93 |
-
summary_skip_last_k=summary_skip_last_k,
|
94 |
-
summary_context_length=summary_context_length,
|
95 |
-
force_finish=force_finish,
|
96 |
-
seed=seed
|
97 |
-
)
|
98 |
-
|
99 |
def update_seed():
|
100 |
seed = random.randint(0, 10000)
|
101 |
return agent.update_parameters(seed=seed)
|
|
|
1 |
import os
|
2 |
+
import sys
|
3 |
import random
|
4 |
import gradio as gr
|
5 |
from datetime import datetime
|
6 |
|
7 |
+
# Add `src` directory to Python path to import your custom agent
|
8 |
+
sys.path.append(os.path.join(os.path.dirname(__file__), "src"))
|
9 |
+
|
10 |
+
# Import your TxAgent class from src/txagent/TxAgent.py
|
11 |
+
from txagent.TxAgent import TxAgent
|
12 |
|
13 |
# ==== Environment Setup ====
|
14 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
15 |
os.environ["MKL_THREADING_LAYER"] = "GNU"
|
16 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
|
17 |
|
18 |
# ==== UI Content ====
|
19 |
DESCRIPTION = '''
|
|
|
82 |
def handle_chat(message, history, temperature, max_new_tokens, max_tokens, multi_agent, conversation, max_round):
|
83 |
return agent.run_gradio_chat(message, history, temperature, max_new_tokens, max_tokens, multi_agent, conversation, max_round)
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
def update_seed():
|
86 |
seed = random.randint(0, 10000)
|
87 |
return agent.update_parameters(seed=seed)
|