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:
BraisedPork
2024-02-01 13:11:07 +08:00
committed by GitHub
parent 990828ceb2
commit 60244a253a
12 changed files with 51 additions and 57 deletions

View File

@@ -38,11 +38,6 @@ repos:
rev: v2.2.6
hooks:
- 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
rev: v3.15.0
hooks:

View File

@@ -1,3 +1,4 @@
# flake8: noqa: E501
import json
import os
from typing import Optional, Type
@@ -103,9 +104,7 @@ class BINGMap(BaseAction):
latitude: float = 0.0,
longitude: float = 0.0,
radius: int = 5000) -> dict:
"""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.
"""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.
Args:
search_term (:class:`str`): the place name.

View File

@@ -1,3 +1,4 @@
# flake8: noqa: E501
import os
from typing import Optional, Type
@@ -52,8 +53,7 @@ class GoogleScholar(BaseAction):
filter: Optional[str] = None,
as_vis: Optional[str] = None,
) -> dict:
"""Search for scholarly articles based on a query according to the
google scholar.
"""Search for scholarly articles based on a query according to the google scholar.
Args:
query (str): The query to search for.
@@ -133,8 +133,7 @@ class GoogleScholar(BaseAction):
no_cache: Optional[bool] = None,
async_req: Optional[bool] = None,
output: Optional[str] = None) -> dict:
"""Search for an author's information by author's id provided by
get_author_id.
"""Search for an author's information by author's id provided by get_author_id.
Args:
author_id (str): Required. The ID of an author.
@@ -192,8 +191,7 @@ class GoogleScholar(BaseAction):
no_cache: Optional[bool] = None,
async_: Optional[bool] = None,
output: Optional[str] = 'json') -> dict:
"""Function to get MLA citation format by an identification of
organic_result's id provided by search_google_scholar.
"""Function to get MLA citation format by an identification of organic_result's id provided by search_google_scholar.
Args:
q (str): ID of an individual Google Scholar organic search result.
@@ -233,26 +231,20 @@ class GoogleScholar(BaseAction):
no_cache: Optional[bool] = False,
_async: Optional[bool] = False,
output: Optional[str] = 'json') -> dict:
"""The getAuthorId function is used to get the author's id by his or
her name.
"""The getAuthorId function is used to get the author's id by his or her name.
Args:
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'.
Args:
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:
:class:`dict`: author id
* author_id: the author_id of the author
Returns:
:class:`dict`: author id
* author_id: the author_id of the author
"""
params = {
'mauthors': mauthors,

View File

@@ -71,8 +71,8 @@ class IPythonInteractive(BaseAction):
Args:
command (:class:`str`): Python code snippet
timeout (:class:`Optional[int]`): timeout for execution. This
argument only works in the main thread. Defaults to ``None``.
timeout (:class:`Optional[int]`): timeout for execution.
This argument only works in the main thread. Defaults to ``None``.
"""
tool_return = ActionReturn(args={'text': command}, type=self.name)
ret = (

View File

@@ -1,3 +1,4 @@
# flake8: noqa: E501
import base64
import io
import logging
@@ -207,12 +208,7 @@ class IPythonInterpreter(BaseAction):
@tool_api
def run(self, command: str, timeout: Optional[int] = None) -> ActionReturn:
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.
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.
Args:
command (:class:`str`): Python code

View File

@@ -16,8 +16,7 @@ THEME_MAPPING = {
class PPT(BaseAction):
"""Plugin to create ppt slides with text, paragraph, images in good looking
styles."""
"""Plugin to create ppt slides with text, paragraph, images in good looking styles."""
def __init__(self,
theme_mapping: Optional[Dict[str, dict]] = None,

View File

@@ -1,3 +1,4 @@
# flake8: noqa: E501
import copy
import io
from contextlib import redirect_stdout
@@ -65,11 +66,21 @@ class PythonInterpreter(BaseAction):
@tool_api
def run(self, command: str) -> ActionReturn:
"""用来执行Python代码。代码必须是一个函数函数名必须得是 'solution',代码对应你的思考过程。代码实例格式如下:
```python # import 依赖包 import xxx 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 ```
```python
# import 依赖包
import xxx
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:
command (:class:`str`): Python code snippet

View File

@@ -1,4 +1,5 @@
from .autogpt 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 .rewoo import * # noqa: F401, F403

View File

@@ -3,8 +3,8 @@ import logging
from copy import deepcopy
from typing import Dict, List, Optional, Union
from lagent import BaseAgent
from lagent.actions import ActionExecutor
from lagent.agents.base_agent import BaseAgent
from lagent.llms import BaseAPIModel, BaseModel
from lagent.schema import ActionReturn, ActionStatusCode, AgentReturn, AgentStatusCode, ModelStatusCode # noqa: E501

View File

@@ -1,10 +1,12 @@
from lagent.utils import is_module_exist
from .base_api import BaseAPIModel
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
__all__ = ['BaseModel', 'BaseAPIModel', 'GPTAPI']
if is_module_exist('transformers'):
from .huggingface import HFTransformer, HFTransformerCasualLM # noqa: F401
__all__.extend(['HFTransformer', 'HFTransformerCasualLM'])
__all__ = [
'BaseModel', 'BaseAPIModel', 'GPTAPI', 'LMDeployClient',
'LMDeployPipeline', 'LMDeployServer', 'HFTransformer',
'HFTransformerCasualLM', 'INTERNLM2_META'
]

View File

@@ -1,4 +1,4 @@
lmdeploy
lmdeploy>=0.2.2
streamlit
torch
transformers
transformers>=4.34

View File

@@ -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
[flake8]
per-file-ignores = ftdp/configs/*: F401,F403,F405
max-line-length = 200