Fix docstring format of GoogleScholar (#138)
* fix docstrings * update pre-commit-hooks * chores --------- Co-authored-by: wangzy <wangziyi@pjlab.org.cn>
This commit is contained in:
@@ -38,11 +38,6 @@ repos:
|
|||||||
rev: v2.2.6
|
rev: v2.2.6
|
||||||
hooks:
|
hooks:
|
||||||
- id: codespell
|
- id: codespell
|
||||||
- repo: https://github.com/myint/docformatter
|
|
||||||
rev: v1.7.5
|
|
||||||
hooks:
|
|
||||||
- id: docformatter
|
|
||||||
args: ["--in-place", "--wrap-descriptions", "79"]
|
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v3.15.0
|
rev: v3.15.0
|
||||||
hooks:
|
hooks:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: E501
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from typing import Optional, Type
|
from typing import Optional, Type
|
||||||
@@ -103,9 +104,7 @@ class BINGMap(BaseAction):
|
|||||||
latitude: float = 0.0,
|
latitude: float = 0.0,
|
||||||
longitude: float = 0.0,
|
longitude: float = 0.0,
|
||||||
radius: int = 5000) -> dict:
|
radius: int = 5000) -> dict:
|
||||||
"""Search for places nearby a location, within a given radius, and \
|
"""Search for places nearby a location, within a given radius, and return the results into a list. You can use either the places name or the latitude and longitude.
|
||||||
return the results into a list. You can use either the places name or
|
|
||||||
the \\ latitude and longitude.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
search_term (:class:`str`): the place name.
|
search_term (:class:`str`): the place name.
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: E501
|
||||||
import os
|
import os
|
||||||
from typing import Optional, Type
|
from typing import Optional, Type
|
||||||
|
|
||||||
@@ -52,8 +53,7 @@ class GoogleScholar(BaseAction):
|
|||||||
filter: Optional[str] = None,
|
filter: Optional[str] = None,
|
||||||
as_vis: Optional[str] = None,
|
as_vis: Optional[str] = None,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""Search for scholarly articles based on a query according to the
|
"""Search for scholarly articles based on a query according to the google scholar.
|
||||||
google scholar.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
query (str): The query to search for.
|
query (str): The query to search for.
|
||||||
@@ -133,8 +133,7 @@ class GoogleScholar(BaseAction):
|
|||||||
no_cache: Optional[bool] = None,
|
no_cache: Optional[bool] = None,
|
||||||
async_req: Optional[bool] = None,
|
async_req: Optional[bool] = None,
|
||||||
output: Optional[str] = None) -> dict:
|
output: Optional[str] = None) -> dict:
|
||||||
"""Search for an author's information by author's id provided by
|
"""Search for an author's information by author's id provided by get_author_id.
|
||||||
get_author_id.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
author_id (str): Required. The ID of an author.
|
author_id (str): Required. The ID of an author.
|
||||||
@@ -192,8 +191,7 @@ class GoogleScholar(BaseAction):
|
|||||||
no_cache: Optional[bool] = None,
|
no_cache: Optional[bool] = None,
|
||||||
async_: Optional[bool] = None,
|
async_: Optional[bool] = None,
|
||||||
output: Optional[str] = 'json') -> dict:
|
output: Optional[str] = 'json') -> dict:
|
||||||
"""Function to get MLA citation format by an identification of
|
"""Function to get MLA citation format by an identification of organic_result's id provided by search_google_scholar.
|
||||||
organic_result's id provided by search_google_scholar.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
q (str): ID of an individual Google Scholar organic search result.
|
q (str): ID of an individual Google Scholar organic search result.
|
||||||
@@ -233,26 +231,20 @@ class GoogleScholar(BaseAction):
|
|||||||
no_cache: Optional[bool] = False,
|
no_cache: Optional[bool] = False,
|
||||||
_async: Optional[bool] = False,
|
_async: Optional[bool] = False,
|
||||||
output: Optional[str] = 'json') -> dict:
|
output: Optional[str] = 'json') -> dict:
|
||||||
"""The getAuthorId function is used to get the author's id by his or
|
"""The getAuthorId function is used to get the author's id by his or her name.
|
||||||
her name.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
mauthors (str): Defines the author you want to search for.
|
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 \
|
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'.
|
||||||
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.
|
||||||
after_author (Optional[str]): Defines the next page token. It is used for retrieving the next page \
|
before_author (Optional[str]): Defines the previous page token. It is used for retrieving the previous page results. Defaults to None.
|
||||||
results. The parameter has the precedence over before_author parameter. 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.
|
||||||
before_author (Optional[str]): Defines the previous page token. It is used for retrieving the previous \
|
_async (Optional[bool]): Defines the way you want to submit your search to SerpApi. Defaults to False.
|
||||||
page results. Defaults to None.
|
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'.
|
||||||
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:
|
Returns:
|
||||||
:class:`dict`: author id
|
:class:`dict`: author id
|
||||||
* author_id: the author_id of the author
|
* author_id: the author_id of the author
|
||||||
"""
|
"""
|
||||||
params = {
|
params = {
|
||||||
'mauthors': mauthors,
|
'mauthors': mauthors,
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ class IPythonInteractive(BaseAction):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
command (:class:`str`): Python code snippet
|
command (:class:`str`): Python code snippet
|
||||||
timeout (:class:`Optional[int]`): timeout for execution. This
|
timeout (:class:`Optional[int]`): timeout for execution.
|
||||||
argument only works in the main thread. Defaults to ``None``.
|
This argument only works in the main thread. Defaults to ``None``.
|
||||||
"""
|
"""
|
||||||
tool_return = ActionReturn(args={'text': command}, type=self.name)
|
tool_return = ActionReturn(args={'text': command}, type=self.name)
|
||||||
ret = (
|
ret = (
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: E501
|
||||||
import base64
|
import base64
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
@@ -207,12 +208,7 @@ class IPythonInterpreter(BaseAction):
|
|||||||
|
|
||||||
@tool_api
|
@tool_api
|
||||||
def run(self, command: str, timeout: Optional[int] = None) -> ActionReturn:
|
def run(self, command: str, timeout: Optional[int] = None) -> ActionReturn:
|
||||||
r"""When you send a message containing Python code to python, it will be
|
r"""When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 60.0 seconds. The drive at '/mnt/data' can be used to save and persist user files. Internet access for this session is disabled. Do not make external web requests or API calls as they will fail.
|
||||||
\ executed in a stateful Jupyter notebook environment. python will
|
|
||||||
respond with \ the output of the execution or time out after 60.0
|
|
||||||
seconds. The drive at '/mnt/data' \ can be used to save and persist
|
|
||||||
user files. Internet access for this session is \ disabled. Do not make
|
|
||||||
external web requests or API calls as they will fail.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
command (:class:`str`): Python code
|
command (:class:`str`): Python code
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ THEME_MAPPING = {
|
|||||||
|
|
||||||
|
|
||||||
class PPT(BaseAction):
|
class PPT(BaseAction):
|
||||||
"""Plugin to create ppt slides with text, paragraph, images in good looking
|
"""Plugin to create ppt slides with text, paragraph, images in good looking styles."""
|
||||||
styles."""
|
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
theme_mapping: Optional[Dict[str, dict]] = None,
|
theme_mapping: Optional[Dict[str, dict]] = None,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: E501
|
||||||
import copy
|
import copy
|
||||||
import io
|
import io
|
||||||
from contextlib import redirect_stdout
|
from contextlib import redirect_stdout
|
||||||
@@ -65,11 +66,21 @@ class PythonInterpreter(BaseAction):
|
|||||||
@tool_api
|
@tool_api
|
||||||
def run(self, command: str) -> ActionReturn:
|
def run(self, command: str) -> ActionReturn:
|
||||||
"""用来执行Python代码。代码必须是一个函数,函数名必须得是 'solution',代码对应你的思考过程。代码实例格式如下:
|
"""用来执行Python代码。代码必须是一个函数,函数名必须得是 'solution',代码对应你的思考过程。代码实例格式如下:
|
||||||
```python # import 依赖包 import xxx def solution(): # 初始化一些变量
|
|
||||||
variable_names_with_real_meaning = xxx # 步骤一 mid_variable =
|
```python
|
||||||
func(variable_names_with_real_meaning) # 步骤 x mid_variable =
|
# import 依赖包
|
||||||
func(mid_variable) # 最后结果 final_answer = func(mid_variable) return
|
import xxx
|
||||||
final_answer ```
|
def solution():
|
||||||
|
# 初始化一些变量
|
||||||
|
variable_names_with_real_meaning = xxx
|
||||||
|
# 步骤一
|
||||||
|
mid_variable = func(variable_names_with_real_meaning)
|
||||||
|
# 步骤 x
|
||||||
|
mid_variable = func(mid_variable)
|
||||||
|
# 最后结果
|
||||||
|
final_answer = func(mid_variable)
|
||||||
|
return final_answer
|
||||||
|
```
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
command (:class:`str`): Python code snippet
|
command (:class:`str`): Python code snippet
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .autogpt import * # noqa: F401, F403
|
from .autogpt import * # noqa: F401, F403
|
||||||
from .base_agent import * # noqa: F401, F403
|
from .base_agent import * # noqa: F401, F403
|
||||||
|
from .internlm2_agent import * # noqa: F401, F403
|
||||||
from .react import * # noqa: F401, F403
|
from .react import * # noqa: F401, F403
|
||||||
from .rewoo import * # noqa: F401, F403
|
from .rewoo import * # noqa: F401, F403
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import logging
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from typing import Dict, List, Optional, Union
|
from typing import Dict, List, Optional, Union
|
||||||
|
|
||||||
from lagent import BaseAgent
|
|
||||||
from lagent.actions import ActionExecutor
|
from lagent.actions import ActionExecutor
|
||||||
|
from lagent.agents.base_agent import BaseAgent
|
||||||
from lagent.llms import BaseAPIModel, BaseModel
|
from lagent.llms import BaseAPIModel, BaseModel
|
||||||
from lagent.schema import ActionReturn, ActionStatusCode, AgentReturn, AgentStatusCode, ModelStatusCode # noqa: E501
|
from lagent.schema import ActionReturn, ActionStatusCode, AgentReturn, AgentStatusCode, ModelStatusCode # noqa: E501
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
from lagent.utils import is_module_exist
|
|
||||||
from .base_api import BaseAPIModel
|
from .base_api import BaseAPIModel
|
||||||
from .base_llm import BaseModel
|
from .base_llm import BaseModel
|
||||||
|
from .huggingface import HFTransformer, HFTransformerCasualLM
|
||||||
|
from .lmdepoly_wrapper import LMDeployClient, LMDeployPipeline, LMDeployServer
|
||||||
|
from .meta_template import INTERNLM2_META
|
||||||
from .openai import GPTAPI
|
from .openai import GPTAPI
|
||||||
|
|
||||||
__all__ = ['BaseModel', 'BaseAPIModel', 'GPTAPI']
|
__all__ = [
|
||||||
|
'BaseModel', 'BaseAPIModel', 'GPTAPI', 'LMDeployClient',
|
||||||
if is_module_exist('transformers'):
|
'LMDeployPipeline', 'LMDeployServer', 'HFTransformer',
|
||||||
from .huggingface import HFTransformer, HFTransformerCasualLM # noqa: F401
|
'HFTransformerCasualLM', 'INTERNLM2_META'
|
||||||
__all__.extend(['HFTransformer', 'HFTransformerCasualLM'])
|
]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
lmdeploy
|
lmdeploy>=0.2.2
|
||||||
streamlit
|
streamlit
|
||||||
torch
|
torch
|
||||||
transformers
|
transformers>=4.34
|
||||||
|
|||||||
@@ -21,5 +21,4 @@ quiet-level = 3
|
|||||||
ignore-words-list = patten,nd,ty,mot,hist,formating,winn,gool,datas,wan,confids,TOOD,tood,ba,warmup,nam,DOTA,dota,conveyer,astroid
|
ignore-words-list = patten,nd,ty,mot,hist,formating,winn,gool,datas,wan,confids,TOOD,tood,ba,warmup,nam,DOTA,dota,conveyer,astroid
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
per-file-ignores = ftdp/configs/*: F401,F403,F405
|
|
||||||
max-line-length = 200
|
max-line-length = 200
|
||||||
|
|||||||
Reference in New Issue
Block a user