im commited on
Commit ·
08607af
1
Parent(s): 3a120e2
refinements
Browse files
tool.py
CHANGED
|
@@ -9,42 +9,42 @@ import streamlit as st
|
|
| 9 |
|
| 10 |
|
| 11 |
#TODO: replace search with something else
|
| 12 |
-
client = Metaphor(api_key=st.secrets["METAPHOR_API_KEY"])
|
| 13 |
-
|
| 14 |
-
@tool
|
| 15 |
-
def search(query: str, num_results: Optional[int] = None, include_domains: Optional[List[str]] = None, exclude_domains: Optional[List[str]] = None):
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
@tool
|
| 27 |
-
def get_contents(ids: List[str]):
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
@tool
|
| 39 |
-
def find_similar(url: str, num_results: Optional[int] = None, include_domains: Optional[List[str]] = None, exclude_domains: Optional[List[str]] = None):
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
|
| 49 |
|
| 50 |
crawling_api_key = st.secrets["CRAWLING_API_KEY"]
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
#TODO: replace search with something else
|
| 12 |
+
# client = Metaphor(api_key=st.secrets["METAPHOR_API_KEY"])
|
| 13 |
+
#
|
| 14 |
+
# @tool
|
| 15 |
+
# def search(query: str, num_results: Optional[int] = None, include_domains: Optional[List[str]] = None, exclude_domains: Optional[List[str]] = None):
|
| 16 |
+
# """Call search engine with a query """
|
| 17 |
+
# try:
|
| 18 |
+
# result = client.search(query, use_autoprompt=True, num_results=num_results, include_domains=include_domains, exclude_domains=exclude_domains)
|
| 19 |
+
# if "I'm sorry" in result.autoprompt_string:
|
| 20 |
+
# raise Exception(result.autoprompt_string)
|
| 21 |
+
# return result
|
| 22 |
+
# except Exception as e:
|
| 23 |
+
# raise ToolException(e.args[0])
|
| 24 |
+
#
|
| 25 |
+
#
|
| 26 |
+
# @tool
|
| 27 |
+
# def get_contents(ids: List[str]):
|
| 28 |
+
# """Get contents of a webpage. May return an empty content, it means you have to use another tool to get the content.
|
| 29 |
+
#
|
| 30 |
+
# The ids passed in should be a list of ids as fetched from `search`.
|
| 31 |
+
# """
|
| 32 |
+
# try:
|
| 33 |
+
# return client.get_contents(ids)
|
| 34 |
+
# except Exception as e:
|
| 35 |
+
# raise ToolException(e.args[0])
|
| 36 |
+
#
|
| 37 |
+
#
|
| 38 |
+
# @tool
|
| 39 |
+
# def find_similar(url: str, num_results: Optional[int] = None, include_domains: Optional[List[str]] = None, exclude_domains: Optional[List[str]] = None):
|
| 40 |
+
# """Get search results similar to a given URL.
|
| 41 |
+
#
|
| 42 |
+
# The url passed in should be a URL returned from `search`
|
| 43 |
+
# """
|
| 44 |
+
# try:
|
| 45 |
+
# return client.find_similar(url, num_results=num_results, include_domains=include_domains, exclude_domains=exclude_domains)
|
| 46 |
+
# except Exception as e:
|
| 47 |
+
# raise ToolException(e.args[0])
|
| 48 |
|
| 49 |
|
| 50 |
crawling_api_key = st.secrets["CRAWLING_API_KEY"]
|