genWizard allows for versatile usage of openAI generation and prompting management.
Project description
GENWIZARD LIBRARY:
‘genWizard’ is a complex project aimed at utilizing AI for text generation, particularly using OpenAI’s language models. it is designed around the concept of generating content based on provided prompts, and involves a multi-stage process of expanding prompts, evaluating the reliability and validity of generated outputs, and comparing these outputs.
The purpose of the project is the allow anyone with little to no experience in coding AI to utilize the features of OpenAI’s LLMs.
- SETUP:
- DATABASE MANAGER CLASS:
__init__(self): The constructor for the DatabaseManager class. This initializes the instance with a mapping of paths to different directories in your project.
get_latest_file(self, path, number=1): This function retrieves the latest file(s) from a given directory, as determined by the path argument. If number is greater than 1, it will return the specified number of latest files. The returned files are sorted in descending order of creation time.
write(self, id, content=None, filetype=”.txt”): This function writes content to a file in a directory specified by id. The file is named with the current timestamp and the provided filetype. If no content is given, it prompts the user to provide content.
read(self, id, filename=None): This function reads content from a file in a directory specified by id. If no filename is given, it reads from the latest file in the directory. It returns the content of the file.
delete(self, id, filename=None): This function deletes a file in a directory specified by id. If no filename is given, it deletes the latest file in the directory.
edit(self, id, filename=None, content=None): This function edits a file in a directory specified by id. If no filename is given, it edits the latest file in the directory. If no content is given, it prompts the user to provide new content.
In essence, the DatabaseManager class is a utility for reading from, writing to, editing, and deleting files in specified directories in your project.
- GENERATOR CLASS:
__init__(self, engine=”gpt-3.5-turbo”, api_key=””): The constructor for the Generator class. Initializes an instance of the Generator class with the specified OpenAI engine and API key. It also creates an empty list conversation_log for storing the conversation history and an instance of the DatabaseManager.
display_info(self): This function prints out the details of the Generator instance, including the OpenAI engine being used and the API key.
base_generation(self, prompt, memory=False, token=300, temperature=0.5): This function makes a request to the OpenAI API using the provided prompt and other optional parameters. If memory is set to True, it will remember the response from the OpenAI API and store it in conversation_log. If memory is False, it will forget the response. It returns the response content as a string.
multi_generation(self, prompt, number=1, memory=False): This function uses the base_generation function to generate multiple responses from the OpenAI API. The number of responses is determined by the number parameter. It returns a list of responses.
The Generator class serves as a wrapper for the OpenAI API, providing utility functions for making requests and handling responses. It also integrates with the DatabaseManager class to handle data storage and retrieval.
- EXPANDER CLASS:
__init__(self): The constructor for the Expander class. This initializes the instance with a Generator object and a DatabaseManager object.
base_expansion(self, prompt_parts: list) -> str: This function takes a list of string parts and joins them with two newline characters (”nn”). It is used for creating a prompt by joining multiple strings together in a specific format.
expansion_generator(self, user_prompt: str, filename=”expansion_generator_prompt.txt”) -> list: This function generates an expanded text based on a user-provided prompt. It reads an “expansion_prompt” from a file (default name “expansion_generator_prompt.txt”) located in the directory associated with the ID 2 in the DatabaseManager’s path mapping. It then creates a full prompt by joining the “expansion_prompt” and the user’s prompt using base_expansion. The full prompt is fed into the generator for text generation. The generated text is split by newline characters and returned as a list of strings.
In essence, the Expander class is used to expand a given prompt by adding additional content from a file and then generate text based on the expanded prompt.
GENWIZARD CHANGELOGS
0.0.3
First Release - Includes the basic functions: Database Manager, Expander, and Generator.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file genWizard-0.0.3.tar.gz
.
File metadata
- Download URL: genWizard-0.0.3.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03317f25bf498a3c52a9bb5ecdf4fe992c1602da150705c315b4458334bac197 |
|
MD5 | dcda5ac254eef0eaf589074d3334c77b |
|
BLAKE2b-256 | 206058bb884648e8504acfc95aace2986b58ef067eab025befe6fac7e4144a5c |
File details
Details for the file genWizard-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: genWizard-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3cba1726a8c3a1e579bfdc7fce160c8d6d4d431a85c8df9787846bea2f3ce23 |
|
MD5 | 384aa1ed5963758eb321d14a2664f3c6 |
|
BLAKE2b-256 | 76975c9962ee766aa8ed3136a72f2df10bbb562d96fb4dc473a11ff0d3e67503 |