Package: genWizard
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 theDatabaseManagerclass. 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 thepathargument. Ifnumberis 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 byid. The file is named with the current timestamp and the providedfiletype. 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 byid. 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 byid. 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 byid. 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, theDatabaseManagerclass 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 theGeneratorclass. Initializes an instance of theGeneratorclass with the specified OpenAI engine and API key. It also creates an empty listconversation_logfor storing the conversation history and an instance of theDatabaseManager.display_info(self): This function prints out the details of theGeneratorinstance, 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. Ifmemoryis set toTrue, it will remember the response from the OpenAI API and store it inconversation_log. IfmemoryisFalse, it will forget the response. It returns the response content as a string.multi_generation(self, prompt, number=1, memory=False): This function uses thebase_generationfunction to generate multiple responses from the OpenAI API. The number of responses is determined by thenumberparameter. It returns a list of responses.TheGeneratorclass serves as a wrapper for the OpenAI API, providing utility functions for making requests and handling responses. It also integrates with theDatabaseManagerclass to handle data storage and retrieval.EXPANDER CLASS:__init__(self): The constructor for theExpanderclass. This initializes the instance with aGeneratorobject and aDatabaseManagerobject.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 theDatabaseManager’s path mapping. It then creates a full prompt by joining the “expansion_prompt” and the user’s prompt usingbase_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, theExpanderclass is used to expand a given prompt by adding additional content from a file and then generate text based on the expanded prompt.GENWIZARD CHANGELOGS0.0.3First Release
- Includes the basic functions: Database Manager, Expander, and Generator.