seawolf2357 commited on
Commit
55aa389
β€’
1 Parent(s): 76e110d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -49,15 +49,14 @@ async def generate_response(user_input, history, system_message, max_tokens, tem
49
  messages.append({"role": "assistant", "content": val[1]})
50
  messages.append({"role": "user", "content": user_input})
51
 
52
- # ν•¨μˆ˜κ°€ 동기 λ°©μ‹μ΄λ―€λ‘œ awaitλ₯Ό μ‚¬μš©ν•˜μ§€ μ•ŠμŒ
53
  try:
54
- response = hf_client.chat_completion(messages, max_tokens=max_tokens, stream=False, temperature=temperature, top_p=top_p)
55
- return response.choices[0].delta.content.strip() # 비동기가 μ•„λ‹ˆλ―€λ‘œ λ°”λ‘œ κ²°κ³Ό μ ‘κ·Ό
 
56
  except Exception as e:
57
  logging.error(f"An error occurred: {e}")
58
  return "였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. λ‹€μ‹œ μ‹œλ„ν•΄ μ£Όμ„Έμš”."
59
 
60
-
61
  # λ””μŠ€μ½”λ“œ 봇 μΈμŠ€ν„΄μŠ€ 생성 및 μ‹€ν–‰
62
  discord_client = MyClient(intents=intents)
63
  discord_client.run(os.getenv('DISCORD_TOKEN'))
 
49
  messages.append({"role": "assistant", "content": val[1]})
50
  messages.append({"role": "user", "content": user_input})
51
 
 
52
  try:
53
+ response = await hf_client.chat_completion(messages, max_tokens=max_tokens, stream=False, temperature=temperature, top_p=top_p)
54
+ # μ˜¬λ°”λ₯Έ 속성에 μ ‘κ·Όν•˜μ—¬ 응닡 λ‚΄μš©μ„ μΆ”μΆœ
55
+ return response.choices[0].text # 'delta' λŒ€μ‹  'text' λ˜λŠ” API λ¬Έμ„œμ— λ”°λ₯Έ μ μ ˆν•œ 속성 μ‚¬μš©
56
  except Exception as e:
57
  logging.error(f"An error occurred: {e}")
58
  return "였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. λ‹€μ‹œ μ‹œλ„ν•΄ μ£Όμ„Έμš”."
59
 
 
60
  # λ””μŠ€μ½”λ“œ 봇 μΈμŠ€ν„΄μŠ€ 생성 및 μ‹€ν–‰
61
  discord_client = MyClient(intents=intents)
62
  discord_client.run(os.getenv('DISCORD_TOKEN'))