KaiserShultz commited on
Commit
22e2721
·
verified ·
1 Parent(s): b8c382c

Update src/tools/tools.py

Browse files
Files changed (1) hide show
  1. src/tools/tools.py +14 -5
src/tools/tools.py CHANGED
@@ -365,7 +365,11 @@ def arxiv_search(
365
 
366
 
367
  @tool
368
- def web_extract(urls : List[str]) -> str:
 
 
 
 
369
  """
370
  Extract text content from web pages using TavilyExtract.
371
 
@@ -377,14 +381,19 @@ def web_extract(urls : List[str]) -> str:
377
  include_images (bool) – add image URLs if True
378
  extract_depth (str) – "basic" (default) or "advanced"
379
  """
 
 
 
380
 
381
  tool = TavilyExtract(
382
- extract_depth="basic",
383
- include_images=False,
384
- )
385
- results = tool.invoke(urls)
 
386
  return json.dumps(results)
387
 
 
388
  @tool
389
  def extract_youtube_transcript(url: str, chars: int = 10_00) -> str:
390
  """
 
365
 
366
 
367
  @tool
368
+ def web_extract(
369
+ urls: List[str] | str,
370
+ include_images: bool = False,
371
+ extract_depth: str = "basic",
372
+ ) -> str:
373
  """
374
  Extract text content from web pages using TavilyExtract.
375
 
 
381
  include_images (bool) – add image URLs if True
382
  extract_depth (str) – "basic" (default) or "advanced"
383
  """
384
+ # нормализуем вход
385
+ if isinstance(urls, str):
386
+ urls = [urls]
387
 
388
  tool = TavilyExtract(
389
+ extract_depth=extract_depth,
390
+ include_images=include_images,
391
+ )
392
+ # ВАЖНО: .invoke ждёт словарь по схеме TavilyExtractInput
393
+ results = tool.invoke({"urls": urls})
394
  return json.dumps(results)
395
 
396
+
397
  @tool
398
  def extract_youtube_transcript(url: str, chars: int = 10_00) -> str:
399
  """