Skip to main content

OPENAI tool that runs your prompts over a document

Project description

GPTEngineModel Class Documentation

The GPTEngineModel class is designed to interact with the OpenAI GPT-3.5 Turbo engine using prompts from a .doc file. It provides a convenient way to generate responses based on tasks and input prompts.

Table of Contents

  1. Installation
  2. Usage
  3. Class Details
  4. Example
  5. Contributing
  6. License

Installation

Before using the GPTEngineModel class, make sure you have the required dependencies installed:

pip install openai
pip install python-docx

Usage

To use the GPTEngineModel class, follow these steps:

  1. Create a configuration file containing your OpenAI API key. Refer to the config.py file in the code for an example.

  2. Import the GPTEngineModel class:

from your_module import GPTEngineModel
  1. Initialize an instance of the GPTEngineModel class with your main task and input prompt:
engine = GPTEngineModel("Main task description", "Input prompt text")
  1. Use the generate_response method to generate responses based on a .doc file:
response = engine.generate_response("path/to/your/file.docx")
print(response)

Class Details

Attributes

  • main_task (str): The main task description.
  • input_prompt (str): The input prompt for the GPT-3.5 Turbo engine.
  • api_key (str): The OpenAI API key for authentication.

Methods

generate_response(file_path: str) -> str

Generate a response from OpenAI based on the provided .doc file.

  • Parameters:

    • file_path (str): The path to the .doc file.
  • Returns:

    • str: The response from OpenAI.

Private Methods

  • _setup_openai(): Set up the OpenAI API key for authentication.
  • _get_context() -> str: Get the context for the current task.
  • _get_file(file_path: str) -> str: Read the .doc file and return the text content.
  • _batch_process(file_path: str) -> List[dict]: Batch process the instructions and input prompt.

Example

from your_module import GPTEngineModel

# Initialize the GPTEngineModel
engine = GPTEngineModel("Summarize an article", "Please summarize the following article:")

# Generate a response from OpenAI based on a .doc file
response = engine.generate_response("path/to/your/article.docx")
print(response)

Contributing

If you would like to contribute to this project or report issues, please refer to the project's GitHub repository https://github.com/mbsuraj/gptEngine.git.

License

This project is licensed under the MIT. See the LICENSE.md file for details.

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

gptEngine-0.0.2.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

gptEngine-0.0.2-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

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