|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from abc import ABC, abstractmethod |
|
from typing import List, Optional, Tuple |
|
|
|
from camel.messages import BaseMessage |
|
|
|
|
|
class BaseTerminator(ABC): |
|
r"""Base class for terminators.""" |
|
|
|
def __init__(self, *args, **kwargs) -> None: |
|
self._terminated: bool = False |
|
self._termination_reason: Optional[str] = None |
|
|
|
@abstractmethod |
|
def is_terminated(self, *args, **kwargs) -> Tuple[bool, Optional[str]]: |
|
pass |
|
|
|
@abstractmethod |
|
def reset(self): |
|
pass |
|
|
|
|
|
class ResponseTerminator(BaseTerminator): |
|
r"""A terminator that terminates the conversation based on the response.""" |
|
|
|
@abstractmethod |
|
def is_terminated( |
|
self, messages: List[BaseMessage] |
|
) -> Tuple[bool, Optional[str]]: |
|
pass |
|
|
|
@abstractmethod |
|
def reset(self): |
|
pass |
|
|