Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -421,134 +421,131 @@ with gr.Blocks(title="Tavily Search API", theme=gr.themes.Soft()) as app:
|
|
421 |
**Available countries**: afghanistan, albania, algeria, andorra, angola, argentina, armenia, australia, austria, azerbaijan, bahamas, bahrain, bangladesh, barbados, belarus, belgium, belize, benin, bhutan, bolivia, bosnia and herzegovina, botswana, brazil, brunei, bulgaria, burkina faso, burundi, cambodia, cameroon, canada, cape verde, central african republic, chad, chile, china, colombia, comoros, congo, costa rica, croatia, cuba, cyprus, czech republic, denmark, djibouti, dominican republic, ecuador, egypt, el salvador, equatorial guinea, eritrea, estonia, ethiopia, fiji, finland, france, gabon, gambia, georgia, germany, ghana, greece, guatemala, guinea, haiti, honduras, hungary, iceland, india, indonesia, iran, iraq, ireland, israel, italy, jamaica, japan, jordan, kazakhstan, kenya, kuwait, kyrgyzstan, latvia, lebanon, lesotho, liberia, libya, liechtenstein, lithuania, luxembourg, madagascar, malawi, malaysia, maldives, mali, malta, mauritania, mauritius, mexico, moldova, monaco, mongolia, montenegro, morocco, mozambique, myanmar, namibia, nepal, netherlands, new zealand, nicaragua, niger, nigeria, north korea, north macedonia, norway, oman, pakistan, panama, papua new guinea, paraguay, peru, philippines, poland, portugal, qatar, romania, russia, rwanda, saudi arabia, senegal, serbia, singapore, slovakia, slovenia, somalia, south africa, south korea, south sudan, spain, sri lanka, sudan, sweden, switzerland, syria, taiwan, tajikistan, tanzania, thailand, togo, trinidad and tobago, tunisia, turkey, turkmenistan, uganda, ukraine, united arab emirates, united kingdom, united states, uruguay, uzbekistan, venezuela, vietnam, yemen, zambia, zimbabwe
|
422 |
""")
|
423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
with gr.Row():
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
type="password",
|
432 |
-
info="Your API key will be used to authenticate requests to Tavily."
|
433 |
-
)
|
434 |
-
|
435 |
-
# Search Parameters
|
436 |
-
gr.Markdown("## π― Search Parameters")
|
437 |
-
query = gr.Textbox(
|
438 |
-
label="Search Query",
|
439 |
-
placeholder="e.g., 'who is Leo Messi?'",
|
440 |
-
info="The search query you want to execute."
|
441 |
-
)
|
442 |
-
|
443 |
-
with gr.Row():
|
444 |
-
topic = gr.Dropdown(
|
445 |
-
choices=["general", "news"],
|
446 |
-
value="general",
|
447 |
-
label="Topic",
|
448 |
-
info="general: broad searches, news: real-time updates"
|
449 |
-
)
|
450 |
-
|
451 |
-
search_depth = gr.Dropdown(
|
452 |
-
choices=["basic", "advanced"],
|
453 |
-
value="basic",
|
454 |
-
label="Search Depth",
|
455 |
-
info="basic: 1 credit, advanced: 2 credits"
|
456 |
-
)
|
457 |
-
|
458 |
-
with gr.Row():
|
459 |
-
max_results = gr.Slider(
|
460 |
-
minimum=1,
|
461 |
-
maximum=20,
|
462 |
-
value=5,
|
463 |
-
step=1,
|
464 |
-
label="Max Results",
|
465 |
-
info="Maximum number of search results to return"
|
466 |
-
)
|
467 |
-
|
468 |
-
chunks_per_source = gr.Slider(
|
469 |
-
minimum=1,
|
470 |
-
maximum=3,
|
471 |
-
value=3,
|
472 |
-
step=1,
|
473 |
-
label="Chunks per Source",
|
474 |
-
info="Only applies to advanced search"
|
475 |
-
)
|
476 |
-
|
477 |
-
# Advanced Options
|
478 |
-
gr.Markdown("## βοΈ Advanced Options")
|
479 |
-
|
480 |
-
with gr.Row():
|
481 |
-
time_range = gr.Dropdown(
|
482 |
-
choices=["None", "day", "week", "month", "year"],
|
483 |
-
value="None",
|
484 |
-
label="Time Range",
|
485 |
-
info="Filter results by time period"
|
486 |
-
)
|
487 |
-
|
488 |
-
days = gr.Number(
|
489 |
-
value=7,
|
490 |
-
minimum=1,
|
491 |
-
label="Days (News only)",
|
492 |
-
info="Number of days back for news searches"
|
493 |
-
)
|
494 |
-
|
495 |
-
with gr.Row():
|
496 |
-
include_answer = gr.Checkbox(
|
497 |
-
value=True,
|
498 |
-
label="Include Answer",
|
499 |
-
info="Include LLM-generated answer"
|
500 |
-
)
|
501 |
-
|
502 |
-
include_images = gr.Checkbox(
|
503 |
-
value=False,
|
504 |
-
label="Include Images",
|
505 |
-
info="Perform image search"
|
506 |
-
)
|
507 |
-
|
508 |
-
include_image_descriptions = gr.Checkbox(
|
509 |
-
value=False,
|
510 |
-
label="Include Image Descriptions",
|
511 |
-
info="Add descriptions for images"
|
512 |
-
)
|
513 |
-
|
514 |
-
include_raw_content = gr.Dropdown(
|
515 |
-
choices=["false", "html", "markdown", "text"],
|
516 |
-
value="html",
|
517 |
-
label="Include Raw Content",
|
518 |
-
info="HTML: Clean styled format, Markdown: MD format, Text: Plain text"
|
519 |
-
)
|
520 |
-
|
521 |
-
with gr.Row():
|
522 |
-
include_domains = gr.Textbox(
|
523 |
-
label="Include Domains",
|
524 |
-
placeholder="example.com, another.com",
|
525 |
-
info="Comma-separated list of domains to include"
|
526 |
-
)
|
527 |
-
|
528 |
-
exclude_domains = gr.Textbox(
|
529 |
-
label="Exclude Domains",
|
530 |
-
placeholder="example.com, another.com",
|
531 |
-
info="Comma-separated list of domains to exclude"
|
532 |
-
)
|
533 |
-
|
534 |
-
country = gr.Dropdown(
|
535 |
-
choices=country_options,
|
536 |
-
value="None",
|
537 |
-
label="Country",
|
538 |
-
info="Boost results from specific country (general topic only)"
|
539 |
-
)
|
540 |
-
|
541 |
-
# Search Button
|
542 |
-
search_btn = gr.Button("π Search", variant="primary", size="lg")
|
543 |
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
|
553 |
# Examples
|
554 |
gr.Markdown("## π‘ Comprehensive Test Examples")
|
|
|
421 |
**Available countries**: afghanistan, albania, algeria, andorra, angola, argentina, armenia, australia, austria, azerbaijan, bahamas, bahrain, bangladesh, barbados, belarus, belgium, belize, benin, bhutan, bolivia, bosnia and herzegovina, botswana, brazil, brunei, bulgaria, burkina faso, burundi, cambodia, cameroon, canada, cape verde, central african republic, chad, chile, china, colombia, comoros, congo, costa rica, croatia, cuba, cyprus, czech republic, denmark, djibouti, dominican republic, ecuador, egypt, el salvador, equatorial guinea, eritrea, estonia, ethiopia, fiji, finland, france, gabon, gambia, georgia, germany, ghana, greece, guatemala, guinea, haiti, honduras, hungary, iceland, india, indonesia, iran, iraq, ireland, israel, italy, jamaica, japan, jordan, kazakhstan, kenya, kuwait, kyrgyzstan, latvia, lebanon, lesotho, liberia, libya, liechtenstein, lithuania, luxembourg, madagascar, malawi, malaysia, maldives, mali, malta, mauritania, mauritius, mexico, moldova, monaco, mongolia, montenegro, morocco, mozambique, myanmar, namibia, nepal, netherlands, new zealand, nicaragua, niger, nigeria, north korea, north macedonia, norway, oman, pakistan, panama, papua new guinea, paraguay, peru, philippines, poland, portugal, qatar, romania, russia, rwanda, saudi arabia, senegal, serbia, singapore, slovakia, slovenia, somalia, south africa, south korea, south sudan, spain, sri lanka, sudan, sweden, switzerland, syria, taiwan, tajikistan, tanzania, thailand, togo, trinidad and tobago, tunisia, turkey, turkmenistan, uganda, ukraine, united arab emirates, united kingdom, united states, uruguay, uzbekistan, venezuela, vietnam, yemen, zambia, zimbabwe
|
422 |
""")
|
423 |
|
424 |
+
# API Configuration
|
425 |
+
gr.Markdown("## π API Configuration")
|
426 |
+
api_key = gr.Textbox(
|
427 |
+
label="Tavily API Key",
|
428 |
+
placeholder="Enter your Tavily API key here...",
|
429 |
+
type="password",
|
430 |
+
info="Your API key will be used to authenticate requests to Tavily."
|
431 |
+
)
|
432 |
+
|
433 |
+
# Search Parameters
|
434 |
+
gr.Markdown("## π― Search Parameters")
|
435 |
+
query = gr.Textbox(
|
436 |
+
label="Search Query",
|
437 |
+
placeholder="e.g., 'who is Leo Messi?'",
|
438 |
+
info="The search query you want to execute."
|
439 |
+
)
|
440 |
+
|
441 |
with gr.Row():
|
442 |
+
topic = gr.Dropdown(
|
443 |
+
choices=["general", "news"],
|
444 |
+
value="general",
|
445 |
+
label="Topic",
|
446 |
+
info="general: broad searches, news: real-time updates"
|
447 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
|
449 |
+
search_depth = gr.Dropdown(
|
450 |
+
choices=["basic", "advanced"],
|
451 |
+
value="basic",
|
452 |
+
label="Search Depth",
|
453 |
+
info="basic: 1 credit, advanced: 2 credits"
|
454 |
+
)
|
455 |
+
|
456 |
+
with gr.Row():
|
457 |
+
max_results = gr.Slider(
|
458 |
+
minimum=1,
|
459 |
+
maximum=20,
|
460 |
+
value=5,
|
461 |
+
step=1,
|
462 |
+
label="Max Results",
|
463 |
+
info="Maximum number of search results to return"
|
464 |
+
)
|
465 |
+
|
466 |
+
chunks_per_source = gr.Slider(
|
467 |
+
minimum=1,
|
468 |
+
maximum=3,
|
469 |
+
value=3,
|
470 |
+
step=1,
|
471 |
+
label="Chunks per Source",
|
472 |
+
info="Only applies to advanced search"
|
473 |
+
)
|
474 |
+
|
475 |
+
# Advanced Options
|
476 |
+
gr.Markdown("## βοΈ Advanced Options")
|
477 |
+
|
478 |
+
with gr.Row():
|
479 |
+
time_range = gr.Dropdown(
|
480 |
+
choices=["None", "day", "week", "month", "year"],
|
481 |
+
value="None",
|
482 |
+
label="Time Range",
|
483 |
+
info="Filter results by time period"
|
484 |
+
)
|
485 |
+
|
486 |
+
days = gr.Number(
|
487 |
+
value=7,
|
488 |
+
minimum=1,
|
489 |
+
label="Days (News only)",
|
490 |
+
info="Number of days back for news searches"
|
491 |
+
)
|
492 |
+
|
493 |
+
with gr.Row():
|
494 |
+
include_answer = gr.Checkbox(
|
495 |
+
value=True,
|
496 |
+
label="Include Answer",
|
497 |
+
info="Include LLM-generated answer"
|
498 |
+
)
|
499 |
+
|
500 |
+
include_images = gr.Checkbox(
|
501 |
+
value=False,
|
502 |
+
label="Include Images",
|
503 |
+
info="Perform image search"
|
504 |
+
)
|
505 |
+
|
506 |
+
include_image_descriptions = gr.Checkbox(
|
507 |
+
value=False,
|
508 |
+
label="Include Image Descriptions",
|
509 |
+
info="Add descriptions for images"
|
510 |
+
)
|
511 |
+
|
512 |
+
include_raw_content = gr.Dropdown(
|
513 |
+
choices=["false", "html", "markdown", "text"],
|
514 |
+
value="html",
|
515 |
+
label="Include Raw Content",
|
516 |
+
info="HTML: Clean styled format, Markdown: MD format, Text: Plain text"
|
517 |
+
)
|
518 |
+
|
519 |
+
with gr.Row():
|
520 |
+
include_domains = gr.Textbox(
|
521 |
+
label="Include Domains",
|
522 |
+
placeholder="example.com, another.com",
|
523 |
+
info="Comma-separated list of domains to include"
|
524 |
+
)
|
525 |
+
|
526 |
+
exclude_domains = gr.Textbox(
|
527 |
+
label="Exclude Domains",
|
528 |
+
placeholder="example.com, another.com",
|
529 |
+
info="Comma-separated list of domains to exclude"
|
530 |
+
)
|
531 |
+
|
532 |
+
country = gr.Dropdown(
|
533 |
+
choices=country_options,
|
534 |
+
value="None",
|
535 |
+
label="Country",
|
536 |
+
info="Boost results from specific country (general topic only)"
|
537 |
+
)
|
538 |
+
|
539 |
+
# Search Button
|
540 |
+
search_btn = gr.Button("π Search", variant="primary", size="lg")
|
541 |
+
|
542 |
+
# Results Section - Moved above examples
|
543 |
+
gr.Markdown("## π Search Results")
|
544 |
+
results = gr.HTML(
|
545 |
+
label="Results",
|
546 |
+
show_label=False,
|
547 |
+
elem_id="search_results"
|
548 |
+
)
|
549 |
|
550 |
# Examples
|
551 |
gr.Markdown("## π‘ Comprehensive Test Examples")
|