Skip to main content

AI Agent for zishu.co.

Project description


Release Notes Python 3.9+ PyPI - Python Version License GitHub star chart

Paper | Key Features | Installation | Quick Start | Examples | Tutorials | Benchmark


AgentLite is a research-oriented library designed for building and advancing LLM-based task-oriented agent systems. It simplifies the implementation of new agent/multi-agent architectures, enabling easy orchestration of multiple agents through a manager agent. Whether you're building individual agents or complex multi-agent systems, AgentLite provides a straightforward and lightweight foundation for your research and development. Check more details in our paper.

🎉 News

🌟 Key Features

  • Lightweight Codebase: Designed for easy implementation of new Agent/Multi-Agent architectures.
  • Task-oriented LLM-based Agents: Focus on building agents for specific tasks, enhancing their performance and capabilities.
  • Research-oriented Design: A perfect tool for exploring advanced concepts in LLM-based multi-agent systems.

🤖 Framework

AgentLite Framework

🛠️ Installation

To get started with AgentLite, clone the repository and install the package using the following commands:

git clone https://github.com/SalesforceAIResearch/AgentLite.git
cd AgentLite
pip install -e .

Ensure you check the package dependencies and requirements in requirements.txt and setup.py.

🚀 Quick Start

To use AgentLite, set your OpenAI API key and run one of the example scripts:

export OPENAI_API_KEY=<INSERT YOUR OpenAI API KEY HERE>
python ./example/SearchManager.py

🖥️ UI Supporting

We provide a simple UI feature with AgentLite for demo purpose. To enable this capbility, uncomment the UI parts in requirements.txt to install the steamlite package. After installation, start with

streamlit run app/Homepage.py

Check our recorded UI demo. UI demo

🔍 Examples

Building Individual Agents

Build a Wikipedia search agent by providing a specific search action. For the full source, see SearchAgent.py.

1. Define the Action of an Agent

from agentlite.actions.BaseAction import BaseAction
from langchain_community.tools import WikipediaQueryRun

class WikipediaSearch(BaseAction):
    def __init__(self) -> None:
        action_name = "Wikipedia_Search" 
        action_desc = "Using this API to search Wiki content." # LLM uses action_name and action_desc to understand this action
        params_doc = {"query": "the search string. be simple."} # LLM uses this params_doc to understand the parameters in self.__call__() function
        self.search = WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper())
        super().__init__(
            action_name=action_name,
            action_desc=action_desc,
            params_doc=params_doc,
        )

    def __call__(self, query):
        return self.search.run(query)

2. Define an Agent with the Search Action

# get the llm for agent. Should already export OPENAI_API_KEY="" in the your terminal if you use OPENAI_API.
llm_config_dict = {"llm_name": "gpt-3.5-turbo", "temperature": 0.9}
llm_config = LLMConfig(llm_config_dict)
llm = get_llm_backend(llm_config)
# define an individual agent
search_agent_info = {
    "name": "search_agent",
    "role": "you can search wikipedia to get the information."
}
search_agent = BaseAgent(name=search_agent_info["name"], 
                         role=search_agent_info["role"], 
                         llm=llm, 
                         actions=[WikipediaSearch()], 
                         logger=agent_logger
                         )

3. Calling the Agent with a Task

# calling the agent with TaskPackage
from agentlite.commons import TaskPackage
test_task = "what is the found date of microsoft"
test_task_pack = TaskPackage(instruction=test_task)
response = search_agent(test_task_pack)
print("response:", response)

Building a Multi-Agent System

Orchestrate different search agents into a multi-agent system. For full source, see simple_manager.py.

1. Define Individual Agents

# define two different types search agents
## get llm backend
from agentlite.llm.agent_llms import get_llm_backend
from agentlite.llm.LLMConfig import LLMConfig
llm_config_dict = {
    "llm_name": "gpt-3.5-turbo",
    "temperature": 0.9,
    "context_len": 4000,
}
llm_config = LLMConfig(llm_config_dict)
llm = get_llm_backend(llm_config)
## get individual agents
from example.SearchAgent import WikiSearchAgent, DuckSearchAgent
wiki_search_agent = WikiSearchAgent(llm)
duck_search_agent = DuckSearchAgent(llm)

2. Define a Manager Agent

from agentlite.agents import ManagerAgent
manager_agent_info = {
    "name": "search_manager",
    "role": "you are controlling wiki_search_agent and duck_search_agent to complete the search task. You should first use wiki_search_agent to complete the search task. If didn't answer the task, please try to ask duck_search_agent. You should integrate the answer from both agent to finalize the task."
}
# simply initializing the manager with info and the TeamAgents.
search_manager = ManagerAgent(llm, manager_agent_info["name"], 
                              manager_agent_info["role"],
                              TeamAgents=[wiki_search_agent, duck_search_agent])

3. Test the Manager Agent with a TaskPackage

from agentlite.commons import TaskPackage
test_task = "what is salesforce famous for?"
test_task_pack = TaskPackage(instruction=test_task, task_creator="User")
response = search_manager(test_task_pack)
print(response)

running the test in terminal. You will see the running output like following:

Agent search_manager receives the following TaskPackage:
[
        Task ID: 6f6bffdd-1ba8-4f7c-b326-8f409865fef0
        Instruction: what is salesforce famous for?
]
====search_manager starts execution on TaskPackage 6f6bffdd-1ba8-4f7c-b326-8f409865fef0====
Agent search_manager takes 0-step Action:
{
        name: wiki_search_agent
        params: {'Task': 'What is salesforce famous for?'}
}

📘 Tutorials

For detailed examples and tutorials on how to utilize AgentLite for your research or projects, please visit the tutorials directory.

🔬 Benchmark

Citation

If you find our paper or code useful, please cite

@misc{liu2024agentlite,
      title={AgentLite: A Lightweight Library for Building and Advancing Task-Oriented LLM Agent System}, 
      author={Zhiwei Liu and Weiran Yao and Jianguo Zhang and Liangwei Yang and Zuxin Liu and Juntao Tan and Prafulla K. Choubey and Tian Lan and Jason Wu and Huan Wang and Shelby Heinecke and Caiming Xiong and Silvio Savarese},
      year={2024},
      eprint={2402.15538},
      archivePrefix={arXiv},
      primaryClass={cs.MA}
}

Acknowledgement

  • We use some great tools in Langchain to build the examples and the library LLM call

Contact

Please reach out to us if you have any questions or suggestions. You can submit an issue or pull request, or send an email to zhiweiliu@salesforce.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zigent-0.0.4.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zigent-0.0.4-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file zigent-0.0.4.tar.gz.

File metadata

  • Download URL: zigent-0.0.4.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for zigent-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9d225fea9b89d8110b8e40827a119ad19b3e80161882cbad4c6ba146348abda5
MD5 3eccfaa519b1850a13c6e48e1b80a2b6
BLAKE2b-256 4d9b1b01620bf11d98dec620c41c105933cab4dba0a7209dad794eb20b7d72a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for zigent-0.0.4.tar.gz:

Publisher: publish.yml on zigent/zigent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zigent-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: zigent-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for zigent-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 30da30bc4ab09015fa8324b1d87f482f835a5309a8b6740978c1b40117d7bfe7
MD5 d0313819a74fd8fe9e8c3e9cce713751
BLAKE2b-256 b626e3e29a099b976187d85ccc93d7d962145d8e517c739372b5a706ba99cba2

See more details on using hashes here.

Provenance

The following attestation bundles were made for zigent-0.0.4-py3-none-any.whl:

Publisher: publish.yml on zigent/zigent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page