diff --git a/src/ragas/llms/base.py b/src/ragas/llms/base.py index ecbf6279e..a18fd55e9 100644 --- a/src/ragas/llms/base.py +++ b/src/ragas/llms/base.py @@ -157,7 +157,7 @@ def is_finished(self, response: LLMResult) -> bool: # if generation_info is empty, we parse the response_metadata # this is less reliable - elif t.cast(ChatGeneration, resp).message is not None: + elif isinstance(resp, ChatGeneration) and t.cast(ChatGeneration, resp).message is not None: resp_message: BaseMessage = t.cast(ChatGeneration, resp).message if resp_message.response_metadata.get("finish_reason") is not None: is_finished_list.append(