abhidgp1978 commited on
Commit
60925ed
Β·
verified Β·
1 Parent(s): 7325046

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
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
- # === CONFIG ===
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}" # Replace with your logic
25
  log_chat(message, answer)
26
- history.append({"role": "user", "content": message})
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", type="messages")
103
  txt = gr.Textbox(show_label=False, placeholder="Type your message...")
104
- download_logs = gr.File(label="⬇️ Download Logs", value=LOG_FILE, interactive=True)
 
 
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()