Update app.py
Browse files
app.py
CHANGED
|
@@ -2,26 +2,8 @@ import numpy as np
|
|
| 2 |
import gradio as gr
|
| 3 |
import openai
|
| 4 |
|
| 5 |
-
req1 = "可能性のある仮説や因果モデルを提案して下さい"
|
| 6 |
req2 = "疑問を明らかにするために最適な研究デザインを簡潔に提案して下さい"
|
| 7 |
-
req3 = f'''研究計画書の草案を作成して下さい。構成は
|
| 8 |
-
概要:
|
| 9 |
-
研究の目的:
|
| 10 |
-
研究の背景:
|
| 11 |
-
研究デザイン:
|
| 12 |
-
参加者選択基準:
|
| 13 |
-
参加者登録方法:
|
| 14 |
-
治療計画:
|
| 15 |
-
評価項目、評価スケジュール:
|
| 16 |
-
データ収集:
|
| 17 |
-
エンドポイント:
|
| 18 |
-
統計解析:
|
| 19 |
-
倫理的事項:
|
| 20 |
-
研究結果の発表:
|
| 21 |
-
の順番で作成して下さい。'''
|
| 22 |
-
|
| 23 |
-
# openai.api_key = openai_api_key
|
| 24 |
-
|
| 25 |
|
| 26 |
def generate_clinical_query_solution(text0, text1,text2, text3, text4):
|
| 27 |
|
|
@@ -31,11 +13,9 @@ def generate_clinical_query_solution(text0, text1,text2, text3, text4):
|
|
| 31 |
text2 = req1
|
| 32 |
elif text2 == "Study design 研究デザイン":
|
| 33 |
text2 = req2
|
| 34 |
-
elif text2 == "Protocol draft 研究計画書":
|
| 35 |
-
text2 = req3
|
| 36 |
|
| 37 |
query = f'''あなたは臨床研究の専門家です。以下の臨床疑問や記述について、{text2}。必ず{text4}でお答えください。Please think step by step.;
|
| 38 |
-
|
| 39 |
|
| 40 |
openai.api_key = text0
|
| 41 |
|
|
@@ -191,6 +171,24 @@ def generate_abstract(text0, text27, text28, text4):
|
|
| 191 |
|
| 192 |
return response.choices[0]["message"]["content"].strip()
|
| 193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
title = ("""
|
| 195 |
<h2 align="center">📚GPT-Doc📚</h2>
|
| 196 |
<h5 align="center">This is a support tool for writing papers using OpenAI-API<br>OpenAI-APIを利用した論文作成支援ツールです</h5>
|
|
@@ -231,8 +229,8 @@ with gr.Blocks() as demo:
|
|
| 231 |
with gr.Tab("Clinical Qustion Generation"):
|
| 232 |
with gr.Column(scale=1):
|
| 233 |
text1 = gr.Textbox(lines=2, label="Clinical question 臨床疑問", placeholder="Both formulated messages and vague tweets are acceptable. 定式化されたものでも漠然としたつぶやきでもOKです")
|
| 234 |
-
text2 = gr.Radio(["Hypothesis generation 仮説形成", "Study design 研究デザイン"
|
| 235 |
-
text3 = gr.Textbox(lines=2, label="Create original query 相談内容を記載", placeholder="Please ask any questions. If not, please leave blank here. 上の
|
| 236 |
cq_button = gr.Button("Generate!")
|
| 237 |
text5 = gr.Textbox(lines=2, label="Answer")
|
| 238 |
|
|
@@ -289,6 +287,12 @@ with gr.Blocks() as demo:
|
|
| 289 |
abst_button = gr.Button("Generate!")
|
| 290 |
text29 = gr.Textbox(lines=2, label="Answer")
|
| 291 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
gr.Markdown(disclaimer)
|
| 293 |
|
| 294 |
cq_button.click(generate_clinical_query_solution, inputs=[text0, text1, text2, text3, text4], outputs=text5)
|
|
@@ -298,5 +302,6 @@ with gr.Blocks() as demo:
|
|
| 298 |
disc_button.click(generate_discussions_draft, inputs=[text0, text25, text4], outputs=text26)
|
| 299 |
disc2_button.click(generate_discussions_draft_morita_style, inputs=[text0, text25, text4], outputs=text26)
|
| 300 |
abst_button.click(generate_abstract, inputs=[text0, text27, text28, text4], outputs=text29)
|
|
|
|
| 301 |
|
| 302 |
demo.launch()
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import openai
|
| 4 |
|
| 5 |
+
req1 = "得られた情報をヒントに可能性のある仮説や因果モデルをいくつか提案して下さい"
|
| 6 |
req2 = "疑問を明らかにするために最適な研究デザインを簡潔に提案して下さい"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def generate_clinical_query_solution(text0, text1,text2, text3, text4):
|
| 9 |
|
|
|
|
| 13 |
text2 = req1
|
| 14 |
elif text2 == "Study design 研究デザイン":
|
| 15 |
text2 = req2
|
|
|
|
|
|
|
| 16 |
|
| 17 |
query = f'''あなたは臨床研究の専門家です。以下の臨床疑問や記述について、{text2}。必ず{text4}でお答えください。Please think step by step.;
|
| 18 |
+
{text1}'''
|
| 19 |
|
| 20 |
openai.api_key = text0
|
| 21 |
|
|
|
|
| 171 |
|
| 172 |
return response.choices[0]["message"]["content"].strip()
|
| 173 |
|
| 174 |
+
|
| 175 |
+
def free_consultation(text0, text30, text4):
|
| 176 |
+
|
| 177 |
+
query = f'''あなたは臨床研究の専門家です。以下の相談に対する回答を作成して下さい。必ず{text4}で回答をお願いします。
|
| 178 |
+
{text30}'''
|
| 179 |
+
openai.api_key = text0
|
| 180 |
+
|
| 181 |
+
response = openai.ChatCompletion.create(
|
| 182 |
+
model="gpt-3.5-turbo",
|
| 183 |
+
temperature=0.7,
|
| 184 |
+
max_tokens=2048,
|
| 185 |
+
messages=[
|
| 186 |
+
{"role": "user", "content": query},
|
| 187 |
+
],
|
| 188 |
+
)
|
| 189 |
+
|
| 190 |
+
return response.choices[0]["message"]["content"].strip()
|
| 191 |
+
|
| 192 |
title = ("""
|
| 193 |
<h2 align="center">📚GPT-Doc📚</h2>
|
| 194 |
<h5 align="center">This is a support tool for writing papers using OpenAI-API<br>OpenAI-APIを利用した論文作成支援ツールです</h5>
|
|
|
|
| 229 |
with gr.Tab("Clinical Qustion Generation"):
|
| 230 |
with gr.Column(scale=1):
|
| 231 |
text1 = gr.Textbox(lines=2, label="Clinical question 臨床疑問", placeholder="Both formulated messages and vague tweets are acceptable. 定式化されたものでも漠然としたつぶやきでもOKです")
|
| 232 |
+
text2 = gr.Radio(["Hypothesis generation 仮説形成", "Study design 研究デザイン"], label="Please select your request 相談内容", value="Hypothesis generation 仮説形成")
|
| 233 |
+
text3 = gr.Textbox(lines=2, label="Create original query 相談内容を記載", placeholder="Please ask any questions. If not, please leave blank here. 上の項目の他に質問があれば記載して下さい。なければ空欄のままにしてください")
|
| 234 |
cq_button = gr.Button("Generate!")
|
| 235 |
text5 = gr.Textbox(lines=2, label="Answer")
|
| 236 |
|
|
|
|
| 287 |
abst_button = gr.Button("Generate!")
|
| 288 |
text29 = gr.Textbox(lines=2, label="Answer")
|
| 289 |
|
| 290 |
+
with gr.Tab("Free"):
|
| 291 |
+
with gr.Column(scale=1):
|
| 292 |
+
text30 = gr.Textbox(lines=2, label="Input anything you want to ask 何でも相談", placeholder="e.g. 'please review my writings', 'please summarize',,,英文校正して下さい、サマリーを作って下さい等")
|
| 293 |
+
free_button = gr.Button("Generate!")
|
| 294 |
+
text31 = gr.Textbox(lines=2, label="Answer")
|
| 295 |
+
|
| 296 |
gr.Markdown(disclaimer)
|
| 297 |
|
| 298 |
cq_button.click(generate_clinical_query_solution, inputs=[text0, text1, text2, text3, text4], outputs=text5)
|
|
|
|
| 302 |
disc_button.click(generate_discussions_draft, inputs=[text0, text25, text4], outputs=text26)
|
| 303 |
disc2_button.click(generate_discussions_draft_morita_style, inputs=[text0, text25, text4], outputs=text26)
|
| 304 |
abst_button.click(generate_abstract, inputs=[text0, text27, text28, text4], outputs=text29)
|
| 305 |
+
free_button.click(free_consultation, inputs=[text0, text30, text4], outputs=text31)
|
| 306 |
|
| 307 |
demo.launch()
|