Agentic LLM library
Project description
DillAgent
DillAgent is an AI agent library based on the principles of ReAct: Synergizing Reasoning and Acting in Language Models. While there are existing libraries such as Langchain, Langroid, and Llamaindex, DillAgent takes a different approach by prioritizing modularity and abstraction to provide developers with more control over their LLM-powered applications.
Overview
DillAgent empowers developers by offering a high-level framework while allowing customization of prompts, formatting, and logic patterns - which is necessary when using a non-deterministic technology like an LLM. It provides a structured environment for creating production-ready LLM-powered applications. The key abstractions in DillAgent include:
-
LLM: A wrapper for any provided Language Model, accessible via API or executable path, serving as the engine for any AI Agent framework.
-
Tool: Contains an LLM-callable function with user-defined descriptions/instructions to provide to the LLM.
-
Agent: Comprised of an LLM, Tools that the LLM can use, and a System Prompt to set up the environment for an AI Agent loop regardless of specific logic implementation.
-
Agent Executor: Utilizes an Agent, intermediate parser, and output parser in a loop, allowing developers to implement their own logic to achieve various tasks using LLM reasoning.
High Level Usage:
- Define Tools and Schemas for the parameters of the tool fucntions using Described Models
- Instantiate an LLM and SysPrompt (Abstraction for system prompt)
- Instantiate an Agent using the LLM and SysPrompt
- Create an Agent Executor to run the agent
It should be noted that AgentExecutors can be implemented into loops for continuous chats with conversational memory.
Basic Example Usage
Before running this example, make sure you have the dillagent package installed. You can install it using pip:
pip install dillagent
Then using python...
from dillagent.models import DescribedModel, Field
from dillagent.agents.executors import ConversationalExecutor
from dillagent.llm import OpenAILLM, LLMConfig
from dillagent.tools import tool
from dillagent.agents.agents import AdvancedAgent
from dotenv import load_dotenv
load_dotenv()
class SearchSchema(DescribedModel):
query: str = Field(...,
description="Query to be searched in the form of a string.")
@tool(name="Search", description="Useful for searching for information", schema=SearchSchema)
def search(query: str):
# Return search results using query
return "I searched the internet for your query!"
llm = OpenAILLM(LLMConfig(
model="gpt-3.5-turbo-0125", api_key=os.environ.get('API_KEY'), path="[https://api.openai.com/v1/](https://api.openai.com/v1/)"),)
sys_prompt = MultiInputSysPrompt("You are a helpful AI Assistant.")
agent = AdvancedAgent(llm, [search], sys_prompt)
runner = ConversationalExecutor(agent, JsonParser(
['action', 'action_input'], 'action', 'action_input'))
prompt = input("What can I help you with?\n")
print(runner.run(prompt))
View the project documentation for further implementation details.
Demo
This library is currently under development. However, you can use the provided demo.py file to demo the project with premade "dummy" tools. Follow these instructions:
- Clone the repository.
- Create and start a Python 3.10+ virtual environment.
- Install the required packages:
pip install -r requirements.txt. - Create a
.envfile and add your OpenAI API key:OPENAI_API_KEY=<your_api_key>. - Run the command
python demo.pyto execute the program. - Press
CTRL + Cto exit.
WARNING: This will consume API tokens (gpt-3.5-turbo-0125 by default), which may incur costs. Make sure to use it responsibly.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dillagent-1.0.6.tar.gz.
File metadata
- Download URL: dillagent-1.0.6.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b60cfadbfea7aff39c7abc1b2fc8df6fb3b96d5fd837c6689d5ca95563d9ef7
|
|
| MD5 |
a7ee8e62abdaad1ddc41d5f87eaa1e20
|
|
| BLAKE2b-256 |
a232f17a70dda9b0792060533f99fa785d9c3fc01170dffc59c8a12cd0a05f9f
|
File details
Details for the file dillagent-1.0.6-py3-none-any.whl.
File metadata
- Download URL: dillagent-1.0.6-py3-none-any.whl
- Upload date:
- Size: 28.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67875d2b6f33e40b74fcffe07a0612c84f00b740b9c8a9d9d1461a2b84935383
|
|
| MD5 |
cb039d88cdc59c7d7e35e4b374467ac2
|
|
| BLAKE2b-256 |
f5c5103fd2e6352479a6f895c54b698542b20216bd40d6eb3d1c631b09646922
|