A library to help and facilitate the creation of bots and AI assistants
Project description
EasyBot Library
EasyBot is a Python library designed to facilitate the creation of AI-powered bots using OpenAI's API. This library provides a simple interface to integrate various functionalities and create a customizable assistant.
Features
- Easy integration with OpenAI's API.
- Customizable bot functions.
- Simple setup and usage.
Installation
To install the EasyBot library, you can use pip:
pip install easybot-py
Usage
Usage Here is an example of how to use the EasyBot library:
import os
from easy_bot import EasyBot
def sum(a: int, b: int, positive: bool = False):
"""
Made an operation and returns the result
@a : int First operand
@b : int Second operand
"""
return a + b
def main():
INSTRUCTION = "You're a Math tutor, you should use the functions"
token = os.getenv('OPENAI_API_KEY')
if token is None:
raise ValueError('Token key is not set in env variables')
client = EasyBot(token, INSTRUCTION)
client.add_function(sum)
client.create_assistant()
response = client.create_text_completion('What is 24556 + 554322 + 2')
print(response)
if __name__ == "__main__":
main()
Here you're using the default model of EasyBot, it's using the OpenAI endpoint to generate the response. It's using by default the gpt-4o-mini model. You can change the model by passing the model name in the create_assistant method.
import os
from easy_bot import EasyBot, OpenAICore
# Your functions here
# ...
def main():
INSTRUCTION = "You're a Math tutor, you should use the functions"
token = os.getenv('OPENAI_API_KEY')
if token is None:
raise ValueError('Token key is not set in env variables')
client = EasyBot(token, INSTRUCTION)
client.add_function(sum)
client.create_assistant(OpenAICore, model='gpt-4o')
response = client.create_text_completion('What is 24556 + 554322 + 2')
print(response)
if __name__ == "__main__":
main()
You can pass an image to the bot, and it will generate a response based on the image. You can use the create_image_completion method to generate a response based on the image. You could use either a local image (encoded) or a URL to the image.
# URL
response = client.create_image_completion('url_to_image')
# Local image
with open('image.jpg', 'rb') as image:
response = client.create_image_completion('What\'s this?', image)
Documentation
Using NIM endpoints (Beta)
To use the NIM endpoints, you need to pass the Nim class in the create_assistant method. For use NIM endpoints, you need to have a NIM API key. You can get it by signing up on the NIM website, NVIDIA NIM.
By default we're using mistral-large-2-instruct model, but you can change it by passing the model name in the create_assistant method. For example, you can use the meta/llama-3.1-70b-instruct model.
It also support function calling, you can use the functions in the same way as the OpenAI endpoints.
import os
from easy_bot import EasyBot, Nim
def main():
INSTRUCTION = "You're a Math tutor, you should use the functions"
token = os.getenv('NIM_API_KEY')
if token is None:
raise ValueError('Token key is not set in env variables')
client = EasyBot(token, INSTRUCTION)
client.add_function(sum)
client.create_assistant(Nim, model='meta/llama-3.1-70b-instruct')
response = client.create_text_completion('What is 24556 + 554322 + 2')
print(response)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any changes.
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
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 easybot_py-0.0.7.tar.gz.
File metadata
- Download URL: easybot_py-0.0.7.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
604dc42b1b5c791b5a8bf8b7335cff89030bc6e2de0037076394d4457ca098b3
|
|
| MD5 |
00ec52086e520cf83141e0b0a0c65b38
|
|
| BLAKE2b-256 |
c50dc8fb7a601125a4b7fafeff754ce9096e3d073764258fad57700ddf168f2c
|
File details
Details for the file easybot_py-0.0.7-py3-none-any.whl.
File metadata
- Download URL: easybot_py-0.0.7-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7b22b782401959206f3c02ccbd3ae520de9773a145862f4f1fbf906f3c14905
|
|
| MD5 |
83d8aeb70ea697e12db4f99333c95d7e
|
|
| BLAKE2b-256 |
6002f65a6743fc68f87b43104d5454a5d64358567b06c3481a20779aabe1d36f
|