|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import logging |
|
from typing import List |
|
|
|
from camel.toolkits.base import BaseToolkit |
|
from camel.toolkits.function_tool import FunctionTool |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
class HumanToolkit(BaseToolkit): |
|
r"""A class representing a toolkit for human interaction.""" |
|
|
|
def __init__(self): |
|
pass |
|
|
|
def ask_human_via_console(self, question: str) -> str: |
|
r"""Ask a question to the human via the console. |
|
|
|
Args: |
|
question (str): The question to ask the human. |
|
|
|
Returns: |
|
str: The answer from the human. |
|
""" |
|
print(f"Question: {question}") |
|
logger.info(f"Question: {question}") |
|
reply = input("Your reply: ") |
|
logger.info(f"User reply: {reply}") |
|
return reply |
|
|
|
def get_tools(self) -> List[FunctionTool]: |
|
r"""Returns a list of FunctionTool objects representing the |
|
functions in the toolkit. |
|
|
|
Returns: |
|
List[FunctionTool]: A list of FunctionTool objects |
|
representing the functions in the toolkit. |
|
""" |
|
return [FunctionTool(self.ask_human_via_console)] |
|
|