Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -95,12 +95,13 @@ async def generate_response(message):
|
|
95 |
conversation_history.append({"role": "assistant", "content": full_response_text})
|
96 |
|
97 |
|
98 |
-
|
99 |
def search_in_dataset(query, dataset):
|
|
|
100 |
response = []
|
101 |
for record in dataset['train']:
|
102 |
-
#
|
103 |
-
if
|
|
|
104 |
detail = (
|
105 |
f"ํ๋ก์ ๋ณด์ผ๋ จ๋ฒํธ: {record['ํ๋ก์ ๋ณด์ผ๋ จ๋ฒํธ']}\n"
|
106 |
f"์ฌ๊ฑด๋ช
: {record['์ฌ๊ฑด๋ช
']}\n"
|
@@ -117,16 +118,9 @@ def search_in_dataset(query, dataset):
|
|
117 |
f"์ ๋ฌธ: {record['์ ๋ฌธ']}\n"
|
118 |
)
|
119 |
response.append(detail)
|
120 |
-
break # ์ฒซ ๋ฒ์งธ ์ผ์นํ๋ ๊ฒฐ๊ณผ๋ง ๋ฐํ
|
121 |
|
122 |
-
#
|
123 |
-
if response
|
124 |
-
logging.debug("Search successful, response generated.")
|
125 |
-
return "\n".join(response)
|
126 |
-
else:
|
127 |
-
logging.debug("No relevant legal information found.")
|
128 |
-
return "๊ด๋ จ ๋ฒ๋ฅ ์ ๋ณด๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค."
|
129 |
-
|
130 |
|
131 |
|
132 |
if __name__ == "__main__":
|
|
|
95 |
conversation_history.append({"role": "assistant", "content": full_response_text})
|
96 |
|
97 |
|
|
|
98 |
def search_in_dataset(query, dataset):
|
99 |
+
# ์ฌ์ฉ์์ ์ฟผ๋ฆฌ์ ๊ด๋ จ๋ ๋ชจ๋ ํ๋๋ฅผ ๊ฒ์ํ๊ณ ์์ธ ์ ๋ณด๋ฅผ ๋ฐํํฉ๋๋ค.
|
100 |
response = []
|
101 |
for record in dataset['train']:
|
102 |
+
# ์ฌ๊ฑด๋ช
ํ๋์์ ์ฌ์ฉ์์ ์ฟผ๋ฆฌ์ ๊ด๋ จ๋ ์ ๋ณด๋ฅผ ์ฐพ์ต๋๋ค.
|
103 |
+
if query in record['์ฌ๊ฑด๋ช
']:
|
104 |
+
# ์ ๋ณด๊ฐ ๋ฐ๊ฒฌ๋๋ฉด, ๋ชจ๋ ํ๋์ ์์ธํ ์ ๋ณด๋ฅผ ํฌ๋งทํ
ํ์ฌ response ๋ฆฌ์คํธ์ ์ถ๊ฐํฉ๋๋ค.
|
105 |
detail = (
|
106 |
f"ํ๋ก์ ๋ณด์ผ๋ จ๋ฒํธ: {record['ํ๋ก์ ๋ณด์ผ๋ จ๋ฒํธ']}\n"
|
107 |
f"์ฌ๊ฑด๋ช
: {record['์ฌ๊ฑด๋ช
']}\n"
|
|
|
118 |
f"์ ๋ฌธ: {record['์ ๋ฌธ']}\n"
|
119 |
)
|
120 |
response.append(detail)
|
|
|
121 |
|
122 |
+
# response ๋ฆฌ์คํธ์ ๋ด๊ธด ์ ๋ณด๋ค์ ๋ฐํํฉ๋๋ค.
|
123 |
+
return "\n".join(response) if response else "๊ด๋ จ ๋ฒ๋ฅ ์ ๋ณด๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค."
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
|
126 |
if __name__ == "__main__":
|