Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -113,13 +113,13 @@ async def generate_response(message):
|
|
113 |
# Google Custom Search ์คํ
|
114 |
search_results = google_search(user_input)
|
115 |
|
116 |
-
conversation_history.append({"role": "user", "content": user_input})
|
117 |
-
logging.debug(f'Conversation history updated: {conversation_history}')
|
118 |
-
|
119 |
messages = [
|
120 |
{"role": "system", "content": f"{system_prefix} {system_message}"},
|
121 |
{"role": "user", "content": f"์ฌ์ฉ์ ์ง๋ฌธ: {user_input}\n\n๊ฒ์ ๊ฒฐ๊ณผ:\n{search_results}"}
|
122 |
-
]
|
|
|
|
|
|
|
123 |
|
124 |
logging.debug(f'Messages to be sent to the model: {messages}')
|
125 |
|
@@ -136,8 +136,15 @@ async def generate_response(message):
|
|
136 |
full_response_text = ''.join(full_response)
|
137 |
logging.debug(f'Full model response: {full_response_text}')
|
138 |
|
|
|
|
|
139 |
conversation_history.append({"role": "assistant", "content": full_response_text})
|
140 |
|
|
|
|
|
|
|
|
|
|
|
141 |
return f"{user_mention}, {full_response_text}"
|
142 |
|
143 |
if __name__ == "__main__":
|
|
|
113 |
# Google Custom Search ์คํ
|
114 |
search_results = google_search(user_input)
|
115 |
|
|
|
|
|
|
|
116 |
messages = [
|
117 |
{"role": "system", "content": f"{system_prefix} {system_message}"},
|
118 |
{"role": "user", "content": f"์ฌ์ฉ์ ์ง๋ฌธ: {user_input}\n\n๊ฒ์ ๊ฒฐ๊ณผ:\n{search_results}"}
|
119 |
+
]
|
120 |
+
|
121 |
+
# ์ด์ ๋ํ ํ์คํ ๋ฆฌ ์ถ๊ฐ
|
122 |
+
messages.extend(conversation_history)
|
123 |
|
124 |
logging.debug(f'Messages to be sent to the model: {messages}')
|
125 |
|
|
|
136 |
full_response_text = ''.join(full_response)
|
137 |
logging.debug(f'Full model response: {full_response_text}')
|
138 |
|
139 |
+
# ๋ํ ํ์คํ ๋ฆฌ ์
๋ฐ์ดํธ
|
140 |
+
conversation_history.append({"role": "user", "content": user_input})
|
141 |
conversation_history.append({"role": "assistant", "content": full_response_text})
|
142 |
|
143 |
+
# ๋ํ ํ์คํ ๋ฆฌ ๊ธธ์ด ์ ํ (์: ์ต๊ทผ 10๊ฐ ๋ฉ์์ง๋ง ์ ์ง)
|
144 |
+
conversation_history = conversation_history[-10:]
|
145 |
+
|
146 |
+
logging.debug(f'Conversation history updated: {conversation_history}')
|
147 |
+
|
148 |
return f"{user_mention}, {full_response_text}"
|
149 |
|
150 |
if __name__ == "__main__":
|