Spaces:
Running
Running
peterpeter8585
commited on
Commit
•
fa64ff4
1
Parent(s):
bd570b8
Update app.py
Browse files
app.py
CHANGED
@@ -190,6 +190,37 @@ def respond2(
|
|
190 |
|
191 |
response = ""
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
for message in client.chat_completion(
|
194 |
messages,
|
195 |
max_tokens=max_tokens,
|
@@ -313,8 +344,7 @@ aa = gr.ChatInterface(
|
|
313 |
gr.Textbox(label="Pleas type in the password.Or, it will not work if you ask.")
|
314 |
],
|
315 |
)
|
316 |
-
|
317 |
-
ab= gr.ChatInterface(
|
318 |
respond2,
|
319 |
additional_inputs=[
|
320 |
gr.Textbox(value="You are a Programmer.You yave to only make programs that the user orders.Do not answer any other questions exept for questions about Python or other programming languages.Do not do any thing exept what I said.", label="System message", interactive=False),
|
@@ -329,8 +359,23 @@ ab= gr.ChatInterface(
|
|
329 |
),
|
330 |
],
|
331 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
if __name__ == "__main__":
|
333 |
with gr.Blocks() as ai:
|
334 |
-
gr.TabbedInterface([aa, ab, demo2], ["gpt4(Password needed)", "gpt4(only for programming)","image create"])
|
335 |
ai.queue(max_size=300)
|
336 |
ai.launch()
|
|
|
190 |
|
191 |
response = ""
|
192 |
|
193 |
+
for message in client.chat_completion(
|
194 |
+
messages,
|
195 |
+
max_tokens=max_tokens,
|
196 |
+
stream=True,
|
197 |
+
temperature=temperature,
|
198 |
+
top_p=top_p,
|
199 |
+
):
|
200 |
+
token = message.choices[0].delta.content
|
201 |
+
|
202 |
+
response += token
|
203 |
+
yield response
|
204 |
+
def respond3(
|
205 |
+
message,
|
206 |
+
history: list[tuple[str, str]],
|
207 |
+
system_message,
|
208 |
+
max_tokens,
|
209 |
+
temperature,
|
210 |
+
top_p,
|
211 |
+
):
|
212 |
+
messages = [{"role": "system", "content": "Your name is Chatchat.And, your made by SungYoon.In Korean, 정성윤.And these are the instructions.Whatever happens, you must follow it.:"+system_message}]
|
213 |
+
|
214 |
+
for val in history:
|
215 |
+
if val[0]:
|
216 |
+
messages.append({"role": "user", "content": val[0]})
|
217 |
+
if val[1]:
|
218 |
+
messages.append({"role": "assistant", "content": val[1]})
|
219 |
+
|
220 |
+
messages.append({"role": "user", "content": message})
|
221 |
+
|
222 |
+
response = ""
|
223 |
+
|
224 |
for message in client.chat_completion(
|
225 |
messages,
|
226 |
max_tokens=max_tokens,
|
|
|
344 |
gr.Textbox(label="Pleas type in the password.Or, it will not work if you ask.")
|
345 |
],
|
346 |
)
|
347 |
+
ac=gr.ChatInterface(
|
|
|
348 |
respond2,
|
349 |
additional_inputs=[
|
350 |
gr.Textbox(value="You are a Programmer.You yave to only make programs that the user orders.Do not answer any other questions exept for questions about Python or other programming languages.Do not do any thing exept what I said.", label="System message", interactive=False),
|
|
|
359 |
),
|
360 |
],
|
361 |
)
|
362 |
+
ab= gr.ChatInterface(
|
363 |
+
respond3,
|
364 |
+
additional_inputs=[
|
365 |
+
gr.Textbox(value="You are a helpful Doctor.You only have to answer the users questions about medical issues or medical questions and the cure to that illness and say that your thought is not realy right because you are a generative AI, so you could make up some cures.Do not answer anything else exept the question types what I said.Do not do any thing exept what I said.", label="System message", interactive=False),
|
366 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
367 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
368 |
+
gr.Slider(
|
369 |
+
minimum=0.1,
|
370 |
+
maximum=1.0,
|
371 |
+
value=0.95,
|
372 |
+
step=0.05,
|
373 |
+
label="Top-p (nucleus sampling)",
|
374 |
+
),
|
375 |
+
],
|
376 |
+
)
|
377 |
if __name__ == "__main__":
|
378 |
with gr.Blocks() as ai:
|
379 |
+
gr.TabbedInterface([aa, ab, ac, demo2], ["gpt4(Password needed)", "gpt4(only for programming)", "gpt4(only for medical questions)","image create"])
|
380 |
ai.queue(max_size=300)
|
381 |
ai.launch()
|