youngtsai commited on
Commit
b7a82ac
1 Parent(s): cabf77a
Files changed (1) hide show
  1. app.py +17 -20
app.py CHANGED
@@ -705,7 +705,8 @@ def split_data(df_string, word_base=100000):
705
 
706
  def generate_content_by_open_ai(sys_content, user_content, response_format=None):
707
  print("LLM using OPEN AI")
708
- model = "gpt-4-turbo"
 
709
  messages = [
710
  {"role": "system", "content": sys_content},
711
  {"role": "user", "content": user_content}
@@ -1777,7 +1778,7 @@ def reading_passage_add_latex_version(video_id):
1777
  ]
1778
 
1779
  request_payload = {
1780
- "model": "gpt-4-turbo",
1781
  "messages": messages,
1782
  "max_tokens": 4000,
1783
  }
@@ -1846,7 +1847,7 @@ def summary_add_markdown_version(video_id):
1846
  {"role": "user", "content": user_content}
1847
  ]
1848
  request_payload = {
1849
- "model": "gpt-4-turbo",
1850
  "messages": messages,
1851
  "max_tokens": 4000,
1852
  }
@@ -2206,7 +2207,7 @@ def feedback_with_ai(ai_type, chat_history, thread_id=None):
2206
  client = OPEN_AI_CLIENT
2207
 
2208
  if ai_type == "chat_completions":
2209
- model_name = "gpt-4-turbo"
2210
  response_text = handle_conversation_by_open_ai_chat_completions(client, model_name, user_content, system_content)
2211
  elif ai_type == "assistant":
2212
  assistant_id = OPEN_AI_ASSISTANT_ID_GPT4 #GPT 4 turbo
@@ -2270,7 +2271,7 @@ def handle_conversation_by_open_ai_assistant(client, user_message, instructions,
2270
  except Exception as e:
2271
  if fallback:
2272
  response = client.chat.completions.create(
2273
- model="gpt-4-turbo",
2274
  messages=[
2275
  {"role": "system", "content": instructions},
2276
  {"role": "user", "content": user_message}
@@ -2376,7 +2377,7 @@ def process_open_ai_audio_to_chatbot(password, audio_url):
2376
  也不要給出多餘的敘述
2377
  """
2378
  request = OPEN_AI_CLIENT.chat.completions.create(
2379
- model="gpt-4-turbo",
2380
  messages=[
2381
  {"role": "system", "content": system_message},
2382
  {"role": "user", "content": user_message}
@@ -2677,20 +2678,13 @@ HEAD = """
2677
 
2678
  with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, secondary_hue=gr.themes.colors.amber, text_size = gr.themes.sizes.text_lg), head=HEAD) as demo:
2679
  with gr.Row() as admin:
2680
- with gr.Column(scale=4):
2681
- with gr.Row():
2682
- password = gr.Textbox(label="Password", type="password", elem_id="password_input", visible=True)
2683
- youtube_link = gr.Textbox(label="Enter YouTube Link", elem_id="youtube_link_input", visible=True)
2684
- video_id = gr.Textbox(label="video_id", visible=True)
2685
- # file_upload = gr.File(label="Upload your CSV or Word file", visible=False)
2686
- # web_link = gr.Textbox(label="Enter Web Page Link", visible=False)
2687
- user_data = gr.Textbox(label="User Data", elem_id="user_data_input", visible=True)
2688
- with gr.Row():
2689
- is_env_prod = gr.Checkbox(value=False, label="is_env_prod")
2690
- LLM_model = gr.Dropdown(label="LLM Model", choices=["open-ai-gpt-4", "anthropic-claude-3-sonnet"], value="open-ai-gpt-4", visible=True, interactive=True)
2691
- with gr.Column(scale=1):
2692
- with gr.Row():
2693
- youtube_link_btn = gr.Button("Submit_YouTube_Link", elem_id="youtube_link_btn", visible=True)
2694
  with gr.Row() as data_state:
2695
  content_subject_state = gr.State() # 使用 gr.State 存储 content_subject
2696
  content_grade_state = gr.State() # 使用 gr.State 存储 content_grade
@@ -2944,6 +2938,9 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
2944
  # metacognition_content_btn = gr.Button("生成後設認知問題")
2945
 
2946
  with gr.Accordion("See Details", open=False) as see_details:
 
 
 
2947
  with gr.Tab("逐字稿本文"):
2948
  with gr.Row() as transcript_admmin:
2949
  transcript_kind = gr.Textbox(value="transcript", show_label=False)
 
705
 
706
  def generate_content_by_open_ai(sys_content, user_content, response_format=None):
707
  print("LLM using OPEN AI")
708
+ # model = "gpt-4-turbo"
709
+ model = "gpt-4o"
710
  messages = [
711
  {"role": "system", "content": sys_content},
712
  {"role": "user", "content": user_content}
 
1778
  ]
1779
 
1780
  request_payload = {
1781
+ "model": "gpt-4o",
1782
  "messages": messages,
1783
  "max_tokens": 4000,
1784
  }
 
1847
  {"role": "user", "content": user_content}
1848
  ]
