You-shen commited on
Commit
912da6c
·
verified ·
1 Parent(s): 02f340d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -13,7 +13,6 @@ from model import *
13
  from gradio import ChatMessage, on
14
  from tools import *
15
  from prompt import *
16
- from config import *
17
  import sys
18
  from gradio.components.chatbot import MessageDict
19
  from langchain_community.llms import Tongyi
@@ -176,7 +175,7 @@ class FactChecker:
176
  if len(action_input) >= 3:
177
  # agent_thought.append({"title": f"工具调用:{action}", "content": action_input})
178
  web_search_tools = {"BoCha Webs Search","Image Search","Baidu News Search","tavily_search_results_json"}
179
- if action in web_search_tools:
180
  action = "网页搜索"
181
  agent_thought.append(
182
  ChatMessage(
@@ -468,7 +467,7 @@ class History:
468
  def build_interface() -> gr.Blocks:
469
  with gr.Blocks(css=css, theme='soft') as demo:
470
  gr.HTML(
471
- "<h1 style='font-size: 36px; text-align: center; color: #333333; margin-bottom: 20px;'>虚假信息检测系统</h1>")
472
  with gr.Tab(label='Chat'):
473
  with gr.Row():
474
  with gr.Sidebar():
@@ -491,9 +490,9 @@ def build_interface() -> gr.Blocks:
491
  )
492
 
493
  language_select = gr.Dropdown(["中文", "英文"], label="请选择要使用的语言", scale=1, value="中文")
494
- model_select = gr.Dropdown(["自研", "llama3-70b", "llama3-8b", "mistral"],
495
- label="请选择要使用的大模型",
496
- scale=1, value="自研")
497
  # mode_select = gr.Dropdown(["事实核查","谣言检测"],label= "请选择使用的模式",scale= 1, value= "谣言检测")
498
 
499
  with gr.Column(scale=3):
@@ -505,7 +504,7 @@ def build_interface() -> gr.Blocks:
505
  {
506
  "text": "据最新天文研究,火星的轨道将逐渐接近地球,最终成为地球的“第二月亮”。天文学家预测这一变化将在2025年发生,届时火星将在夜空中与月亮一样明亮,影响全球潮汐和生态平衡。"}
507
  ],
508
- chatbot=gr.Chatbot(label='自研系统',
509
  avatar_images=("./image/user.png", "./image/logo.png"),
510
  type="messages",
511
  height=600,
@@ -522,8 +521,8 @@ def build_interface() -> gr.Blocks:
522
  )
523
 
524
  with gr.Column(scale=1):
525
- with gr.Accordion("图片检测", open=False):
526
- img_info = gr.Textbox(label="检测结果", lines=5)
527
  # contrast_model = gr.Textbox(label="对比模型", lines=5)
528
  # with gr.Accordion("展示对比模型prompt", open=False):
529
  # model_prompt = gr.Textbox(label="对比模型prompt", lines=5, placeholder=constract_model_prompt, interactive=True)
@@ -531,10 +530,10 @@ def build_interface() -> gr.Blocks:
531
  # label="请选择使用的对比模型", scale=1, value="qwen")
532
  # contrast_bn = gr.Button("展示对比模型")
533
  # prompt_bn = gr.Button("确定更改提示词")
534
- img_bn = gr.Button("显示检测结果")
535
  img_bn.click(factChecker.update_image_summaries, [], img_info)
536
  language_select.change(factChecker.SelectLanguage, language_select, [])
537
- model_select.change(factChecker.SelectModel, model_select, [])
538
  # mode_select.change(factChecker.SelectMode, mode_select, [])
539
  # contrast_select.change(factChecker.SelectContrast, contrast_select, [])
540
  # contrast_bn.click(factChecker.contract, [], contrast_model)
 
13
  from gradio import ChatMessage, on
14
  from tools import *
15
  from prompt import *
 
16
  import sys
17
  from gradio.components.chatbot import MessageDict
18
  from langchain_community.llms import Tongyi
 
175
  if len(action_input) >= 3:
176
  # agent_thought.append({"title": f"工具调用:{action}", "content": action_input})
177
  web_search_tools = {"BoCha Webs Search","Image Search","Baidu News Search","tavily_search_results_json"}
178
+ if action in web_search_tools or action == "":
179
  action = "网页搜索"
180
  agent_thought.append(
181
  ChatMessage(
 
467
  def build_interface() -> gr.Blocks:
468
  with gr.Blocks(css=css, theme='soft') as demo:
469
  gr.HTML(
470
+ "<h1 style='font-size: 36px; text-align: center; color: #333333; margin-bottom: 20px;'>惊堂木-虚假信息检测系统</h1>")
471
  with gr.Tab(label='Chat'):
472
  with gr.Row():
473
  with gr.Sidebar():
 
490
  )
491
 
492
  language_select = gr.Dropdown(["中文", "英文"], label="请选择要使用的语言", scale=1, value="中文")
493
+ # model_select = gr.Dropdown(["自研", "llama3-70b", "llama3-8b", "mistral"],
494
+ # label="请选择要使用的大模型",
495
+ # scale=1, value="自研")
496
  # mode_select = gr.Dropdown(["事实核查","谣言检测"],label= "请选择使用的模式",scale= 1, value= "谣言检测")
497
 
498
  with gr.Column(scale=3):
 
504
  {
505
  "text": "据最新天文研究,火星的轨道将逐渐接近地球,最终成为地球的“第二月亮”。天文学家预测这一变化将在2025年发生,届时火星将在夜空中与月亮一样明亮,影响全球潮汐和生态平衡。"}
506
  ],
507
+ chatbot=gr.Chatbot(label='惊堂木',
508
  avatar_images=("./image/user.png", "./image/logo.png"),
509
  type="messages",
510
  height=600,
 
521
  )
522
 
523
  with gr.Column(scale=1):
524
+ with gr.Accordion("图片分析", open=False):
525
+ img_info = gr.Textbox(label="分析结果", lines=5)
526
  # contrast_model = gr.Textbox(label="对比模型", lines=5)
527
  # with gr.Accordion("展示对比模型prompt", open=False):
528
  # model_prompt = gr.Textbox(label="对比模型prompt", lines=5, placeholder=constract_model_prompt, interactive=True)
 
530
  # label="请选择使用的对比模型", scale=1, value="qwen")
531
  # contrast_bn = gr.Button("展示对比模型")
532
  # prompt_bn = gr.Button("确定更改提示词")
533
+ img_bn = gr.Button("显示分析结果")
534
  img_bn.click(factChecker.update_image_summaries, [], img_info)
535
  language_select.change(factChecker.SelectLanguage, language_select, [])
536
+ # model_select.change(factChecker.SelectModel, model_select, [])
537
  # mode_select.change(factChecker.SelectMode, mode_select, [])
538
  # contrast_select.change(factChecker.SelectContrast, contrast_select, [])
539
  # contrast_bn.click(factChecker.contract, [], contrast_model)