Wajahat698 commited on
Commit
81f21fe
·
verified ·
1 Parent(s): 81933f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -30
app.py CHANGED
@@ -1175,7 +1175,7 @@ def cache_response(query, response, ttl=3600):
1175
 
1176
 
1177
  tavily_tool = TavilySearchResults(
1178
- max_results=7,
1179
  search_depth="basic",
1180
  include_answer=True,
1181
  include_raw_content=False,
@@ -1187,38 +1187,10 @@ tavily_tool = TavilySearchResults(
1187
  # args_schema=..., # overwrite default args_schema: BaseModel
1188
  )
1189
 
1190
- class CachedTavilyTool:
1191
- def __init__(self, tavily_instance):
1192
- self.tavily_instance = tavily_instance
1193
-
1194
- def search(self, query):
1195
- """Perform Tavily search with caching."""
1196
- # Check for cached response
1197
- cached_response = get_cached_response(query)
1198
- if cached_response:
1199
- print("Cache hit!")
1200
- return cached_response
1201
-
1202
- # Perform Tavily search
1203
- print("Cache miss! Searching Tavily...")
1204
- try:
1205
- results = self.tavily_instance.search(query)
1206
- if not results:
1207
- return "No relevant information found."
1208
-
1209
- # Cache the results
1210
- cache_response(query, results)
1211
- return results
1212
- except Exception as e:
1213
- print(f"Error during Tavily search: {e}")
1214
- return "An error occurred while processing the Tavily search."
1215
-
1216
- # Create a cached instance of TavilyTool
1217
- cached_tavily_tool = CachedTavilyTool(tavily_tool)
1218
  # Compile all tool functions into a list
1219
  tools = [
1220
  knowledge_base_tool, # Tool for querying the knowledge base and retrieving responses
1221
- cached_tavily_tool,
1222
  # google_search_tool, # Tool for performing a Google search and retrieving search result snippets
1223
  ]
1224
 
 
1175
 
1176
 
1177
  tavily_tool = TavilySearchResults(
1178
+ max_results=4,
1179
  search_depth="basic",
1180
  include_answer=True,
1181
  include_raw_content=False,
 
1187
  # args_schema=..., # overwrite default args_schema: BaseModel
1188
  )
1189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1190
  # Compile all tool functions into a list
1191
  tools = [
1192
  knowledge_base_tool, # Tool for querying the knowledge base and retrieving responses
1193
+ tavily_tool,
1194
  # google_search_tool, # Tool for performing a Google search and retrieving search result snippets
1195
  ]
1196