Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

OpenAI Text Response CLI Tool

This Python script allows you to interact with OpenAI's API via command-line inputs, where you can provide a model and input text to receive a generated response. It uses the openai library and environment variables for secure API key management.

Features

  • Communicates with OpenAI's models (e.g., gpt-3.5-turbo) via API.
  • Accepts model and input content as command-line arguments.
  • Handles up to 2000 tokens per response.
  • Flexible parameters for response generation (temperature, top_p).

Prerequisites

Before running the script, make sure you have the following installed:

  • Python 3.x
  • Required libraries:
    • openai
    • python-dotenv

You can install the dependencies using the following command:

pip install openai python-dotenv

Setup

  1. Clone the repository:

    git clone <repository_url>
    cd <repository_folder>
  2. Create a .env file: In the project directory, create a .env file and add your OpenAI API key:

    OPENAI_API_KEY=your_openai_api_key
    

Usage

  1. Run the script:

    To use the script, pass the desired OpenAI model and input content as command-line arguments:

    python script.py <model_name> "<input_text>"

    For example:

    python script.py gpt-3.5-turbo "What is the capital of France?"
  2. Response:

    The script will return the response generated by the OpenAI model based on the input text:

    Paris is the capital of France.
    

Customization

  • Model: You can specify any OpenAI model, such as gpt-3.5-turbo.
  • Max Tokens: You can adjust the maximum number of tokens returned by modifying the max_tokens argument in the script.
  • Temperature & Top P: You can control the randomness of the responses by tweaking the temperature and top_p parameters in the script.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any questions or issues, please contact [bdeva1975@gmail.com].


Let me know if you need any further changes to the README.md!

About

TextGen-CLI is a Python-based command-line tool that interacts with OpenAI's API to generate text responses. Pass in a model and input text, and receive AI-generated outputs. Easily configurable via environment variables and supports customizable parameters like temperature and max tokens.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages