ShawnRu commited on
Commit
2a03b34
Β·
1 Parent(s): efd51ba
Files changed (3) hide show
  1. .gitignore +1 -0
  2. src/pipeline.py +1 -1
  3. src/webui.py +37 -17
.gitignore CHANGED
@@ -2,6 +2,7 @@ local
2
  local-new
3
  data
4
  examples
 
5
  README_CN.md
6
  **/__pycache__
7
  *.pyc
 
2
  local-new
3
  data
4
  examples
5
+ figs
6
  README_CN.md
7
  **/__pycache__
8
  *.pyc
src/pipeline.py CHANGED
@@ -75,7 +75,7 @@ class Pipeline:
75
 
76
  if isgui and mode == "customized":
77
  process_method = three_agents
78
- # print("Customized Agents: ", three_agents)
79
 
80
  sorted_process_method = self.__init_method(data, process_method)
81
  print("Process Method: ", sorted_process_method)
 
75
 
76
  if isgui and mode == "customized":
77
  process_method = three_agents
78
+ print("Customized 3-Agents: ", three_agents)
79
 
80
  sorted_process_method = self.__init_method(data, process_method)
81
  print("Process Method: ", sorted_process_method)
src/webui.py CHANGED
@@ -61,7 +61,7 @@ examples = [
61
 
62
 
63
  def create_interface():
64
- with gr.Blocks(title="OneKE Demo") as demo:
65
  gr.HTML("""
66
  <div style="text-align:center;">
67
  <p align="center">
@@ -83,15 +83,33 @@ def create_interface():
83
 
84
  with gr.Row():
85
  with gr.Column():
86
- model_gr = gr.Dropdown(choices=["deepseek-chat", "deepseek-reasoner", "gpt-3.5-turbo", "gpt-4o", "gpt-4o-mini"], label="πŸͺ„ Select your Model")
87
- api_key_gr = gr.Textbox(label="πŸ”‘ Enter your API-Key")
88
- base_url_gr = gr.Textbox(label="πŸ”— Enter your Base-URL", value="DEFAULT")
 
 
 
 
 
 
 
 
 
 
89
  with gr.Column():
90
- task_gr = gr.Dropdown(choices=["Base", "NER", "RE", "EE"], label="🎯 Select your Task")
91
- mode_gr = gr.Dropdown(choices=["quick", "standard", "customized"], label="🧭 Select your Mode")
92
- schema_agent_gr = gr.Dropdown(choices=["NOT REQUIRED", "get_default_schema", "get_retrieved_schema", "get_deduced_schema"], label="πŸ€– Select your Schema-Agent", visible=False)
93
- extraction_Agent_gr = gr.Dropdown(choices=["NOT REQUIRED", "extract_information_direct", "extract_information_with_case"], label="πŸ€– Select your Extraction-Agent", visible=False)
94
- reflection_agent_gr = gr.Dropdown(choices=["NOT REQUIRED", "reflect_with_case"], label="πŸ€– Select your Reflection-Agent", visible=False)
 
 
 
 
 
 
 
 
95
 
96
  with gr.Row():
97
  use_file_gr = gr.Checkbox(label="πŸ“‚ Use File", value=True)
@@ -105,9 +123,11 @@ def create_interface():
105
  def customized_mode(mode):
106
  if mode == "customized":
107
  return gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
 
 
108
 
109
  def update_fields(task):
110
- if task == "Base":
111
  return gr.update(visible=True, label="πŸ•ΉοΈ Instruction", placeholder="Enter your Instruction"), gr.update(visible=False)
112
  elif task == "NER":
113
  return gr.update(visible=False), gr.update(visible=True, label="πŸ•ΉοΈ Constraint", placeholder="Enter your NER Constraint")
@@ -141,7 +161,7 @@ def create_interface():
141
 
142
  def submit(model, api_key, base_url, task, mode, instruction, constraint, text, use_file, file_path, update_case, schema_agent, extraction_Agent, reflection_agent):
143
  try:
144
- if base_url == "DEFAULT":
145
  if model in ["gpt-3.5-turbo", "gpt-4o", "gpt-4o-mini"]:
146
  pipeline = Pipeline(ChatGPT(model_name_or_path=model, api_key=api_key))
147
  elif model in ["deepseek-chat", "deepseek-reasoner"]:
@@ -201,9 +221,9 @@ def create_interface():
201
 
202
  def clear_all():
203
  return (
204
- gr.update(value="", visible=False), # sechema_agent
205
- gr.update(value="", visible=False), # extraction_Agent
206
- gr.update(value="", visible=False), # reflection_agent
207
  gr.update(value=""), # task
208
  gr.update(value=""), # mode
209
  gr.update(value="", visible=False), # instruction
@@ -298,6 +318,6 @@ def create_interface():
298
 
299
  return demo
300
 
301
-
302
- interface = create_interface()
303
- interface.launch()
 
61
 
62
 
63
  def create_interface():
64
+ with gr.Blocks(title="OneKE Demo", theme=gr.themes.Soft(text_size="lg")) as demo:
65
  gr.HTML("""
66
  <div style="text-align:center;">
67
  <p align="center">
 
83
 
84
  with gr.Row():
85
  with gr.Column():
86
+ model_gr = gr.Dropdown(
87
+ label="πŸͺ„ Select your Model",
88
+ choices=["deepseek-chat", "deepseek-reasoner", "gpt-3.5-turbo", "gpt-4o", "gpt-4o-mini"],
89
+ value="deepseek-chat",
90
+ )
91
+ api_key_gr = gr.Textbox(
92
+ label="πŸ”‘ Enter your API-Key",
93
+ value="sk-...",
94
+ )
95
+ base_url_gr = gr.Textbox(
96
+ label="πŸ”— Enter your Base-URL",
97
+ value="DEFAULT",
98
+ )
99
  with gr.Column():
100
+ task_gr = gr.Dropdown(
101
+ label="🎯 Select your Task",
102
+ choices=["Base", "NER", "RE", "EE"],
103
+ value="Base",
104
+ )
105
+ mode_gr = gr.Dropdown(
106
+ label="🧭 Select your Mode",
107
+ choices=["quick", "standard", "customized"],
108
+ value="quick",
109
+ )
110
+ schema_agent_gr = gr.Dropdown(choices=["NOT REQUIRED", "get_default_schema", "get_retrieved_schema", "get_deduced_schema"], value="NOT REQUIRED", label="πŸ€– Select your Schema-Agent", visible=False)
111
+ extraction_Agent_gr = gr.Dropdown(choices=["NOT REQUIRED", "extract_information_direct", "extract_information_with_case"], value="NOT REQUIRED", label="πŸ€– Select your Extraction-Agent", visible=False)
112
+ reflection_agent_gr = gr.Dropdown(choices=["NOT REQUIRED", "reflect_with_case"], value="NOT REQUIRED", label="πŸ€– Select your Reflection-Agent", visible=False)
113
 
114
  with gr.Row():
115
  use_file_gr = gr.Checkbox(label="πŸ“‚ Use File", value=True)
 
123
  def customized_mode(mode):
124
  if mode == "customized":
125
  return gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
126
+ else:
127
+ return gr.update(visible=False, value="NOT REQUIRED"), gr.update(visible=False, value="NOT REQUIRED"), gr.update(visible=False, value="NOT REQUIRED")
128
 
129
  def update_fields(task):
130
+ if task == "Base" or task == "":
131
  return gr.update(visible=True, label="πŸ•ΉοΈ Instruction", placeholder="Enter your Instruction"), gr.update(visible=False)
132
  elif task == "NER":
133
  return gr.update(visible=False), gr.update(visible=True, label="πŸ•ΉοΈ Constraint", placeholder="Enter your NER Constraint")
 
161
 
162
  def submit(model, api_key, base_url, task, mode, instruction, constraint, text, use_file, file_path, update_case, schema_agent, extraction_Agent, reflection_agent):
163
  try:
164
+ if base_url == "DEFAULT" or base_url == "":
165
  if model in ["gpt-3.5-turbo", "gpt-4o", "gpt-4o-mini"]:
166
  pipeline = Pipeline(ChatGPT(model_name_or_path=model, api_key=api_key))
167
  elif model in ["deepseek-chat", "deepseek-reasoner"]:
 
221
 
222
  def clear_all():
223
  return (
224
+ gr.update(value="NOT REQUIRED", visible=False), # sechema_agent
225
+ gr.update(value="NOT REQUIRED", visible=False), # extraction_Agent
226
+ gr.update(value="NOT REQUIRED", visible=False), # reflection_agent
227
  gr.update(value=""), # task
228
  gr.update(value=""), # mode
229
  gr.update(value="", visible=False), # instruction
 
318
 
319
  return demo
320
 
321
+ if __name__ == "__main__":
322
+ interface = create_interface()
323
+ interface.launch()