orrinin commited on
Commit
4eb29a5
·
verified ·
1 Parent(s): db4530e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -24,10 +24,10 @@ SYS_PROMPT = read('system_prompt.txt')
24
 
25
  DESCRIPTION = '''
26
  <div>
27
- <h1 style="text-align: center;">家庭医生demo</h1>
28
- <p>🩺一个帮助您分析症状和检验报告的家庭医生(AI诊疗助手)。</p>
29
- <p>🔎 选择您需要咨询的科室医生,在输入框中输入症状描述或者体检信息等;您也可以在图片框中上传检测报告图。</p>
30
- <p>🦕 请注意生成信息可能不准确,且不具备任何实际参考价值,如有需要请联系专业医生。</p>
31
  </div>
32
  '''
33
 
@@ -59,15 +59,15 @@ def process_text(text_input, unit):
59
  completion = client.chat.completions.create(
60
  model=MODEL,
61
  messages=[
62
- {"role": "system", "content": f" You are a experienced {unit} doctor AI assistant." + SYS_PROMPT},
63
- {"role": "user", "content": f"Hello! Could you solve {text_input}?"}
64
  ]
65
  )
66
  return completion.choices[0].message.content
67
  elif text_input and endpoint == 'GOOGLE':
68
  genai.configure(api_key=api_key)
69
  model = genai.GenerativeModel(model_name=MODEL)
70
- prompt = f" You are a experienced {unit} doctor AI assistant." + SYS_PROMPT + f"Could you solve {text_input}?"
71
  response = model.generate_content(prompt)
72
  return response.text
73
  return ""
@@ -88,7 +88,7 @@ def process_image(image_input, unit):
88
  response = client.chat.completions.create(
89
  model=MODEL,
90
  messages=[
91
- {"role": "system", "content": f" You are a experienced {unit} doctor AI assistant." + SYS_PROMPT},
92
  {"role": "user", "content": [
93
  {"type": "text", "text": "Help me understand what is in this picture and analysis."},
94
  {"type": "image_url",
@@ -105,7 +105,7 @@ def process_image(image_input, unit):
105
  elif image_input is not None and endpoint == 'GOOGLE':
106
  genai.configure(api_key=api_key)
107
  model = genai.GenerativeModel(model_name=MODEL)
108
- prompt = f" You are a experienced {unit} doctor AI assistant." + SYS_PROMPT + "Help me understand what is in this picture and analysis."
109
  response = model.generate_content([prompt, image_input],request_options={"timeout": 60})
110
  return response.text
111
 
@@ -116,14 +116,12 @@ def main(text_input="", image_input=None, unit=""):
116
  elif image_input is not None:
117
  return process_image(image_input,unit)
118
 
119
- with gr.Blocks(theme='shivi/calm_seafoam', css=css, title="家庭医生AI助手") as iface:
120
  with gr.Accordion(""):
121
  gr.Markdown(DESCRIPTION)
122
- unit = gr.Dropdown(label="🩺科室", value='中医科', elem_id="units",
123
- choices=["中医科", "内科", "外科", "妇产科", "儿科", \
124
- "五官科", "男科", "皮肤性病科", "传染科", "精神心理科", \
125
- "整形美容科", "营养科", "生殖中心", "麻醉医学科", "医学影像科", \
126
- "骨科", "肿瘤科", "急诊科", "检验科"])
127
  with gr.Row():
128
  output_box = gr.Markdown(label="分析") # Create an output textbox
129
  with gr.Row():
 
24
 
25
  DESCRIPTION = '''
26
  <div>
27
+ <h1 style="text-align: center;">知觉demo</h1>
28
+ <p>🩺一个基于提示词和前沿多模态模型的AI,帮助您解读专业领域内容。</p>
29
+ <p>🔎 您可以选择领域,参考示例上传图像,或发送需要解读的文字内容。</p>
30
+ <p>🦕 生成解读内容仅供参考。</p>
31
  </div>
32
  '''
33
 
 
59
  completion = client.chat.completions.create(
60
  model=MODEL,
61
  messages=[
62
+ {"role": "system", "content": f" You are a experienced Analyst in {unit}." + SYS_PROMPT},
63
+ {"role": "user", "content": f"Hello! Could you analysis {text_input}?"}
64
  ]
65
  )
66
  return completion.choices[0].message.content
67
  elif text_input and endpoint == 'GOOGLE':
68
  genai.configure(api_key=api_key)
69
  model = genai.GenerativeModel(model_name=MODEL)
70
+ prompt = f" You are a experienced Analyst in {unit}." + SYS_PROMPT + f"Could you analysis {text_input}?"
71
  response = model.generate_content(prompt)
72
  return response.text
73
  return ""
 
88
  response = client.chat.completions.create(
89
  model=MODEL,
90
  messages=[
91
+ {"role": "system", "content": f" You are a experienced Analyst in {unit}." + SYS_PROMPT},
92
  {"role": "user", "content": [
93
  {"type": "text", "text": "Help me understand what is in this picture and analysis."},
94
  {"type": "image_url",
 
105
  elif image_input is not None and endpoint == 'GOOGLE':
106
  genai.configure(api_key=api_key)
107
  model = genai.GenerativeModel(model_name=MODEL)
108
+ prompt = f" You are a experienced Analyst in {unit}." + SYS_PROMPT + "Help me understand what is in this picture and analysis it."
109
  response = model.generate_content([prompt, image_input],request_options={"timeout": 60})
110
  return response.text
111
 
 
116
  elif image_input is not None:
117
  return process_image(image_input,unit)
118
 
119
+ with gr.Blocks(theme='shivi/calm_seafoam', css=css, title="知觉demo") as iface:
120
  with gr.Accordion(""):
121
  gr.Markdown(DESCRIPTION)
122
+ unit = gr.Dropdown(label="领域", value='财经', elem_id="units",
123
+ choices=["财经", "市场", "产业", "国际关系", "医疗", \
124
+ "SEO", "评估", "科技", "策划", "营销"])
 
 
125
  with gr.Row():
126
  output_box = gr.Markdown(label="分析") # Create an output textbox
127
  with gr.Row():