MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / build_tool

Function build_tool

bmtools/tools/google_scholar/api.py:10–223  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

8
9
10def build_tool(config) -> Tool:
11 tool = Tool(
12 "Google Scholar Info",
13 "Look up google scholar information",
14 name_for_model="Google_Scholar",
15 description_for_model="Plugin for look up Google Scholar information",
16 logo_url="https://your-app-url.com/.well-known/logo.png",
17 contact_email="hello@contact.com",
18 legal_info_url="hello@legal.com"
19 )
20
21 KEY = config["subscription_key"]
22
23 @tool.get("/search_google_scholar")
24 def search_google_scholar(
25 query: str,
26 engine: str = "google_scholar",
27 cites: Optional[str] = None,
28 as_ylo: Optional[int] = None,
29 as_yhi: Optional[int] = None,
30 scisbd: Optional[int] = None,
31 cluster: Optional[str] = None,
32 hl: Optional[str] = None,
33 lr: Optional[str] = None,
34 start: Optional[int] = None,
35 num: Optional[int] = None,
36 as_sdt: Optional[str] = None,
37 safe: Optional[str] = None,
38 filter: Optional[str] = None,
39 as_vis: Optional[str] = None,
40 ):
41 """
42 Search for scholarly articles based on a query according to the google scholar
43 :param query: The query to search for.
44 :param engine: The search engine to use, default is "google_scholar"
45 :param cites: The unique ID of an article for triggering "Cited By" searches
46 :param as_ylo: The starting year for results (e.g., if as_ylo=2018, results before this year will be omitted)
47 :param as_yhi: The ending year for results (e.g., if as_yhi=2018, results after this year will be omitted)
48 :param scisbd: Defines articles added in the last year, sorted by date. It can be set to 1 to include only abstracts, or 2 to include everything
49 :param cluster: The unique ID of an article for triggering "All Versions" searches
50 :param hl: The language to use for the Google Scholar search
51 :param lr: One or multiple languages to limit the search to
52 :param start: The result offset for pagination (0 is the first page of results, 10 is the 2nd page, etc.)
53 :param num: The maximum number of results to return, limited to 20
54 :param as_sdt: Can be used either as a search type or a filter
55 :param safe: The level of filtering for adult content
56 :param filter: Defines if the filters for 'Similar Results' and 'Omitted Results' are on or off
57 :param as_vis: Defines whether to include citations or not
58 :return: Return a list of dictionaries of the papers
59 """
60 params = {
61 "q": query,
62 "engine": engine,
63 "api_key": KEY,
64 "cites": cites,
65 "as_ylo": as_ylo,
66 "as_yhi": as_yhi,
67 "scisbd": scisbd,

Callers

nothing calls this directly

Calls 1

ToolClass · 0.50

Tested by

no test coverage detected