Wajahat698 commited on
Commit
0a17c97
·
verified ·
1 Parent(s): e3364d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1014,7 +1014,7 @@ def search_knowledge_base(query):
1014
  def google_search(query):
1015
  try:
1016
  # Initialize the search client and parameters
1017
- search_client = serpapi.Client(api_key=serper_api_key)
1018
  search_params = {
1019
  "engine": "google",
1020
  "q": query,
@@ -1032,18 +1032,21 @@ def google_search(query):
1032
  link = result.get("link", "")
1033
  snippet = result.get("snippet", "")
1034
 
1035
- # Ensure proper Markdown formatting with only "Source" as the clickable text
1036
- if link.startswith("http"):
1037
- formatted_results.append(f"{snippet} - [Source]({link})")
 
 
1038
 
1039
  if formatted_results:
1040
  return formatted_results
1041
  return ["No valid links found"]
1042
 
1043
  except Exception as e:
1044
- logger.error(f"Error in Google search: {e}")
1045
  return ["Error occurred during Google search"]
1046
 
 
1047
  # RAG response function
1048
  def rag_response(query):
1049
  """
 
1014
  def google_search(query):
1015
  try:
1016
  # Initialize the search client and parameters
1017
+ search_client = Client(api_key=serper_api_key)
1018
  search_params = {
1019
  "engine": "google",
1020
  "q": query,
 
1032
  link = result.get("link", "")
1033
  snippet = result.get("snippet", "")
1034
 
1035
+ # Skip any results that are from visionaustralia.org
1036
+ if "visionaustralia.org" not in link:
1037
+ # Ensure proper Markdown formatting with only "Source" as the clickable text
1038
+ if link.startswith("http"):
1039
+ formatted_results.append(f"{snippet} - [Source]({link})")
1040
 
1041
  if formatted_results:
1042
  return formatted_results
1043
  return ["No valid links found"]
1044
 
1045
  except Exception as e:
1046
+ print(f"Error in Google search: {e}")
1047
  return ["Error occurred during Google search"]
1048
 
1049
+
1050
  # RAG response function
1051
  def rag_response(query):
1052
  """