1849
  request_payload = {
1850
+ "model": "gpt-4o",
1851
  "messages": messages,
1852
  "max_tokens": 4000,
1853
  }
 
2207
  client = OPEN_AI_CLIENT
2208
 
2209
  if ai_type == "chat_completions":
2210
+ model_name = "gpt-4o"
2211
  response_text = handle_conversation_by_open_ai_chat_completions(client, model_name, user_content, system_content)
2212
  elif ai_type == "assistant":
2213
  assistant_id = OPEN_AI_ASSISTANT_ID_GPT4 #GPT 4 turbo
 
2271
  except Exception as e:
2272
  if fallback:
2273
  response = client.chat.completions.create(
2274
+ model="gpt-4o",
2275
  messages=[
2276
  {"role": "system", "content": instructions},
2277
  {"role": "user", "content": user_message}
 
2377
  也不要給出多餘的敘述
2378
  """
2379
  request = OPEN_AI_CLIENT.chat.completions.create(
2380
+ model="gpt-4o",
2381
  messages=[
2382
  {"role": "system", "content": system_message},
2383
  {"role": "user", "content": user_message}
 
2678
 
2679
  with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, secondary_hue=gr.themes.colors.amber, text_size = gr.themes.sizes.text_lg), head=HEAD) as demo:
2680
  with gr.Row() as admin:
2681
+ password = gr.Textbox(label="Password", type="password", elem_id="password_input", visible=True)
2682
+ youtube_link = gr.Textbox(label="Enter YouTube Link", elem_id="youtube_link_input", visible=True)
2683
+ video_id = gr.Textbox(label="video_id", visible=True)
2684
+ # file_upload = gr.File(label="Upload your CSV or Word file", visible=False)
2685
+ # web_link = gr.Textbox(label="Enter Web Page Link", visible=False)
2686
+ user_data = gr.Textbox(label="User Data", elem_id="user_data_input", visible=True)
2687
+ youtube_link_btn = gr.Button("Submit_YouTube_Link", elem_id="youtube_link_btn", visible=True)
 
 
 
 
 
 
 
2688
  with gr.Row() as data_state:
2689
  content_subject_state = gr.State() # 使用 gr.State 存储 content_subject
2690
  content_grade_state = gr.State() # 使用 gr.State 存储 content_grade
 
2938
  # metacognition_content_btn = gr.Button("生成後設認知問題")
2939
 
2940
  with gr.Accordion("See Details", open=False) as see_details:
2941
+ with gr.Row():
2942
+ is_env_prod = gr.Checkbox(value=False, label="is_env_prod")
2943
+ LLM_model = gr.Dropdown(label="LLM Model", choices=["open-ai-gpt-4", "anthropic-claude-3-sonnet"], value="open-ai-gpt-4", visible=True, interactive=True)
2944
  with gr.Tab("逐字稿本文"):
2945
  with gr.Row() as transcript_admmin:
2946
  transcript_kind = gr.Textbox(value="transcript", show_label=False)