A python package for setting up agentic behavior for LLMs. Includes optimization for large training data, and adherence to applied interactional policies.
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.
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
This is the basic documentation for using the openai
module in AgenPy. Here is a more detailed API documentation.
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.
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())
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()
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())
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
)
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 |
---|---|
bc1qppcjpkcpsrxc35z9zcqcdvtzk333qslc9ft32j |
|
0xc1a9A83fE19a37e362652D9Ca6b7cA12fF3E875d |