Fix typing and typo (#1331)

This commit is contained in:
Xu Song 2024-07-18 13:41:24 +08:00 committed by GitHub
parent 104bddf647
commit 1bfb4217ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -351,7 +351,7 @@ class APITemplateParser:
def _prompt2api(self, def _prompt2api(self,
prompts: Union[List, str], prompts: Union[List, str],
role_dict: Dict[str, Dict], role_dict: Dict[str, Dict],
for_gen: bool = False) -> Tuple[str, bool]: for_gen: bool = False) -> Tuple[List, bool]:
"""Convert the prompts to a API-style prompts, given an updated """Convert the prompts to a API-style prompts, given an updated
role_dict. role_dict.
@ -363,7 +363,7 @@ class APITemplateParser:
role whose "generate" is set to True. role whose "generate" is set to True.
Returns: Returns:
Tuple[str, bool]: The converted string, and whether the follow-up Tuple[List, bool]: The converted string, and whether the follow-up
conversion should be proceeded. conversion should be proceeded.
""" """
cont = True cont = True
@ -376,7 +376,7 @@ class APITemplateParser:
res = [] res = []
for prompt in prompts: for prompt in prompts:
if isinstance(prompt, str): if isinstance(prompt, str):
raise TypeError('Mixing str without explictt role is not ' raise TypeError('Mixing str without explict role is not '
'allowed in API models!') 'allowed in API models!')
else: else:
api_role, cont = self._role2api_role(prompt, role_dict, api_role, cont = self._role2api_role(prompt, role_dict,
@ -390,7 +390,7 @@ class APITemplateParser:
def _role2api_role(self, def _role2api_role(self,
role_prompt: Dict, role_prompt: Dict,
role_dict: Dict[str, Dict], role_dict: Dict[str, Dict],
for_gen: bool = False) -> Tuple[str, bool]: for_gen: bool = False) -> Tuple[Dict, bool]:
"""Convert a role prompt to a string, given an updated role_dict. """Convert a role prompt to a string, given an updated role_dict.
Args: Args:
@ -401,7 +401,7 @@ class APITemplateParser:
role whose "generate" is set to True. role whose "generate" is set to True.
Returns: Returns:
Tuple[str, bool]: The converted string, and whether the follow-up Tuple[Dict, bool]: The converted string, and whether the follow-up
conversion should be proceeded. conversion should be proceeded.
""" """
merged_prompt = role_dict.get( merged_prompt = role_dict.get(