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.
Metadata
Release files for dillagent 1.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dillagent-1.0.8.tar.gz | 15.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dillagent-1.0.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.2 kB
Release files / dillagent-1.0.8.tar.gz
| Download URL | dillagent-1.0.8.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5442a3ca3b81a08077e4ba69955fd67dd9b41291dfbe953cfeb961e790ba56c9
|
|
BLAKE2b-256 checksum How to use checksums |
9d36589e9ad8a9807670b3082a529baa5efc389819808ff24d6b3552bed54057
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.3 Windows/11
|
Release files / dillagent-1.0.8-py3-none-any.whl
| Download URL | dillagent-1.0.8-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96a94d1b7217371ecd757a2312a99e0f974c5ec57923cbfcbf1ec937a24b8317
|
|
BLAKE2b-256 checksum How to use checksums |
f52a9f39ab2c161e96aaba833276fb31232a609b67eae5a64ce4bd63e99b195d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.3 Windows/11
|
Security for dillagent 1.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.