seawolf2357 commited on
Commit
e33536d
ยท
verified ยท
1 Parent(s): e969750

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -31
app.py CHANGED
@@ -22,10 +22,14 @@ def respond(
22
  temperature=0.7,
23
  top_p=0.95,
24
  ):
 
 
 
 
25
  # ํ˜„์žฌ ๋Œ€ํ™” ๋‚ด์šฉ์„ ๋ฉ”๋ชจ๋ฆฌ์— ์ถ”๊ฐ€
26
  memory.append((message, None))
27
 
28
- messages = [{"role": "system", "content": system_message}]
29
 
30
  # ๋ฉ”๋ชจ๋ฆฌ์—์„œ ๋Œ€ํ™” ๊ธฐ๋ก์„ ๊ฐ€์ ธ์™€ ๋ฉ”์‹œ์ง€ ๋ชฉ๋ก์— ์ถ”๊ฐ€
31
  for val in memory:
@@ -62,36 +66,19 @@ def respond(
62
  memory[-1] = (message, response_text)
63
  yield content
64
 
65
- theme="Nymbo/Nymbo_Theme"
66
 
67
- with gr.Blocks(css=None, theme=theme) as demo:
68
- with gr.Tab("Playground"):
69
- gr.Markdown("## Playground")
70
- with gr.Row():
71
- input_text = gr.Textbox(label="Enter your text")
72
- submit_button = gr.Button("Submit")
73
- output_text = gr.Textbox(label="Processed Text")
74
- submit_button.click(
75
- fn=respond,
76
- inputs=[input_text, output_text],
77
- outputs=output_text,
78
- concurrency_limit=20 # ๊ฐœ๋ณ„ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ์— ๋Œ€ํ•ด ๋™์‹œ์„ฑ ์ œํ•œ ์„ค์ •
79
- )
80
- additional_inputs = [
81
- gr.Textbox(value="๋„ˆ์˜ ์ด๋ฆ„์€ ํ™๊ธธ๋™์ด๋‹ค", label="System message"),
82
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
83
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
84
- gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
85
- ]
86
-
87
- with gr.Tab("Guide"):
88
- gr.Markdown("## Guide")
89
- gr.Markdown("""
90
- ### How to use:
91
- - Use the Playground tab to interact with the chatbot.
92
- - Adjust the parameters to see how the model's responses change.
93
- - Explore different system messages to guide the conversation.
94
- """)
95
 
96
  if __name__ == "__main__":
97
- demo.launch(max_threads=20) # max_threads๋กœ ์ „์ฒด ์Šค๋ ˆ๋“œ ์ˆ˜ ์ œํ•œ
 
22
  temperature=0.7,
23
  top_p=0.95,
24
  ):
25
+ # ์‹œ์Šคํ…œ ๋ฉ”์‹œ์ง€์— ์ ‘๋‘์‚ฌ ์ถ”๊ฐ€
26
+ system_prefix = "System: "
27
+ full_system_message = f"{system_prefix}{system_message}"
28
+
29
  # ํ˜„์žฌ ๋Œ€ํ™” ๋‚ด์šฉ์„ ๋ฉ”๋ชจ๋ฆฌ์— ์ถ”๊ฐ€
30
  memory.append((message, None))
31
 
32
+ messages = [{"role": "system", "content": full_system_message}]
33
 
34
  # ๋ฉ”๋ชจ๋ฆฌ์—์„œ ๋Œ€ํ™” ๊ธฐ๋ก์„ ๊ฐ€์ ธ์™€ ๋ฉ”์‹œ์ง€ ๋ชฉ๋ก์— ์ถ”๊ฐ€
35
  for val in memory:
 
66
  memory[-1] = (message, response_text)
67
  yield content
68
 
69
+ theme = "Nymbo/Nymbo_Theme"
70
 
71
+ # Gradio ChatInterface ์„ค์ •
72
+ demo = gr.ChatInterface(
73
+ fn=respond,
74
+ theme=theme,
75
+ additional_inputs=[
76
+ gr.Textbox(value="๋„ˆ์˜ ์ด๋ฆ„์€ ํ™๊ธธ๋™์ด๋‹ค", label="System message"),
77
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
78
+ gr.Slider(minimum=0.1, maximum 4.0, value=0.7, step=0.1, label="Temperature"),
79
+ gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
80
+ ],
81
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  if __name__ == "__main__":
84
+ demo.queue(concurrency_limit=20).launch(max_threads=20)