seawolf2357 commited on
Commit
dd6eadc
โ€ข
1 Parent(s): 51ebe4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -30,7 +30,6 @@ class MyClient(discord.Client):
30
  response = await generate_response(message.content)
31
  await message.channel.send(response)
32
 
33
- # Hugging Face ์ถ”๋ก  API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‘๋‹ต ์ƒ์„ฑ
34
  async def generate_response(user_input):
35
  system_message = "DISCORD์—์„œ ์‚ฌ์šฉ์ž๋“ค์˜ ์งˆ๋ฌธ์— ๋‹ตํ•˜๋Š” ์ „๋ฌธ AI ์–ด์‹œ์Šคํ„ดํŠธ ์—ญํ• ์ž…๋‹ˆ๋‹ค."
36
  system_prefix = """
@@ -44,12 +43,12 @@ async def generate_response(user_input):
44
 
45
  # ๋™๊ธฐ ํ•จ์ˆ˜๋ฅผ ๋น„๋™๊ธฐ๋กœ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๋ž˜ํผ ์‚ฌ์šฉ
46
  loop = asyncio.get_event_loop()
47
- response = await loop.run_in_executor(None, lambda: hf_client.chat_completion(messages, max_tokens=1000, stream=False, temperature=0.7, top_p=0.95))
48
- logging.debug(f'API response: {response}') # API ์‘๋‹ต ๋กœ๊น…
49
 
50
- # API ์‘๋‹ต ๋กœ๊ทธ์— ๋”ฐ๋ผ content ์†์„ฑ ์‚ฌ์šฉ
51
  return response.choices[0].message.content.strip()
52
 
 
53
  # ๋””์Šค์ฝ”๋“œ ๋ด‡ ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ ๋ฐ ์‹คํ–‰
54
  discord_client = MyClient(intents=intents)
55
  discord_client.run(os.getenv('DISCORD_TOKEN'))
 
30
  response = await generate_response(message.content)
31
  await message.channel.send(response)
32
 
 
33
  async def generate_response(user_input):
34
  system_message = "DISCORD์—์„œ ์‚ฌ์šฉ์ž๋“ค์˜ ์งˆ๋ฌธ์— ๋‹ตํ•˜๋Š” ์ „๋ฌธ AI ์–ด์‹œ์Šคํ„ดํŠธ ์—ญํ• ์ž…๋‹ˆ๋‹ค."
35
  system_prefix = """
 
43
 
44
  # ๋™๊ธฐ ํ•จ์ˆ˜๋ฅผ ๋น„๋™๊ธฐ๋กœ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๋ž˜ํผ ์‚ฌ์šฉ
45
  loop = asyncio.get_event_loop()
46
+ response = await loop.run_in_executor(None, lambda: hf_client.chat_completion(
47
+ messages, max_tokens=1000, stream=False, temperature=1.0, top_p=0.9)) # ํŒŒ๋ผ๋ฏธํ„ฐ ์กฐ์ •
48
 
 
49
  return response.choices[0].message.content.strip()
50
 
51
+
52
  # ๋””์Šค์ฝ”๋“œ ๋ด‡ ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ ๋ฐ ์‹คํ–‰
53
  discord_client = MyClient(intents=intents)
54
  discord_client.run(os.getenv('DISCORD_TOKEN'))