AI Agents List Logo

LLM Agents logoLLM Agents

Build and control AI agents with large language models

LLM Agents is a compact library for building AI agents controlled by large language models. It offers a simplified approach to agent creation, inspired by langchain, with tools for Python REPL, Google search, and Hacker News search.

Details

LLM Agents Agent's User Interface

LLM Agents: Streamlined AI Agent Development

Introduction

LLM Agents is a compact and powerful library designed for building AI agents controlled by large language models (LLMs). Inspired by langchain, this project aims to simplify the process of creating and understanding AI agents, making it accessible to developers and researchers alike.

Key Features

  • Simplified Architecture: Built with minimal abstraction layers for easy comprehension
  • Custom Tools: Includes Python REPL, Google Search, and Hacker News Search capabilities
  • Flexible Integration: Easily extendable with custom tools and LLM providers
  • Thought-Action-Observation Loop: Implements a cyclical decision-making process

How It Works

The LLM Agents library operates on a straightforward principle:

  1. Instruction: The agent receives a prompt outlining how to solve tasks using available tools.
  2. Tool Utilization: Custom-built components (tools) are at the agent's disposal.
  3. Decision Loop: The agent follows a Thought, Action, Observation cycle:
    • Thought and Action are generated by the LLM
    • Observations are produced by using tools (e.g., Python REPL outputs, Google search results)
  4. Continuous Learning: New information is appended to the prompt in each cycle, allowing the agent to adapt and refine its approach.
  5. Final Answer: Once sufficient information is gathered, the agent provides a conclusive response.

Getting Started

Installation

  1. Clone the repository
  2. Run pip install -e . in the project directory

Environment Setup

Set the following environment variables:

  • OPENAI_API_KEY: For OpenAI API access
  • SERPAPI_API_KEY: For Google Search functionality (if using the SerpAPI tool)

Example:

export OPENAI_API_KEY='your-api-key-here'
export SERPAPI_API_KEY='your-serpapi-key-here'

Usage

Basic usage example:

from llm_agents import Agent, ChatLLM, PythonREPLTool, HackerNewsSearchTool, SerpAPITool

agent = Agent(llm=ChatLLM(), tools=[PythonREPLTool(), SerpAPITool(), HackerNewsSearchTool()])
result = agent.run("Your question to the agent")
print(f"Final answer is {result}")

Customization

LLM Agents is designed for flexibility:

  • Create custom tools to expand the agent's capabilities
  • Omit tools as needed (e.g., removing SerpAPI if you don't have an API key)
  • Experiment with different LLM providers or custom prompts

Benefits

  • Educational Value: Gain insights into AI agent architecture and functionality
  • Rapid Prototyping: Quickly build and test AI agent concepts
  • Customizable: Tailor the agent to specific use cases or research needs
  • Lightweight: Minimal dependencies and straightforward implementation

Conclusion

LLM Agents offers a unique opportunity to explore and experiment with AI agent development. Whether you're a researcher, developer, or AI enthusiast, this library provides a solid foundation for building intelligent, task-oriented agents powered by large language models.

Get started with LLM Agents today and unlock the potential of AI-driven problem-solving in your projects!

Explore similar agents