Wajahat698 commited on
Commit
c253389
·
verified ·
1 Parent(s): 29dc65c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -52
app.py CHANGED
@@ -1102,46 +1102,7 @@ def search_knowledge_base(query):
1102
 
1103
 
1104
  # Function to perform an advanced Google search using SERP API
1105
- def brave_search(query, api_key="BSA8wB9NbA2fM76yt0lnU7OEpTQhAm6", max_results=12, search_depth="advanced", days=3, include_answer=True, include_raw_content=True, exclude_domains=None):
1106
- """
1107
- Perform a search using the Brave Search API.
1108
-
1109
- Args:
1110
- query (str): The search query string.
1111
- api_key (str): Your Brave Search API key.
1112
- max_results (int): Maximum number of results to retrieve.
1113
- search_depth (str): Search depth ("basic" or "advanced").
1114
- days (int): Limit results to the past specified days.
1115
- include_answer (bool): Include direct answers in the response.
1116
- include_raw_content (bool): Include raw content in the response.
1117
- exclude_domains (list): List of domains to exclude from the results.
1118
-
1119
- Returns:
1120
- dict: Parsed search results from the Brave Search API.
1121
- """
1122
- url = "https://api.search.brave.com/res/v1/web/search?q=brave+search"
1123
- headers = {
1124
- "Authorization": f"Bearer {api_key}",
1125
- "Content-Type": "application/json",
1126
- }
1127
 
1128
- # Payload to customize the search
1129
- payload = {
1130
- "q": query,
1131
- "count": max_results,
1132
- "search_depth": search_depth,
1133
- "days": days,
1134
- "include_answer": include_answer,
1135
- "include_raw_content": include_raw_content,
1136
- }
1137
-
1138
- if exclude_domains:
1139
- payload["exclude_domains"] = exclude_domains
1140
-
1141
- # Make the API request
1142
- response = requests.post(url, json=payload, headers=headers)
1143
- response.raise_for_status() # Raise an exception for HTTP errors
1144
- return response.json()
1145
 
1146
 
1147
 
@@ -1234,24 +1195,25 @@ def cache_response(query, response, ttl=3600):
1234
 
1235
 
1236
 
1237
- # tavily_tool = TavilySearchResults(
1238
- # max_results=12,
1239
- # search_depth="advanced",
1240
- # days=3,
1241
- # include_answer=True,
1242
- # include_raw_content=True,
1243
- # # include_domains=[...],
1244
- # exclude_domains=['example.com'],
1245
- # # name="...", # overwrite default tool name
1246
- # # description="...", # overwrite default tool description
1247
- # # args_schema=..., # overwrite default args_schema: BaseModel
1248
- # )#
1249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1250
 
1251
  #Compile all tool functions into a list
1252
  tools = [
1253
  knowledge_base_tool, # Tool for querying the knowledge base and retrieving responses
1254
- google_search_tool,
1255
  #google_search_tool, # Tool for performing a Google search and retrieving search result snippets
1256
  ]
1257
 
 
1102
 
1103
 
1104
  # Function to perform an advanced Google search using SERP API
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1106
 
1107
 
1108
 
 
1195
 
1196
 
1197
 
 
 
 
 
 
 
 
 
 
 
 
 
1198
 
1199
+ tavily_tool = TavilySearchResults(
1200
+ max_results=12,
1201
+ search_depth="advanced",
1202
+ topic="news",
1203
+ days=1,
1204
+ include_answer=True,
1205
+ include_raw_content=True,
1206
+ # include_domains=[...],
1207
+ exclude_domains=['example.com'],
1208
+ # name="...", # overwrite default tool name
1209
+ # description="...", # overwrite default tool description
1210
+ # args_schema=..., # overwrite default args_schema: BaseModel
1211
+ )
1212
 
1213
  #Compile all tool functions into a list
1214
  tools = [
1215
  knowledge_base_tool, # Tool for querying the knowledge base and retrieving responses
1216
+ tavily_tool,
1217
  #google_search_tool, # Tool for performing a Google search and retrieving search result snippets
1218
  ]
1219