Skip to content

Commit

Permalink
fix bisheng-rt bug (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaojin3616 committed Sep 15, 2023
2 parents 738ce40 + c33e9c7 commit 45592d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/backend/bisheng/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def get_default_factory(module: str, function: str):

def type_to_string(tp):
if getattr(tp, '__args__', None):
args_str = ','.join(type_to_string(arg) for arg in tp.__args__ if not isinstance(arg, None))
args_str = ','.join(
type_to_string(arg) for arg in tp.__args__ if arg is not type(None)) # noqa
return f'{tp.__name__}[{args_str}]'
else:
return tp.__name__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def _agenerate(
run_manager: Optional[AsyncCallbackManagerForLLMRun] = None,
**kwargs: Any,
) -> ChatResult:
return self._generate(messages, stop, run_manager, kwargs)
return self._generate(messages, stop, run_manager, **kwargs)

def _create_message_dicts(
self, messages: List[BaseMessage],
Expand All @@ -247,6 +247,8 @@ def _create_message_dicts(

def _create_chat_result(self, response: Mapping[str, Any]) -> ChatResult:
generations = []
if 'choices' not in response:
raise Exception(f'LLM return error {response}')
for res in response['choices']:
message = _convert_dict_to_message(res['message'])
gen = ChatGeneration(message=message)
Expand Down

0 comments on commit 45592d4

Please sign in to comment.