8000 fix: tavily/obot search: add time_range parameter by g-linville · Pull Request #645 · obot-platform/tools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: tavily/obot search: add time_range parameter #645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions search/tavily/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,23 @@ def main():
if os.getenv("MAX_RESULTS", "").strip():
max_results = int(os.getenv("MAX_RESULTS")) # override with env var

response = client.search(
query=query,
include_answer=os.getenv("INCLUDE_ANSWER", "").lower()
== "true", # no LLM-generated answer needed by default - we'll do that
include_raw_content=os.getenv("INCLUDE_RAW_CONTENT", "").lower()
!= "false", # include raw content by default
max_results=max_results,
include_domains=include_domains,
)
time_range = os.getenv("TIME_RANGE", "").lower().strip()
if time_range not in ["", "day", "week", "month", "year"]:
print("Invalid time range: must be day, week, month, or year")
sys.exit(1)

search_params = {
"query": query,
"include_answer": os.getenv("INCLUDE_ANSWER", "").lower() == "true", # no LLM-generated answer needed by default - we'll do that
"include_raw_content": os.getenv("INCLUDE_RAW_CONTENT", "").lower() != "false", # include raw content by default
"max_results": max_results,
"include_domains": include_domains,
}

if time_range:
search_params["time_range"] = time_range

response = client.search(**search_params)
case "extract":
client = TavilyClient() # env TAVILY_API_KEY required
url = parse_url(os.getenv("URL").strip())
Expand Down
16 changes: 16 additions & 0 deletions search/tavily/obot-search.gpt
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
---
Name: Obot Search
Description: Search the web with Obot. This returns a list of search results scored by relevance to the query and summarized.
Share Context: Obot Search Context
Credential: ./credential
Param: query: The search query
Param: time_range: (Optional) the time range to search in. Value must be exactly "day", "week", "month", or "year".

#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py search

---
Name: Obot Search Context
Type: context

#!sys.echo

# Instructions for using Obot Search

The `time_range` parameter should only be used when you know that you will get better or more accurate search results by using it.
Examples of when using it might be appropriate include getting some statistic that fluctuates by the day, such as a stock price or currency conversion rate.
Do not use it for information that remains relatively constant over time.

# End of instructions for using Obot Search

---
!metadata:*:icon
/admin/assets/obot_search_icon.png
1 change: 1 addition & 0 deletions search/tavily/tool.gpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Credential: ./credential
Share Context: Tavily Context
Param: query: The search query
Param: includeDomains: A comma-separated list of domains to specifically include in the search
Param: time_range: (Optional) the time range to search in. Value must be exactly "day", "week", "month", or "year".

#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py search

Expand Down
Loading
0