7. Experimental
Andrei Bondarev edited this page May 26, 2023
·
3 revisions
Clone this wiki locally
We've developed experimental features and we're still collecting community's feedback to them.
Agents
Agents are semi-autonomous bots that can respond to user questions and use available to them Tools to provide informed replies. They break down problems into series of steps and define Actions (and Action Inputs) along the way that are executed and fed back to them as additional information. Once an Agent decides that it has the Final Answer it responds with it.
Chain of Thought Agent
agent = Agent::ChainOfThoughtAgent.new(
llm: :openai, # or :cohere, :hugging_face, :google_palm or :replicate
llm_api_key: ENV["OPENAI_API_KEY"],
tools: ["search", "calculator", "wikipedia"]
)
agent.tools
# => ["search", "calculator", "wikipedia"]agent.run(question: "How many full soccer fields would be needed to cover the distance between NYC and DC in a straight line?")
#=> "Approximately 2,945 soccer fields would be needed to cover the distance between NYC and DC in a straight line."Demo


Tools
| Name | Description | ENV Requirements | Gem Requirements |
|---|---|---|---|
| "calculator" | Useful for getting the result of a math expression | gem "eqn", "~> 1.6.5" |
|
| "search" | A wrapper around Google Search |
ENV["SERPAPI_API_KEY"] (https://serpapi.com/manage-api-key) |
gem "google_search_results", "~> 2.0.0" |
| "wikipedia" | Calls Wikipedia API to retrieve the summary | gem "wikipedia-client", "~> 1.17.0" |
To use Tools do the following:
- Pick the tools you'd like to pass to an Agent and install the gems listed under Gem Requirements
# To use all 3 tools:
gem install eqn
gem install google_search_results
gem install wikipedia-client- Set the environment variables listed under ENV Requirements
export SERPAPI_API_KEY=paste-your-serpapi-api-key-here- Pass the tools when Agent is instantiated.
agent = Agent::ChainOfThoughtAgent.new(
llm: :openai, # or :cohere, :hugging_face, :google_palm or :replicate
llm_api_key: ENV["OPENAI_API_KEY"],
tools: ["search", "calculator", "wikipedia"]
)- Confirm that the Agent is using the Tools you passed in:
agent.tools
# => ["search", "calculator", "wikipedia"]