Skip to content

Commit

Permalink
update warning for cases
Browse files Browse the repository at this point in the history
  • Loading branch information
zehuichen123 committed Feb 19, 2024
1 parent 352fbe8 commit c04da09
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lagent/llms/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def __init__(self,
if isinstance(stop_words_id, int):
stop_words_id = [stop_words_id]
self.gen_params.update(stop_words_id=stop_words_id)
if self.gen_params['stop_words'] is not None and \
self.gen_params['stop_words_id'] is not None:
logger.warning("Both stop_words and stop_words_id are specified,"
"only stop_words_id will be used.")

self._load_tokenizer(
path=path,
Expand Down Expand Up @@ -308,7 +312,7 @@ def chat(self, inputs: Union[List[dict], List[List[dict]]], do_sample: bool = Tr
"""Return the chat completions in stream mode.
Args:
inputs (List[dict]): input messages to be completed.
inputs (Union[List[dict], List[List[dict]]]): input messages to be completed.
do_sample (bool): do sampling if enabled
Returns:
the text/chat completion
Expand All @@ -328,6 +332,7 @@ def chat(self, inputs: Union[List[dict], List[List[dict]]], do_sample: bool = Tr
history=history)
except Exception as e:
# handle over-length input error
logger.warning(str(e))
response = ""
return response

0 comments on commit c04da09

Please sign in to comment.