diff --git a/apps/setting/models_provider/impl/openai_model_provider/model/llm.py b/apps/setting/models_provider/impl/openai_model_provider/model/llm.py index ce9d624c2ac..cdd187d9cac 100644 --- a/apps/setting/models_provider/impl/openai_model_provider/model/llm.py +++ b/apps/setting/models_provider/impl/openai_model_provider/model/llm.py @@ -46,14 +46,14 @@ def new_instance(model_type, model_name, model_credential: Dict[str, object], ** def get_num_tokens_from_messages(self, messages: List[BaseMessage]) -> int: try: - super().get_num_tokens_from_messages(messages) + return super().get_num_tokens_from_messages(messages) except Exception as e: tokenizer = TokenizerManage.get_tokenizer() return sum([len(tokenizer.encode(get_buffer_string([m]))) for m in messages]) def get_num_tokens(self, text: str) -> int: try: - super().get_num_tokens(text) + return super().get_num_tokens(text) except Exception as e: tokenizer = TokenizerManage.get_tokenizer() return len(tokenizer.encode(text))