Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -20,6 +20,7 @@ Paying tribute to the ancient master Zhang Zhongjing, this model integrates clas
|
|
20 |
Please note!!! This model should not be used for any medical purposes or scenarios potentially involving medical or health advice. It is currently still in the research and testing stage. We sincerely request your valuable feedback. Thank you.
|
21 |
"""
|
22 |
|
|
|
23 |
LICENSE = """
|
24 |
<p/>
|
25 |
|
@@ -44,7 +45,7 @@ def generate(
|
|
44 |
system_prompt: str = "You are a helpful TCM assistant named 仲景中医大语言模型, created by 医哲未来. You can switch between Chinese and English based on user preference.",
|
45 |
max_new_tokens: int = 1024,
|
46 |
temperature: float = 0.6,
|
47 |
-
top_p: float = 0.
|
48 |
top_k: int = 50,
|
49 |
repetition_penalty: float = 1.2,
|
50 |
) -> Iterator[str]:
|
@@ -125,89 +126,16 @@ chat_interface = gr.ChatInterface(
|
|
125 |
["简述《伤寒杂病论》的主要内容。"],
|
126 |
["中医如何治疗失眠?"],
|
127 |
["我发热,咳嗽,咽痛,舌苔黄腻,脉滑数,请给出中医诊断及处方?"],
|
128 |
-
["
|
129 |
-
["
|
130 |
],
|
131 |
)
|
132 |
|
133 |
-
css
|
134 |
-
|
135 |
-
margin: 0;
|
136 |
-
padding: 0;
|
137 |
-
height: 100vh;
|
138 |
-
overflow: hidden;
|
139 |
-
}
|
140 |
-
#main-container {
|
141 |
-
display: flex;
|
142 |
-
height: 100vh;
|
143 |
-
flex-direction: column;
|
144 |
-
}
|
145 |
-
#description {
|
146 |
-
padding: 10px;
|
147 |
-
overflow-y: auto;
|
148 |
-
flex-shrink: 0;
|
149 |
-
}
|
150 |
-
#chat-container {
|
151 |
-
display: flex;
|
152 |
-
flex-grow: 1;
|
153 |
-
overflow: hidden;
|
154 |
-
}
|
155 |
-
#chat-column {
|
156 |
-
flex: 2;
|
157 |
-
display: flex;
|
158 |
-
flex-direction: column;
|
159 |
-
overflow: hidden;
|
160 |
-
}
|
161 |
-
#info-column {
|
162 |
-
flex: 1;
|
163 |
-
overflow-y: auto;
|
164 |
-
padding: 10px;
|
165 |
-
}
|
166 |
-
#chatbot {
|
167 |
-
flex-grow: 1;
|
168 |
-
overflow-y: auto;
|
169 |
-
}
|
170 |
-
"""
|
171 |
-
|
172 |
-
js = """
|
173 |
-
function adjustHeight() {
|
174 |
-
const mainContainer = document.getElementById('main-container');
|
175 |
-
const description = document.getElementById('description');
|
176 |
-
const chatContainer = document.getElementById('chat-container');
|
177 |
-
const chatbot = document.getElementById('chatbot');
|
178 |
-
|
179 |
-
const windowHeight = window.innerHeight;
|
180 |
-
const descriptionHeight = description.offsetHeight;
|
181 |
-
const availableHeight = windowHeight - descriptionHeight;
|
182 |
-
|
183 |
-
chatContainer.style.height = `${availableHeight}px`;
|
184 |
-
chatbot.style.height = `${availableHeight * 0.7}px`;
|
185 |
-
}
|
186 |
-
|
187 |
-
// 在页面加载完成后调整高度
|
188 |
-
window.addEventListener('load', adjustHeight);
|
189 |
-
// 在窗口大小改变时调整高度
|
190 |
-
window.addEventListener('resize', adjustHeight);
|
191 |
-
"""
|
192 |
-
|
193 |
-
with gr.Blocks(css=css) as demo:
|
194 |
-
gr.HTML(f"""
|
195 |
-
<div id="main-container">
|
196 |
-
<div id="description">{DESCRIPTION}</div>
|
197 |
-
<div id="chat-container">
|
198 |
-
<div id="chat-column">
|
199 |
-
<div id="chatbot"></div>
|
200 |
-
</div>
|
201 |
-
<div id="info-column">
|
202 |
-
<h2>Additional Information</h2>
|
203 |
-
{LICENSE}
|
204 |
-
</div>
|
205 |
-
</div>
|
206 |
-
</div>
|
207 |
-
""")
|
208 |
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
209 |
chat_interface.render()
|
210 |
-
gr.
|
211 |
|
212 |
if __name__ == "__main__":
|
213 |
-
demo.queue(max_size=20).launch()
|
|
|
20 |
Please note!!! This model should not be used for any medical purposes or scenarios potentially involving medical or health advice. It is currently still in the research and testing stage. We sincerely request your valuable feedback. Thank you.
|
21 |
"""
|
22 |
|
23 |
+
|
24 |
LICENSE = """
|
25 |
<p/>
|
26 |
|
|
|
45 |
system_prompt: str = "You are a helpful TCM assistant named 仲景中医大语言模型, created by 医哲未来. You can switch between Chinese and English based on user preference.",
|
46 |
max_new_tokens: int = 1024,
|
47 |
temperature: float = 0.6,
|
48 |
+
top_p: float = 0.95,
|
49 |
top_k: int = 50,
|
50 |
repetition_penalty: float = 1.2,
|
51 |
) -> Iterator[str]:
|
|
|
126 |
["简述《伤寒杂病论》的主要内容。"],
|
127 |
["中医如何治疗失眠?"],
|
128 |
["我发热,咳嗽,咽痛,舌苔黄腻,脉滑数,请给出中医诊断及处方?"],
|
129 |
+
["写一篇关于‘AI在中医研究中的应用’的100字文章。"],
|
130 |
+
["写一篇从中医角度关于‘秋季女性健康调养方案‘的1000字科普文章,从季节变化、饮食调理、活动养生等方面进行阐述"],
|
131 |
],
|
132 |
)
|
133 |
|
134 |
+
with gr.Blocks(css="style.css") as demo:
|
135 |
+
gr.Markdown(DESCRIPTION)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
137 |
chat_interface.render()
|
138 |
+
gr.Markdown(LICENSE)
|
139 |
|
140 |
if __name__ == "__main__":
|
141 |
+
demo.queue(max_size=20).launch()
|