google_scholar_search
Module Contents
Classes
Plugin for google scholar search |
- class lagent.actions.google_scholar_search.GoogleScholar(api_key=None, description=None, parser=JsonParser, enable=True)
Bases:
lagent.actions.base_action.BaseActionPlugin for google scholar search
- Parameters:
api_key (str) – API KEY to use serper google search API, You can create a free API key at https://serper.dev.
description (dict) – The description of the action. Defaults to
None.parser (Type[BaseParser]) – The parser class to process the action’s inputs and outputs. Defaults to
JsonParser.enable (bool, optional) – Whether the action is enabled. Defaults to True.
- search_google_scholar(query, cites=None, as_ylo=None, as_yhi=None, scisbd=None, cluster=None, hl=None, lr=None, start=None, num=None, as_sdt=None, safe=None, filter=None, as_vis=None)
Search for scholarly articles based on a query according to the google scholar
- Parameters:
query (str) – The query to search for.
cites (Optional[str]) – The unique ID of an article for triggering “Cited By” searches.
as_ylo (Optional[int]) – The starting year for results (e.g., if as_ylo=2018, results before this year will be omitted).
as_yhi (Optional[int]) – The ending year for results (e.g., if as_yhi=2018, results after this year will be omitted).
scisbd (Optional[int]) – 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.
cluster (Optional[str]) – The unique ID of an article for triggering “All Versions” searches.
hl (Optional[str]) – The language to use for the Google Scholar search.
lr (Optional[str]) – One or multiple languages to limit the search to.
start (Optional[int]) – The result offset for pagination (0 is the first page of results, 10 is the 2nd page, etc.)
num (Optional[int]) – The maximum number of results to return, limited to 20.
as_sdt (Optional[str]) – Can be used either as a search type or a filter.
safe (Optional[str]) – The level of filtering for adult content.
filter (Optional[str]) – Defines if the filters for ‘Similar Results’ and ‘Omitted Results’ are on or off.
as_vis (Optional[str]) – Defines whether to include citations or not.
- Returns:
- article information
title: a list of the titles of the three selected papers
cited_by: a list of the citation numbers of the three selected papers
organic_id: a list of the organic results’ ids of the three selected papers
pub_info: publication information of selected papers
- Return type:
dict
- get_author_information(author_id, hl=None, view_op=None, sort=None, citation_id=None, start=None, num=None, no_cache=None, async_req=None, output=None)
Search for an author’s information by author’s id provided by get_author_id.
- Parameters:
author_id (str) – Required. The ID of an author.
hl (Optional[str]) – The language to use for the Google Scholar Author search. Default is ‘en’.
view_op (Optional[str]) – Used for viewing specific parts of a page.
sort (Optional[str]) – Used for sorting and refining articles.
citation_id (Optional[str]) – Used for retrieving individual article citation.
start (Optional[int]) – Defines the result offset. Default is 0.
num (Optional[int]) – Defines the number of results to return. Default is 20.
no_cache (Optional[bool]) – Forces SerpApi to fetch the results even if a cached version is already present. Default is False.
async_req (Optional[bool]) – Defines the way you want to submit your search to SerpApi. Default is False.
output (Optional[str]) – Defines the final output you want. Default is ‘json’.
- Returns:
- author information
name: author’s name
affliation: the affliation of the author
articles: at most 3 articles by the author
website: the author’s homepage url
- Return type:
dict
- get_citation_format(q, no_cache=None, async_=None, output='json')
Function to get MLA citation format by an identification of organic_result’s id provided by search_google_scholar.
- Parameters:
q (str) – ID of an individual Google Scholar organic search result.
no_cache (Optional[bool]) – If set to True, will force SerpApi to fetch the Google Scholar Cite results even if a cached version is already present. Defaults to None.
async (Optional[bool]) – If set to True, will submit search to SerpApi and retrieve results later. Defaults to None.
output (Optional[str]) – Final output format. Set to ‘json’ to get a structured JSON of the results, or ‘html’ to get the raw html retrieved. Defaults to ‘json’.
async_ (Optional[bool]) –
- Returns:
- citation format
authors: the authors of the article
citation: the citation format of the article
- Return type:
dict
- get_author_id(mauthors, hl='en', after_author=None, before_author=None, no_cache=False, _async=False, output='json')
The getAuthorId function is used to get the author’s id by his or her name.
- Parameters:
mauthors (str) – Defines the author you want to search for.
hl (Optional[str]) – Defines the language to use for the Google Scholar Profiles search. It’s a two-letter language code. (e.g., ‘en’ for English, ‘es’ for Spanish, or ‘fr’ for French). Defaults to ‘en’.
after_author (Optional[str]) – Defines the next page token. It is used for retrieving the next page results. The parameter has the precedence over before_author parameter. Defaults to None.
before_author (Optional[str]) – Defines the previous page token. It is used for retrieving the previous page results. Defaults to None.
no_cache (Optional[bool]) – Will force SerpApi to fetch the Google Scholar Profiles results even if a cached version is already present. Defaults to False.
_async (Optional[bool]) – Defines the way you want to submit your search to SerpApi. Defaults to False.
output (Optional[str]) – Defines the final output you want. It can be set to ‘json’ (default) to get a structured JSON of the results, or ‘html’ to get the raw html retrieved. Defaults to ‘json’.
- Returns:
- author id
author_id: the author_id of the author
- Return type:
dict