Upload app.py
Browse files
app.py
CHANGED
@@ -843,21 +843,18 @@ with gr.Blocks(css=custom_css, theme="soft", title="Trek Asistanı") as demo:
|
|
843 |
elem_id="msg-input"
|
844 |
)
|
845 |
|
846 |
-
# Session state
|
847 |
-
session_state = gr.State({})
|
848 |
|
849 |
-
def respond(message, chat_history
|
850 |
if not message.strip():
|
851 |
-
return "", chat_history
|
852 |
|
853 |
-
#
|
854 |
-
if not
|
855 |
-
#
|
856 |
-
session_id = str(uuid.uuid4())[:8] + hashlib.md5(str(time.time()).encode()).hexdigest()[:8]
|
857 |
-
session_state = {'session_id': session_id}
|
858 |
|
859 |
# Session ID'yi chatbot_fn'e geç
|
860 |
-
chatbot_fn._current_session_id =
|
861 |
|
862 |
# Chat history'yi chatbot_fn için uygun formata çevir
|
863 |
formatted_history = []
|
@@ -882,7 +879,7 @@ with gr.Blocks(css=custom_css, theme="soft", title="Trek Asistanı") as demo:
|
|
882 |
|
883 |
# Profile kaydetme chatbot_fn içinde yapılıyor, burada duplikasyon yok
|
884 |
|
885 |
-
return "", chat_history
|
886 |
|
887 |
except Exception as e:
|
888 |
error_msg = f"Üzgünüm, bir hata oluştu: {str(e)}"
|
@@ -890,9 +887,9 @@ with gr.Blocks(css=custom_css, theme="soft", title="Trek Asistanı") as demo:
|
|
890 |
if chat_history is None:
|
891 |
chat_history = []
|
892 |
chat_history.append((message, error_msg))
|
893 |
-
return "", chat_history
|
894 |
|
895 |
-
msg.submit(respond, [msg, chatbot
|
896 |
|
897 |
if __name__ == "__main__":
|
898 |
demo.launch(debug=True)
|
|
|
843 |
elem_id="msg-input"
|
844 |
)
|
845 |
|
846 |
+
# Session state kaldırıldı - basit yöntem kullanılıyor
|
|
|
847 |
|
848 |
+
def respond(message, chat_history):
|
849 |
if not message.strip():
|
850 |
+
return "", chat_history
|
851 |
|
852 |
+
# Basit session ID sistemi - her kullanıcı için sabit ID
|
853 |
+
if not hasattr(respond, '_user_session_id'):
|
854 |
+
respond._user_session_id = str(uuid.uuid4())[:12] # Oturum boyunca sabit ID
|
|
|
|
|
855 |
|
856 |
# Session ID'yi chatbot_fn'e geç
|
857 |
+
chatbot_fn._current_session_id = respond._user_session_id
|
858 |
|
859 |
# Chat history'yi chatbot_fn için uygun formata çevir
|
860 |
formatted_history = []
|
|
|
879 |
|
880 |
# Profile kaydetme chatbot_fn içinde yapılıyor, burada duplikasyon yok
|
881 |
|
882 |
+
return "", chat_history
|
883 |
|
884 |
except Exception as e:
|
885 |
error_msg = f"Üzgünüm, bir hata oluştu: {str(e)}"
|
|
|
887 |
if chat_history is None:
|
888 |
chat_history = []
|
889 |
chat_history.append((message, error_msg))
|
890 |
+
return "", chat_history
|
891 |
|
892 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
893 |
|
894 |
if __name__ == "__main__":
|
895 |
demo.launch(debug=True)
|