Nancy1906 commited on
Commit
b710608
·
verified ·
1 Parent(s): 9f2d9f0
Files changed (1) hide show
  1. my_tools.py +1 -26
my_tools.py CHANGED
@@ -20,7 +20,7 @@ from llama_index.core.callbacks.llama_debug import LlamaDebugHandler
20
 
21
  from langchain_community.retrievers import TavilySearchAPIRetriever
22
  from llama_index.core.schema import Document
23
- from app.utils.search_utils import search_cache, add_documents_with_filtered_metadata
24
 
25
 
26
  # -------------------------------------------------------------------
@@ -168,31 +168,6 @@ class GeminiLLM(LLM):
168
  # -------------------------------------------------------------------
169
  # 3) HERRAMIENTAS PERSONALIZADAS
170
  # -------------------------------------------------------------------
171
- def retrieve_with_fallback(query):
172
- cached_results = search_cache.search(query)
173
-
174
- if cached_results:
175
- print(f"✅ Retrieved {len(cached_results)} documents from cache")
176
- return format_docs(cached_results)
177
-
178
- print("🔍 No cache hit, performing web search")
179
-
180
- retriever = TavilySearchAPIRetriever(api_key=os.getenv("TAVILY_API_KEY"), k=5)
181
- search_results = retriever.invoke(query)
182
-
183
- docs = []
184
- for result in search_results:
185
- if isinstance(result, Document):
186
- docs.append(result)
187
- else:
188
- docs.append(Document(page_content=result))
189
-
190
- add_documents_with_filtered_metadata(search_cache, docs)
191
-
192
- return format_docs(docs)
193
-
194
-
195
-
196
  HEADERS = {'User-Agent': 'Mozilla/5.0'}
197
 
198
  def buscar_web(query, num_results=5):
 
20
 
21
  from langchain_community.retrievers import TavilySearchAPIRetriever
22
  from llama_index.core.schema import Document
23
+
24
 
25
 
26
  # -------------------------------------------------------------------
 
168
  # -------------------------------------------------------------------
169
  # 3) HERRAMIENTAS PERSONALIZADAS
170
  # -------------------------------------------------------------------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  HEADERS = {'User-Agent': 'Mozilla/5.0'}
172
 
173
  def buscar_web(query, num_results=5):