seawolf2357 commited on
Commit
55aa389
ยท
verified ยท
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'))