ShawnRu commited on
Commit
132649c
ยท
1 Parent(s): 009d93e
Files changed (2) hide show
  1. app.py +4 -1
  2. src/main.py +16 -4
app.py CHANGED
@@ -1,4 +1,7 @@
 
1
  import subprocess
2
 
3
- # ่ฟ่กŒ src/main.py ๆ–‡ไปถ
 
 
4
  subprocess.run(["python", "src/main.py"])
 
1
+ import nltk
2
  import subprocess
3
 
4
+ nltk.download('punkt')
5
+ nltk.download('punkt_tab')
6
+
7
  subprocess.run(["python", "src/main.py"])
src/main.py CHANGED
@@ -73,8 +73,9 @@ def create_interface():
73
 
74
  with gr.Row():
75
  with gr.Column():
76
- model_gr = gr.Dropdown(choices=["gpt-3.5-turbo", "gpt-4o", "gpt-4o-mini"], label="๐Ÿค– Select your Model")
77
  api_key_gr = gr.Textbox(label="๐Ÿ”‘ Enter your API-Key")
 
78
  with gr.Column():
79
  task_gr = gr.Dropdown(choices=["Base", "NER", "RE", "EE"], label="๐ŸŽฏ Select your Task")
80
  use_file_gr = gr.Checkbox(label="๐Ÿ“‚ Use File", value=True)
@@ -112,10 +113,19 @@ def create_interface():
112
  gr.update(value=example["constraint"], visible=example["task"] in ["NER", "RE", "EE"]),
113
  )
114
 
115
- def submit(model, api_key, task, instruction, constraint, text, use_file, file_path):
116
  try:
117
- # ๅˆ›ๅปบ Pipeline ๅฎžไพ‹
118
- pipeline = Pipeline(ChatGPT(model_name_or_path=model, api_key=api_key))
 
 
 
 
 
 
 
 
 
119
  if task == "Base":
120
  instruction = instruction
121
  constraint = ""
@@ -199,6 +209,7 @@ def create_interface():
199
  inputs=[
200
  model_gr,
201
  api_key_gr,
 
202
  task_gr,
203
  instruction_gr,
204
  constraint_gr,
@@ -214,6 +225,7 @@ def create_interface():
214
  outputs=[
215
  model_gr,
216
  api_key_gr,
 
217
  task_gr,
218
  instruction_gr,
219
  constraint_gr,
 
73
 
74
  with gr.Row():
75
  with gr.Column():
76
+ model_gr = gr.Dropdown(choices=["deepseek-chat", "deepseek-reasoner", "gpt-3.5-turbo", "gpt-4o", "gpt-4o-mini"], label="๐Ÿค– Select your Model")
77
  api_key_gr = gr.Textbox(label="๐Ÿ”‘ Enter your API-Key")
78
+ base_url_gr = gr.Textbox(label="๐Ÿ”— Enter your Base-URL", value="DEFAULT")
79
  with gr.Column():
80
  task_gr = gr.Dropdown(choices=["Base", "NER", "RE", "EE"], label="๐ŸŽฏ Select your Task")
81
  use_file_gr = gr.Checkbox(label="๐Ÿ“‚ Use File", value=True)
 
113
  gr.update(value=example["constraint"], visible=example["task"] in ["NER", "RE", "EE"]),
114
  )
115
 
116
+ def submit(model, api_key, base_url, task, instruction, constraint, text, use_file, file_path):
117
  try:
118
+ if base_url == "DEFAULT":
119
+ if model in ["gpt-3.5-turbo", "gpt-4o", "gpt-4o-mini"]:
120
+ pipeline = Pipeline(ChatGPT(model_name_or_path=model, api_key=api_key))
121
+ elif model in ["deepseek-chat", "deepseek-reasoner"]:
122
+ pipeline = Pipeline(DeepSeek(model_name_or_path=model, api_key=api_key))
123
+ else:
124
+ if model in ["gpt-3.5-turbo", "gpt-4o", "gpt-4o-mini"]:
125
+ pipeline = Pipeline(ChatGPT(model_name_or_path=model, api_key=api_key, base_url=base_url))
126
+ elif model in ["deepseek-chat", "deepseek-reasoner"]:
127
+ pipeline = Pipeline(DeepSeek(model_name_or_path=model, api_key=api_key, base_url=base_url))
128
+
129
  if task == "Base":
130
  instruction = instruction
131
  constraint = ""
 
209
  inputs=[
210
  model_gr,
211
  api_key_gr,
212
+ base_url_gr,
213
  task_gr,
214
  instruction_gr,
215
  constraint_gr,
 
225
  outputs=[
226
  model_gr,
227
  api_key_gr,
228
+ base_url_gr,
229
  task_gr,
230
  instruction_gr,
231
  constraint_gr,