vilarin commited on
Commit
572f86e
·
verified ·
1 Parent(s): fbdf06c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -23
app.py CHANGED
@@ -5,28 +5,23 @@ import os
5
  import io
6
  import base64
7
 
8
- # Set API key and organization ID from environment variables
9
- api_key = os.environ.get("OPENAI_API_KEY")
10
  #base_url = os.environ.get("OPENAI_API_BASE")
 
11
  client = OpenAI(api_key=api_key)
12
 
13
  # Define the model to be used
14
  MODEL = os.environ.get("MODEL")
15
 
16
- def read(filename):
17
- with open(filename) as f:
18
- data = f.read()
19
- return data
20
-
21
  SYS_PROMPT = read('system_prompt.txt')
22
 
23
 
24
  DESCRIPTION = '''
25
  <div>
26
- <h1 style="text-align: center;">诊疗助手Alpha</h1>
27
- <p>一个帮助您分析症状和检验报告的AI工具。</p>
28
- <p>🔎 选择您需要咨询的科室,在输入框中输入症状描述或者体检信息等;您也可以在图片框中上传检测报告图。</p>
29
- <p>🦕 请注意生成信息可能不准确,且不具备任何实际参考价值,如有需要请联系专业医生。</p>
30
  </div>
31
  '''
32
 
@@ -42,7 +37,12 @@ footer {
42
  """
43
 
44
 
45
- LICENSE = '采用 ' + MODEL + ' 模型'
 
 
 
 
 
46
 
47
  def process_text(text_input, unit):
48
  if text_input:
@@ -95,22 +95,24 @@ def main(text_input="", image_input=None, unit=""):
95
  with gr.Blocks(theme='shivi/calm_seafoam', css=css, title="诊疗助手Alpha") as iface:
96
  with gr.Accordion(""):
97
  gr.Markdown(DESCRIPTION)
98
- unit = gr.Dropdown(label="🩺科室", value='中医科', elem_id="units",
99
- choices=["中医科", "内科", "外科", "妇产科", "儿科", \
100
- "五官科", "男科", "皮肤性病科", "传染科", "精神心理科", \
101
- "整形美容科", "营养科", "生殖中心", "麻醉医学科", "医学影像科", \
102
- "骨科", "肿瘤科", "急诊科", "检验科"])
 
 
103
  with gr.Row():
104
- output_box = gr.Markdown(label="分析") # Create an output textbox
105
  with gr.Row():
106
- image_input = gr.Image(type="pil", label="上传图片") # Create an image upload button
107
- text_input = gr.Textbox(label="输入") # Create a text input box
108
  with gr.Row():
109
- submit_btn = gr.Button("🚀 确认") # Create a submit button
110
- clear_btn = gr.ClearButton(output_box, value="🗑️ 清空") # Create a clear button
111
 
112
  # Set up the event listeners
113
- submit_btn.click(main, inputs=[text_input, image_input, unit], outputs=output_box)
114
 
115
  gr.Markdown(LICENSE)
116
 
 
5
  import io
6
  import base64
7
 
8
+ # Set API key
 
9
  #base_url = os.environ.get("OPENAI_API_BASE")
10
+ api_key = ""
11
  client = OpenAI(api_key=api_key)
12
 
13
  # Define the model to be used
14
  MODEL = os.environ.get("MODEL")
15
 
 
 
 
 
 
16
  SYS_PROMPT = read('system_prompt.txt')
17
 
18
 
19
  DESCRIPTION = '''
20
  <div>
21
+ <h1 style="text-align: center;">Medster - Diagnostic Assistant</h1>
22
+ <p>An AI tool that helps you analyze symptoms and test reports. </p>
23
+ <p>🔎 Select the department you need to consult, and enter the symptom description or physical examination information in the input box; you can also upload the test report image in the picture box. </p>
24
+ <p>🦕 Please note that the generated information may be inaccurate and does not have any actual reference value. Please contact a professional doctor if necessary. </p>
25
  </div>
26
  '''
27
 
 
37
  """
38
 
39
 
40
+ LICENSE = 'MODEL: ' + MODEL + ' LOADED'
41
+
42
+ def read(filename):
43
+ with open(filename) as f:
44
+ data = f.read()
45
+ return data
46
 
47
  def process_text(text_input, unit):
48
  if text_input:
 
95
  with gr.Blocks(theme='shivi/calm_seafoam', css=css, title="诊疗助手Alpha") as iface:
96
  with gr.Accordion(""):
97
  gr.Markdown(DESCRIPTION)
98
+ unit = gr.Dropdown(label="🩺Department", value='Traditional Chinese Medicine', elem_id="units",
99
+ choices=["Traditional Medicine", "Internal Medicine", "Surgery", "Obstetrics and Gynecology", "Pediatrics", \
100
+ "Orthodontics", "Andrology", "Dermatology and Venereology", "Infectious Diseases", "Psychiatry", \
101
+ "Plastic Surgery Department", "Nutrition Department", "Reproductive Center", "Anesthesiology Department", "Medical Imaging Department", \
102
+ "Orthopedics", "Oncology", "Emergency Department", "Laboratory Department"])
103
+ with gr.Row():
104
+ output_box = gr.Markdown(label="Diagnosis") # Create an output textbox
105
  with gr.Row():
106
+ api_key = gr.Textbox(label="OpenAI API Key") # Input API key
107
  with gr.Row():
108
+ image_input = gr.Image(type="pil", label="Upload Image") # Create an image upload button
109
+ text_input = gr.Textbox(label="Submit") # Create a text input box
110
  with gr.Row():
111
+ submit_btn = gr.Button("🚀 Send") # Create a submit button
112
+ clear_btn = gr.ClearButton(output_box, value="🗑️ Clear") # Create a clear button
113
 
114
  # Set up the event listeners
115
+ submit_btn.click(main, inputs=[apiKey, text_input, image_input, unit], outputs=output_box)
116
 
117
  gr.Markdown(LICENSE)
118