Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2042,51 +2042,15 @@ IMPORTANT: Give only ONE response per user input. Do not repeat yourself or give
|
|
2042 |
print("[REALTIME API] Connection closed")
|
2043 |
|
2044 |
|
2045 |
-
#
|
2046 |
-
|
2047 |
-
"""Factory function to create new handler with latest settings"""
|
2048 |
-
# 가장 최근의 설정 가져오기
|
2049 |
-
if connection_settings:
|
2050 |
-
recent_ids = sorted(connection_settings.keys(),
|
2051 |
-
key=lambda k: connection_settings[k].get('timestamp', 0),
|
2052 |
-
reverse=True)
|
2053 |
-
if recent_ids:
|
2054 |
-
recent_id = recent_ids[0]
|
2055 |
-
settings = connection_settings[recent_id]
|
2056 |
-
|
2057 |
-
memories = settings.get('memories', {})
|
2058 |
-
|
2059 |
-
# 메모리가 없으면 DB에서 직접 로드 (동기적으로)
|
2060 |
-
if not memories:
|
2061 |
-
import asyncio
|
2062 |
-
loop = asyncio.new_event_loop()
|
2063 |
-
asyncio.set_event_loop(loop)
|
2064 |
-
memories_list = loop.run_until_complete(PersonalAssistantDB.get_all_memories())
|
2065 |
-
loop.close()
|
2066 |
-
|
2067 |
-
# 메모리를 카테고리별로 그룹화
|
2068 |
-
for memory in memories_list:
|
2069 |
-
category = memory['category']
|
2070 |
-
if category not in memories:
|
2071 |
-
memories[category] = []
|
2072 |
-
memories[category].append(memory['content'])
|
2073 |
-
|
2074 |
-
return OpenAIHandler(
|
2075 |
-
web_search_enabled=settings.get('web_search_enabled', False),
|
2076 |
-
webrtc_id=recent_id,
|
2077 |
-
session_id=settings.get('session_id'),
|
2078 |
-
user_name=settings.get('user_name', ''),
|
2079 |
-
memories=memories
|
2080 |
-
)
|
2081 |
-
|
2082 |
-
return OpenAIHandler(web_search_enabled=False)
|
2083 |
|
2084 |
# Create components
|
2085 |
chatbot = gr.Chatbot(type="messages")
|
2086 |
|
2087 |
-
# Create stream with
|
2088 |
stream = Stream(
|
2089 |
-
|
2090 |
mode="send-receive",
|
2091 |
modality="audio",
|
2092 |
additional_inputs=[chatbot],
|
|
|
2042 |
print("[REALTIME API] Connection closed")
|
2043 |
|
2044 |
|
2045 |
+
# Create initial handler instance
|
2046 |
+
handler = OpenAIHandler(web_search_enabled=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2047 |
|
2048 |
# Create components
|
2049 |
chatbot = gr.Chatbot(type="messages")
|
2050 |
|
2051 |
+
# Create stream with handler instance
|
2052 |
stream = Stream(
|
2053 |
+
handler,
|
2054 |
mode="send-receive",
|
2055 |
modality="audio",
|
2056 |
additional_inputs=[chatbot],
|