Update app.py
Browse files
app.py
CHANGED
@@ -108,9 +108,9 @@ def create_deepseek_interface():
|
|
108 |
# ์๋ต ๊ตฌ์กฐ ํ์ธ
|
109 |
print(f"์๋ต ๊ตฌ์กฐ: {list(search_results.keys()) if isinstance(search_results, dict) else '๋์
๋๋ฆฌ ์๋'}")
|
110 |
|
111 |
-
# ๊ฒ์ ๊ฒฐ๊ณผ ํ์ฑ ๋ฐ ํฌ๋งทํ
|
112 |
formatted_results = []
|
113 |
-
formatted_results.append(f"๊ฒ์์ด: {search_query}\n\n")
|
114 |
|
115 |
# ๋ค์ํ ๊ฐ๋ฅํ ์๋ต ๊ตฌ์กฐ์ ๋ํ ์ฒ๋ฆฌ
|
116 |
organic_results = None
|
@@ -133,15 +133,18 @@ def create_deepseek_interface():
|
|
133 |
# ์๋ต ๊ตฌ์กฐ ์ถ๋ ฅ
|
134 |
print(f"์ฒซ๋ฒ์งธ organic ๊ฒฐ๊ณผ ๊ตฌ์กฐ: {organic_results[0].keys() if len(organic_results) > 0 else 'empty'}")
|
135 |
|
136 |
-
for result in organic_results[:5]: # ์์ 5๊ฐ ๊ฒฐ๊ณผ๋ง ํ์
|
137 |
title = result.get("title", "์ ๋ชฉ ์์")
|
138 |
snippet = result.get("snippet", "๋ด์ฉ ์์")
|
139 |
link = result.get("link", "#")
|
|
|
140 |
|
|
|
141 |
formatted_results.append(
|
142 |
-
f"
|
143 |
-
f"
|
144 |
-
f"
|
|
|
145 |
)
|
146 |
|
147 |
print(f"๊ฒ์ ๊ฒฐ๊ณผ {len(organic_results)}๊ฐ ์ฐพ์")
|
@@ -158,7 +161,7 @@ def create_deepseek_interface():
|
|
158 |
elif "message" in search_results:
|
159 |
error_msg = search_results["message"]
|
160 |
|
161 |
-
return f"๊ฒ์์ด '{search_query}'์ ๋ํ
|
162 |
|
163 |
except Exception as e:
|
164 |
error_msg = f"๊ฒ์ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
@@ -166,12 +169,13 @@ def create_deepseek_interface():
|
|
166 |
import traceback
|
167 |
print(traceback.format_exc())
|
168 |
|
169 |
-
# ๋๋ฒ๊น
๋ชฉ์ ์ผ๋ก API ์์ฒญ ์์ธ ์ ๋ณด ์ถ๊ฐ
|
170 |
-
return f"
|
171 |
-
f"
|
172 |
-
f"
|
173 |
-
f"-
|
174 |
-
f"-
|
|
|
175 |
|
176 |
# ์คํธ๋ฆฌ๋ฐ ๋ฐฉ์์ผ๋ก DeepSeek API ํธ์ถ ํจ์
|
177 |
def query_deepseek_streaming(message, history, use_deep_research):
|
|
|
108 |
# ์๋ต ๊ตฌ์กฐ ํ์ธ
|
109 |
print(f"์๋ต ๊ตฌ์กฐ: {list(search_results.keys()) if isinstance(search_results, dict) else '๋์
๋๋ฆฌ ์๋'}")
|
110 |
|
111 |
+
# ๊ฒ์ ๊ฒฐ๊ณผ ํ์ฑ ๋ฐ ํฌ๋งทํ
(Markdown ํ์์ผ๋ก ์ถ๋ ฅ)
|
112 |
formatted_results = []
|
113 |
+
formatted_results.append(f"## ๊ฒ์์ด: {search_query}\n\n")
|
114 |
|
115 |
# ๋ค์ํ ๊ฐ๋ฅํ ์๋ต ๊ตฌ์กฐ์ ๋ํ ์ฒ๋ฆฌ
|
116 |
organic_results = None
|
|
|
133 |
# ์๋ต ๊ตฌ์กฐ ์ถ๋ ฅ
|
134 |
print(f"์ฒซ๋ฒ์งธ organic ๊ฒฐ๊ณผ ๊ตฌ์กฐ: {organic_results[0].keys() if len(organic_results) > 0 else 'empty'}")
|
135 |
|
136 |
+
for i, result in enumerate(organic_results[:5], 1): # ์์ 5๊ฐ ๊ฒฐ๊ณผ๋ง ํ์
|
137 |
title = result.get("title", "์ ๋ชฉ ์์")
|
138 |
snippet = result.get("snippet", "๋ด์ฉ ์์")
|
139 |
link = result.get("link", "#")
|
140 |
+
displayed_link = result.get("displayed_link", link)
|
141 |
|
142 |
+
# Markdown ํ์์ผ๋ก ์ถ๋ ฅ (๋ฒํธ ๋ฐ ๋งํฌ ํฌํจ)
|
143 |
formatted_results.append(
|
144 |
+
f"### {i}. [{title}]({link})\n\n"
|
145 |
+
f"{snippet}\n\n"
|
146 |
+
f"**์ถ์ฒ**: [{displayed_link}]({link})\n\n"
|
147 |
+
f"---\n\n"
|
148 |
)
|
149 |
|
150 |
print(f"๊ฒ์ ๊ฒฐ๊ณผ {len(organic_results)}๊ฐ ์ฐพ์")
|
|
|
161 |
elif "message" in search_results:
|
162 |
error_msg = search_results["message"]
|
163 |
|
164 |
+
return f"## ๊ฒ์์ด '{search_query}'์ ๋ํ ๊ฒฐ๊ณผ\n\n{error_msg}"
|
165 |
|
166 |
except Exception as e:
|
167 |
error_msg = f"๊ฒ์ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
|
|
169 |
import traceback
|
170 |
print(traceback.format_exc())
|
171 |
|
172 |
+
# ๋๋ฒ๊น
๋ชฉ์ ์ผ๋ก API ์์ฒญ ์์ธ ์ ๋ณด ์ถ๊ฐ (Markdown ํ์)
|
173 |
+
return f"## ์ค๋ฅ ๋ฐ์\n\n" + \
|
174 |
+
f"๊ฒ์ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: **{str(e)}**\n\n" + \
|
175 |
+
f"### API ์์ฒญ ์์ธ ์ ๋ณด:\n" + \
|
176 |
+
f"- **URL**: {url}\n" + \
|
177 |
+
f"- **๊ฒ์์ด**: {search_query}\n" + \
|
178 |
+
f"- **ํ๋ผ๋ฏธํฐ**: {params}\n"
|
179 |
|
180 |
# ์คํธ๋ฆฌ๋ฐ ๋ฐฉ์์ผ๋ก DeepSeek API ํธ์ถ ํจ์
|
181 |
def query_deepseek_streaming(message, history, use_deep_research):
|