Metadata-Version: 2.1
Name: dillagent
Version: 1.0.8
Summary: Agentic LLM library
Home-page: https://github.com/buzzoo123/dillagent
License: LICENSE
Author: Dillan Khurana
Author-email: buzzoo123@users.noreply.github.com
Requires-Python: >=3.11,<4.0
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: annotated-types (==0.6.0)
Requires-Dist: anthropic (==0.19.2)
Requires-Dist: anyio (==4.3.0)
Requires-Dist: beautifulsoup4 (==4.12.3)
Requires-Dist: certifi (==2024.2.2)
Requires-Dist: charset-normalizer (==3.3.2)
Requires-Dist: colorama (==0.4.6)
Requires-Dist: distro (==1.9.0)
Requires-Dist: docutils (==0.20.1)
Requires-Dist: exceptiongroup (==1.2.0)
Requires-Dist: filelock (==3.13.1)
Requires-Dist: fsspec (==2024.2.0)
Requires-Dist: googlesearch-python (==1.2.3)
Requires-Dist: h11 (==0.14.0)
Requires-Dist: httpcore (==1.0.4)
Requires-Dist: httpx (==0.27.0)
Requires-Dist: huggingface-hub (==0.21.4)
Requires-Dist: idna (==3.6)
Requires-Dist: importlib-metadata (==7.0.2)
Requires-Dist: jaraco-classes (==3.3.1)
Requires-Dist: keyring (==24.3.1)
Requires-Dist: markdown-it-py (==3.0.0)
Requires-Dist: mdurl (==0.1.2)
Requires-Dist: more-itertools (==10.2.0)
Requires-Dist: nh3 (==0.2.15)
Requires-Dist: openai (==1.13.3)
Requires-Dist: packaging (==24.0)
Requires-Dist: pkginfo (==1.10.0)
Requires-Dist: pydantic (==2.6.3)
Requires-Dist: pydantic-core (==2.16.3)
Requires-Dist: pygments (==2.17.2)
Requires-Dist: python-dotenv (==1.0.1)
Requires-Dist: pywin32-ctypes (==0.2.2)
Requires-Dist: pyyaml (==6.0.1)
Requires-Dist: readme-renderer (==43.0)
Requires-Dist: requests (==2.31.0)
Requires-Dist: requests-toolbelt (==1.0.0)
Requires-Dist: rfc3986 (==2.0.0)
Requires-Dist: rich (==13.7.1)
Requires-Dist: sniffio (==1.3.1)
Requires-Dist: soupsieve (==2.5)
Requires-Dist: termcolor (==2.4.0)
Requires-Dist: tokenizers (==0.15.2)
Requires-Dist: tqdm (==4.66.2)
Requires-Dist: twine (==5.0.0)
Requires-Dist: typing-extensions (==4.10.0)
Requires-Dist: urllib3 (==2.2.1)
Requires-Dist: zipp (==3.18.1)
Project-URL: Repository, https://github.com/buzzoo123/dillagent
Description-Content-Type: text/markdown

# 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:

1. **LLM**: A wrapper for any provided Language Model, accessible via API or executable path, serving as the engine for any AI Agent framework.
   
2. **Tool**: Contains an LLM-callable function with user-defined descriptions/instructions to provide to the LLM.
   
3. **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.
   
4. **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:

1. Define Tools and Schemas for the parameters of the tool fucntions using Described Models
2. Instantiate an LLM and SysPrompt (Abstraction for system prompt)
3. Instantiate an Agent using the LLM and SysPrompt
4. 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:

```bash
pip install dillagent
```
Then using python...
```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:

1. Clone the repository.
2. Create and start a Python 3.10+ virtual environment.
3. Install the required packages: `pip install -r requirements.txt`.
4. Create a `.env` file and add your OpenAI API key: `OPENAI_API_KEY=<your_api_key>`.
5. Run the command `python demo.py` to execute the program.
6. Press `CTRL + C` to exit.

**WARNING:** This will consume API tokens (gpt-3.5-turbo-0125 by default), which may incur costs. Make sure to use it responsibly.

