seawolf2357
commited on
Commit
โข
dd6eadc
1
Parent(s):
51ebe4a
Update app.py
Browse files
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(
|
48 |
-
|
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'))
|