ginipick commited on
Commit
0e621af
Β·
verified Β·
1 Parent(s): 4e8ad25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -146,6 +146,21 @@ def analyze_space(url: str, progress=gr.Progress()):
146
  print(traceback.format_exc())
147
  return f"였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}", "", None, ""
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  def create_ui():
150
  try:
151
  css = """
@@ -232,9 +247,7 @@ def create_ui():
232
  top_p = gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P")
233
 
234
  examples = [
235
- ["νŒ¨μ…˜ μ½”λ“œ μ‹€ν–‰"],
236
- ["UHD 이미지 μ½”λ“œ μ‹€ν–‰"],
237
- ["MixGEN μ½”λ“œ μ‹€ν–‰"],
238
  ["μƒμ„Έν•œ μ‚¬μš© 방법을 마치 화면을 λ³΄λ©΄μ„œ μ„€λͺ…ν•˜λ“―이 4000 토큰 이상 μžμ„Ένžˆ μ„€λͺ…ν•˜λΌ"],
239
  ["FAQ 20건을 μƒμ„Έν•˜κ²Œ μž‘μ„±ν•˜λΌ. 4000토큰 이상 μ‚¬μš©ν•˜λΌ."],
240
  ["μ‚¬μš© 방법과 차별점, νŠΉμ§•, 강점을 μ€‘μ‹¬μœΌλ‘œ 4000 토큰 이상 유튜브 μ˜μƒ 슀크립트 ν˜•νƒœλ‘œ μž‘μ„±ν•˜λΌ"],
 
146
  print(traceback.format_exc())
147
  return f"였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}", "", None, ""
148
 
149
+ def respond(message: str, chat_history: List[Dict[str, str]], system_message: str, max_tokens: int, temperature: float, top_p: float):
150
+ messages = [{"role": "system", "content": system_message}]
151
+ for chat in chat_history:
152
+ messages.append({"role": "user", "content": chat["role"] == "user"})
153
+ messages.append({"role": "assistant", "content": chat["role"] == "assistant"})
154
+ messages.append({"role": "user", "content": message})
155
+
156
+ try:
157
+ response = ""
158
+ for chunk in hf_client.chat_completion_stream(messages, max_tokens=max_tokens, temperature=temperature, top_p=top_p):
159
+ response += chunk.choices[0].delta.content or ""
160
+ yield response
161
+ except Exception as e:
162
+ yield f"응닡 생성 쀑 였λ₯˜ λ°œμƒ: {str(e)}"
163
+
164
  def create_ui():
165
  try:
166
  css = """
 
247
  top_p = gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P")
248
 
249
  examples = [
250
+
 
 
251
  ["μƒμ„Έν•œ μ‚¬μš© 방법을 마치 화면을 λ³΄λ©΄μ„œ μ„€λͺ…ν•˜λ“―이 4000 토큰 이상 μžμ„Ένžˆ μ„€λͺ…ν•˜λΌ"],
252
  ["FAQ 20건을 μƒμ„Έν•˜κ²Œ μž‘μ„±ν•˜λΌ. 4000토큰 이상 μ‚¬μš©ν•˜λΌ."],
253
  ["μ‚¬μš© 방법과 차별점, νŠΉμ§•, 강점을 μ€‘μ‹¬μœΌλ‘œ 4000 토큰 이상 유튜브 μ˜μƒ 슀크립트 ν˜•νƒœλ‘œ μž‘μ„±ν•˜λΌ"],