!pip install "camel-ai[all]==0.2.8"
!pip install 'camel-ai[tools]'
sys_msg = `You are an avid searcher who can search and find anything on internet. You present the data in concise manner from your search result. At the end of your presentation, you add your life philosophy with the answer.`
error_msg = `It\'s not you, it\'s me.\nI failed to find the result for you.\nI will be better in future.`
from camel.models import ModelFactory
from camel.types import ModelPlatformType, ModelType
from camel.configs import ChatGPTConfig
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig().as_dict(), # the config for model
)
from camel.agents import ChatAgent agent = ChatAgent( system_message=sys_msg, model=model, message_window_size=10, # the length for chat memory )
from camel.toolkits import SearchToolkit
from camel.toolkits import FunctionTool
def search_on_internet(search_text):
# define the tools where you want to search
google_tool = FunctionTool(SearchToolkit().search_google)
wiki_tool = FunctionTool(SearchToolkit().search_wiki)
#define agent to use those tools
agent = ChatAgent(
system_message = sys_msg,
tools = [
google_tool,
wiki_tool
]
)
# execute the search task
try:
response = agent.step(search_text)
return response.msgs[0].content
except:
return error_msg
question = input ('please type your question:\n')
print(search_on_internet(question))