Skip to main content

A python package for setting up agentic behavior for LLMs. Includes optimization for large training data, and adherence to applied interactional policies.

Project description

AgenPy 0.1.2 📦

Python ChatGPT

A python package for setting up agentic behavior for LLMs. Includes optimization for large training data, and adherence to applied interactional policies.

Table Of Contents

Features

AgenPy is particularly useful for creating multi-modal agents using LLMs and other AI tools.

  • Set Behavior & Actions:
    Using various APIs, an agent with particular persona can be created. Users can set their behaviors and reactions to different scenarios. User can also set up different tasks to perform according to needs.

  • Database Management:
    Import your knowledge base for extended information to the agent. Is organized into vector databases for ease of recall, hence faster and optimized response rates.

Usage

Import this package into Python using this command. Here is the PyPI website for more details.

pip install agenpy

Create a file named demo.py and paste the following code into it.

import openai
from agenpy.openai import GPTAgent

def main():
    # Initialize the GPTAgent with your API key
    agent = GPTAgent(api_key="your-openai-api-key")

    # Generate a response synchronously
    response = agent.generate()

    # Print the response
    print("Generated Response:", response)

if __name__ == "__main__":
    main()

To execute this code, run the command:

python demo.py

OpenAI Starting Documentation

This is the basic documentation for using the openai module in AgenPy. Here is a more detailed API documentation.

GPT Response from Agent (OpenAI)

Here is a starter code to understand how to use the AgenPy library properly. Create a file named demo.py and paste the following code into it.

import openai
from agenpy.openai import GPTAgent

def main():
    # Initialize the GPTAgent with your API key
    agent = GPTAgent(api_key="your-openai-api-key")

    # Generate a response synchronously
    response = agent.generate()

    # Print the response
    print("Generated Response:", response)

if __name__ == "__main__":
    main()

Note that this program is the same as the code given earlier in the Usages section.

Async GPT Response from Agent (OpenAI)

The output can also be asynchronous using the code below.

import asyncio
import openai
from agenpy.openai import GPTAgent

async def main():
    # Initialize the GPTAgent with async mode enabled and your API key
    agent = GPTAgent(api_key="your-openai-api-key", is_async=True)

    # Generate a response asynchronously
    response = await agent.generate_async()

    # Print the response
    print("Generated Response:", response)

if __name__ == "__main__":
    asyncio.run(main())

GPT Streaming from Agent (OpenAI)

The output can also be streamed using the code below.

import openai
from agenpy.openai import GPTAgent

def main():
    # Initialize the GPTAgent with your API key
    agent = GPTAgent(api_key="your-openai-api-key")

    # Stream the response synchronously
    for chunk in agent.stream():
        # Print each chunk of the streamed response
        print(chunk)

if __name__ == "__main__":
    main()

Async GPT Streaming from Agent (OpenAI)

The output can also be asynchronously streamed using the code below.

import asyncio
import openai
from agenpy.openai import GPTAgent

async def main():
    # Initialize the GPTAgent with async mode enabled and your API key
    agent = GPTAgent(api_key="your-openai-api-key", is_async=True)

    # Stream the response asynchronously
    async for chunk in agent.stream_async():
        # Print each chunk of the streamed response
        print(chunk)

if __name__ == "__main__":
    asyncio.run(main())

Default Values

Here are the default values used by the package. These can and should be changed.

Name: Mr. Octranymous
Role: You are a general robot, tasked with helping the user by answering their questions. Try to make your responses sound engaging and conversational, while maintaining the pace and length of the interaction by analyzing the user. Always try to be friendly, even if the user tries to get you to act harshly.
Is Async: False
Default Model: GPT-4-Omni (gpt-4o)

Donate & Help

If you want to help in the maintenance of this package and keep it open and free for everyone, consider making a donation. It's optional, but we'll be grateful if you did. All of the donations go straight into the development of this package only.

Crypto Network Wallet
Bitcoin bc1qppcjpkcpsrxc35z9zcqcdvtzk333qslc9ft32j
Ethereum 0xc1a9A83fE19a37e362652D9Ca6b7cA12fF3E875d

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

agenpy-0.1.2.1.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file agenpy-0.1.2.1.tar.gz.

File metadata

  • Download URL: agenpy-0.1.2.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for agenpy-0.1.2.1.tar.gz
Algorithm Hash digest
SHA256 1be0ed4386c1d5569f82842465f9781db6d7c060b102c0bfe87e8476dd547cef
MD5 6380e16a84c166fe37983ad7abf66e7e
BLAKE2b-256 bdf45ef41c292972e28d823f149a89d58cd5f55584df98657fc49ba5b506f0af

See more details on using hashes here.

Supported by

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