Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,10 +6,8 @@ import re
|
|
| 6 |
import requests
|
| 7 |
from memory_store import log_chat, build_or_update_index, LOG_FILE
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
GOOGLE_API_KEY = "AIzaSyCgOaCQEVvOuNtZhOkrmcnqzuiiPDA6b1Q" # π Replace this
|
| 12 |
-
SEARCH_ENGINE_ID = "17357d675fc704764" # π Replace this
|
| 13 |
COURSE_DB_PATH = "mock_courses.json"
|
| 14 |
|
| 15 |
# === Load Course Data ===
|
|
@@ -21,11 +19,9 @@ else:
|
|
| 21 |
|
| 22 |
# === Free-form Chat Function ===
|
| 23 |
def chat_with_user(message, history):
|
| 24 |
-
answer = f"Echo: {message}"
|
| 25 |
log_chat(message, answer)
|
| 26 |
-
history
|
| 27 |
-
history.append({"role": "assistant", "content": answer})
|
| 28 |
-
return history, ""
|
| 29 |
|
| 30 |
# === Keyword extraction ===
|
| 31 |
def extract_keywords(text):
|
|
@@ -99,9 +95,12 @@ with gr.Blocks(title="π§ AI Course Finder with Memory") as demo:
|
|
| 99 |
search_btn.click(fn=course_agent, inputs=[profession, query], outputs=result_box)
|
| 100 |
|
| 101 |
with gr.Tab("π¬ Chat"):
|
| 102 |
-
chatbot = gr.Chatbot(label="Chat"
|
| 103 |
txt = gr.Textbox(show_label=False, placeholder="Type your message...")
|
| 104 |
-
|
|
|
|
|
|
|
| 105 |
txt.submit(fn=chat_with_user, inputs=[txt, chatbot], outputs=[chatbot, txt])
|
|
|
|
| 106 |
|
| 107 |
demo.launch()
|
|
|
|
| 6 |
import requests
|
| 7 |
from memory_store import log_chat, build_or_update_index, LOG_FILE
|
| 8 |
|
| 9 |
+
GOOGLE_API_KEY = "" # π Replace this
|
| 10 |
+
SEARCH_ENGINE_ID = "" # π Replace this
|
|
|
|
|
|
|
| 11 |
COURSE_DB_PATH = "mock_courses.json"
|
| 12 |
|
| 13 |
# === Load Course Data ===
|
|
|
|
| 19 |
|
| 20 |
# === Free-form Chat Function ===
|
| 21 |
def chat_with_user(message, history):
|
| 22 |
+
answer = f"Echo: {message}"
|
| 23 |
log_chat(message, answer)
|
| 24 |
+
return history + [(message, answer)], ""
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# === Keyword extraction ===
|
| 27 |
def extract_keywords(text):
|
|
|
|
| 95 |
search_btn.click(fn=course_agent, inputs=[profession, query], outputs=result_box)
|
| 96 |
|
| 97 |
with gr.Tab("π¬ Chat"):
|
| 98 |
+
chatbot = gr.Chatbot(label="Chat")
|
| 99 |
txt = gr.Textbox(show_label=False, placeholder="Type your message...")
|
| 100 |
+
log_display = gr.File(label="β¬οΈ Download Logs", interactive=True)
|
| 101 |
+
refresh = gr.Button("π Refresh Logs")
|
| 102 |
+
|
| 103 |
txt.submit(fn=chat_with_user, inputs=[txt, chatbot], outputs=[chatbot, txt])
|
| 104 |
+
refresh.click(fn=lambda: LOG_FILE, outputs=log_display)
|
| 105 |
|
| 106 |
demo.launch()
|