Skip to main content

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.


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.

GENMAKE CHANGELOG

0.0.1

First Release - Includes the basic functions: Database Manager, Expander, and Generator.

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

genWizard-0.0.2.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file genWizard-0.0.2.tar.gz.

File metadata

  • Download URL: genWizard-0.0.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for genWizard-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9a7bd3d6cdb458b12fabefb1b4ed0401ad8b70d5f379c6d1afc617899300c54f
MD5 a957be3c83eb61333619a005334337b7
BLAKE2b-256 6f517f3a5471457a11b31bc71bccebebc0cbdd09e6ea013a91b0acc65c7ed9ca

See more details on using hashes here.

Supported by

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