Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -94,32 +94,33 @@ async def generate_response(message):
|
|
94 |
logging.debug(f'Full model response sent: {full_response_text}')
|
95 |
conversation_history.append({"role": "assistant", "content": full_response_text})
|
96 |
|
97 |
-
def
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
123 |
|
124 |
|
125 |
if __name__ == "__main__":
|
|
|
94 |
logging.debug(f'Full model response sent: {full_response_text}')
|
95 |
conversation_history.append({"role": "assistant", "content": full_response_text})
|
96 |
|
97 |
+
async def generate_response(message):
|
98 |
+
global conversation_history
|
99 |
+
user_input = message.content
|
100 |
+
user_mention = message.author.mention
|
101 |
+
system_prefix = """
|
102 |
+
๋ฐ๋์ ํ๊ธ๋ก ๋ต๋ณํ์ญ์์ค.
|
103 |
+
"""
|
104 |
+
system_message = f"{user_mention}, DISCORD์์ ์ฌ์ฉ์๋ค์ ์ง๋ฌธ์ ๋ตํ๋ ์ด์์คํดํธ์
๋๋ค."
|
105 |
+
answer = search_in_dataset(user_input, law_dataset)
|
106 |
+
full_response_text = system_prefix + "\n\n" + answer
|
107 |
+
|
108 |
+
# ์๋ต ๋ฉ์์ง๊ฐ ๋น์ด ์๋์ง ํ์ธํ๊ณ ์ฒ๋ฆฌ
|
109 |
+
if full_response_text.strip() == "":
|
110 |
+
full_response_text = "์ฃ์กํฉ๋๋ค, ์ ๋ณด๋ฅผ ์ ๊ณตํ ์ ์์ต๋๋ค."
|
111 |
+
|
112 |
+
max_length = 2000
|
113 |
+
if len(full_response_text) > max_length:
|
114 |
+
# ๋ฉ์์ง๋ฅผ ์ ์ ํ ๊ธธ์ด๋ก ๋๋์ด ์ ์ก
|
115 |
+
for i in range(0, len(full_response_text), max_length):
|
116 |
+
part_response = full_response_text[i:i+max_length]
|
117 |
+
await message.channel.send(part_response)
|
118 |
+
else:
|
119 |
+
# ์ ์ฒด ๋ฉ์์ง๋ฅผ ํ ๋ฒ์ ์ ์ก
|
120 |
+
await message.channel.send(full_response_text)
|
121 |
+
|
122 |
+
logging.debug(f'Full model response sent: {full_response_text}')
|
123 |
+
conversation_history.append({"role": "assistant", "content": full_response_text})
|
124 |
|
125 |
|
126 |
if __name__ == "__main__":
|