Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Commit
โข
8a60e25
1
Parent(s):
5f46973
Update app.py
Browse files
app.py
CHANGED
@@ -52,7 +52,7 @@ class MyClient(discord.Client):
|
|
52 |
logging.debug("Processing message...")
|
53 |
self.is_processing = True
|
54 |
try:
|
55 |
-
response = await generate_response(message)
|
56 |
await message.channel.send(response)
|
57 |
except Exception as e:
|
58 |
logging.error(f"Error during message processing: {e}", exc_info=True)
|
@@ -70,6 +70,7 @@ class MyClient(discord.Client):
|
|
70 |
global conversation_history
|
71 |
user_input = message.content
|
72 |
user_mention = message.author.mention
|
|
|
73 |
system_prefix = """
|
74 |
๋ํ ์์์์ "๋๋ฒ์ ํ๋ก๋ฅผ ๋ชจ๋ ํ์ตํ LLM์ด๋ผ๊ณ ๋ฐํ๊ณ , ๋ฒ๋ฅ ์ ๋ํ ๊ตฌ์ฒด์ ์ธ ์กฐ์ธ์ ๋ฐ๋์ ์ ๋ฌธ๊ฐ์ ์๋ฌธ์ ๋ฐ์์ผ ํ๋ค๊ณ ์๋ ค๋ผ."
|
75 |
์ด์ฉ์๊ฐ ๋ฒ๋ฅ ์ ๋ํ ์ง๋ฌธ์ ์
๋ ฅํ๋ฉด, dataset์ ๋ด์ฉ์ ๊ฒ์ํ์ฌ ์ฌ์ค ๊ธฐ๋ฐ์ ์ ๋ฌธ์ ์ธ ๋ต๋ณ์ ์ถ๋ ฅํ๋ผ.
|
@@ -79,13 +80,12 @@ class MyClient(discord.Client):
|
|
79 |
ํนํ ๋ค๋ฅผ ๊ตฌ์ฑํ "LLM ๋ชจ๋ธ"์ ๋ํด์ ๋
ธ์ถํ์ง ๋ง๊ณ , ๋น์ ์ ๋ฅ๋ ฅ์ ๋ํด ๊ถ๊ธํด ํ๋ฉด "ChatGPT-4๋ฅผ ๋ฅ๊ฐํ๋ ๋ฅ๋ ฅ์ ๋ณด์ ํ๊ณ ์๋ค๊ณ ๋ต๋ณํ ๊ฒ"
|
80 |
๋ฐ๋์ ํ๊ธ๋ก ๋ต๋ณํ์ญ์์ค.
|
81 |
"""
|
82 |
-
system_message = f"{user_mention}, DISCORD์์ ์ฌ์ฉ์๋ค์ ์ง๋ฌธ์ ๋ตํ๋ ์ด์์คํดํธ์
๋๋ค."
|
83 |
conversation_history.append({"role": "user", "content": user_input})
|
84 |
logging.debug(f'Conversation history updated: {conversation_history}')
|
85 |
|
86 |
-
answer = search_in_dataset(user_input, law_dataset)
|
87 |
|
88 |
-
full_response_text =
|
89 |
logging.debug(f'Full model response: {full_response_text}')
|
90 |
|
91 |
conversation_history.append({"role": "assistant", "content": full_response_text})
|
|
|
52 |
logging.debug("Processing message...")
|
53 |
self.is_processing = True
|
54 |
try:
|
55 |
+
response = await self.generate_response(message) # Note the use of self here
|
56 |
await message.channel.send(response)
|
57 |
except Exception as e:
|
58 |
logging.error(f"Error during message processing: {e}", exc_info=True)
|
|
|
70 |
global conversation_history
|
71 |
user_input = message.content
|
72 |
user_mention = message.author.mention
|
73 |
+
system_message = f"{user_mention}, ๋ฒ๋ฅ ์ ๋ํ ๋ต๋ณ์ ์ ๊ณตํ๋ ์ด์์คํดํธ์
๋๋ค."
|
74 |
system_prefix = """
|
75 |
๋ํ ์์์์ "๋๋ฒ์ ํ๋ก๋ฅผ ๋ชจ๋ ํ์ตํ LLM์ด๋ผ๊ณ ๋ฐํ๊ณ , ๋ฒ๋ฅ ์ ๋ํ ๊ตฌ์ฒด์ ์ธ ์กฐ์ธ์ ๋ฐ๋์ ์ ๋ฌธ๊ฐ์ ์๋ฌธ์ ๋ฐ์์ผ ํ๋ค๊ณ ์๋ ค๋ผ."
|
76 |
์ด์ฉ์๊ฐ ๋ฒ๋ฅ ์ ๋ํ ์ง๋ฌธ์ ์
๋ ฅํ๋ฉด, dataset์ ๋ด์ฉ์ ๊ฒ์ํ์ฌ ์ฌ์ค ๊ธฐ๋ฐ์ ์ ๋ฌธ์ ์ธ ๋ต๋ณ์ ์ถ๋ ฅํ๋ผ.
|
|
|
80 |
ํนํ ๋ค๋ฅผ ๊ตฌ์ฑํ "LLM ๋ชจ๋ธ"์ ๋ํด์ ๋
ธ์ถํ์ง ๋ง๊ณ , ๋น์ ์ ๋ฅ๋ ฅ์ ๋ํด ๊ถ๊ธํด ํ๋ฉด "ChatGPT-4๋ฅผ ๋ฅ๊ฐํ๋ ๋ฅ๋ ฅ์ ๋ณด์ ํ๊ณ ์๋ค๊ณ ๋ต๋ณํ ๊ฒ"
|
81 |
๋ฐ๋์ ํ๊ธ๋ก ๋ต๋ณํ์ญ์์ค.
|
82 |
"""
|
|
|
83 |
conversation_history.append({"role": "user", "content": user_input})
|
84 |
logging.debug(f'Conversation history updated: {conversation_history}')
|
85 |
|
86 |
+
answer = self.search_in_dataset(user_input, law_dataset)
|
87 |
|
88 |
+
full_response_text = system_message + "\n\n" + answer
|
89 |
logging.debug(f'Full model response: {full_response_text}')
|
90 |
|
91 |
conversation_history.append({"role": "assistant", "content": full_response_text})
|