seawolf2357 commited on
Commit
8ce49a6
โ€ข
1 Parent(s): e8bc679

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -3,7 +3,7 @@ from huggingface_hub import InferenceClient
3
  import os
4
  import requests
5
 
6
- # ์ถ”๋ก  API ํด๋ผ์ด์–ธํŠธ ์„ค์ •
7
  hf_client = InferenceClient("mistralai/Mistral-Nemo-Instruct-2407", token=os.getenv("HF_TOKEN"))
8
 
9
  def respond(
@@ -16,10 +16,10 @@ def respond(
16
  ):
17
 
18
  system_prefix = """
19
- ์ž…๋ ฅ ์–ธ์–ด(์˜์–ด, ํ•œ๊ตญ์–ด, ์ค‘๊ตญ์–ด ๋“ฑ)๊ฐ€ ํ•œ๊ตญ์–ด์ด๋ฉด ํ•œ๊ตญ์–ด๋กœ ๋‹ต๋ณ€ํ•˜๊ณ , ์˜์–ด์ด๋ฉด ์˜์–ด๋กœ ๋‹ต๋ณ€ํ•˜๋ผ
20
  """
21
 
22
- messages = [{"role": "system", "content": f"{system_prefix} {system_message}"}] # prefix ์ถ”๊ฐ€
23
 
24
  for val in history:
25
  if val[0]:
@@ -40,7 +40,7 @@ def respond(
40
  ):
41
  token = message.choices[0].delta.content
42
  if token is not None:
43
- response += token.strip("") # ํ† ํฐ ์ œ๊ฑฐ
44
  yield response
45
 
46
 
@@ -56,8 +56,8 @@ demo = gr.ChatInterface(
56
  respond,
57
  additional_inputs=[
58
  gr.Textbox(value="""
59
- ๋„ˆ๋Š” AI ์–ด์‹œ์Šคํ„ดํŠธ์ด๋‹ค.
60
- """, label="์‹œ์Šคํ…œ ํ”„๋กฌํ”„ํŠธ"),
61
  gr.Slider(minimum=1, maximum=2000, value=512, step=1, label="Max new tokens"),
62
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
63
  gr.Slider(
@@ -68,11 +68,9 @@ demo = gr.ChatInterface(
68
  label="Top-p (nucleus sampling)",
69
  ),
70
  ],
71
- theme=theme, # ํ…Œ๋งˆ ์ ์šฉ
72
- css=css # CSS ์ ์šฉ
73
  )
74
 
75
-
76
-
77
  if __name__ == "__main__":
78
  demo.launch()
 
3
  import os
4
  import requests
5
 
6
+ # Set up the inference API client
7
  hf_client = InferenceClient("mistralai/Mistral-Nemo-Instruct-2407", token=os.getenv("HF_TOKEN"))
8
 
9
  def respond(
 
16
  ):
17
 
18
  system_prefix = """
19
+ If the input language is Korean, respond in Korean. If it's English, respond in English.
20
  """
21
 
22
+ messages = [{"role": "system", "content": f"{system_prefix} {system_message}"}] # Add prefix
23
 
24
  for val in history:
25
  if val[0]:
 
40
  ):
41
  token = message.choices[0].delta.content
42
  if token is not None:
43
+ response += token.strip("") # Remove tokens
44
  yield response
45
 
46
 
 
56
  respond,
57
  additional_inputs=[
58
  gr.Textbox(value="""
59
+ You are an AI assistant.
60
+ """, label="System Prompt"),
61
  gr.Slider(minimum=1, maximum=2000, value=512, step=1, label="Max new tokens"),
62
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
63
  gr.Slider(
 
68
  label="Top-p (nucleus sampling)",
69
  ),
70
  ],
71
+ theme=theme, # Apply theme
72
+ css=css # Apply CSS
73
  )
74
 
 
 
75
  if __name__ == "__main__":
76
  demo.launch()