abhidgp1978 commited on
Commit
11e2419
Β·
verified Β·
1 Parent(s): 84258f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -4,7 +4,7 @@ import json
4
  import os
5
  import re
6
  import requests
7
- from memory_store import log_chat, build_or_update_index, LOG_FILE
8
 
9
  GOOGLE_API_KEY = "AIzaSyCgOaCQEVvOuNtZhOkrmcnqzuiiPDA6b1Q" # πŸ” Replace this
10
  SEARCH_ENGINE_ID = "17357d675fc704764" # πŸ” Replace this
@@ -17,9 +17,11 @@ if os.path.exists(COURSE_DB_PATH):
17
  else:
18
  linkedin_courses = []
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
 
@@ -81,7 +83,7 @@ def course_agent(profession, query):
81
 
82
  # === Combined UI ===
83
  with gr.Blocks(title="🧠 AI Course Finder with Memory") as demo:
84
- gr.Markdown("## πŸ“š Smart Agent with FAISS + Logging")
85
 
86
  with gr.Tab("πŸ” Course Finder"):
87
  with gr.Row():
 
4
  import os
5
  import re
6
  import requests
7
+ from memory_store import log_chat, build_or_update_index, LOG_FILE, search_similar
8
 
9
  GOOGLE_API_KEY = "AIzaSyCgOaCQEVvOuNtZhOkrmcnqzuiiPDA6b1Q" # πŸ” Replace this
10
  SEARCH_ENGINE_ID = "17357d675fc704764" # πŸ” Replace this
 
17
  else:
18
  linkedin_courses = []
19
 
20
+ # === Free-form Chat Function (RAG-based) ===
21
  def chat_with_user(message, history):
22
+ retrieved = search_similar(message)
23
+ context = "\n".join([f"β€’ {r}" for r in retrieved]) if retrieved else "(no relevant context found)"
24
+ answer = f"Based on your query, here's what I found:\n{context}"
25
  log_chat(message, answer)
26
  return history + [(message, answer)], ""
27
 
 
83
 
84
  # === Combined UI ===
85
  with gr.Blocks(title="🧠 AI Course Finder with Memory") as demo:
86
+ gr.Markdown("## πŸ“š Smart Agent with FAISS + Logging + RAG")
87
 
88
  with gr.Tab("πŸ” Course Finder"):
89
  with gr.Row():