/test-gpt-connection

Python script to test connection to OpenAI/Azure LLM

Primary LanguagePythonMIT LicenseMIT

Test GPT Connecton

A simple Python project that uses the OpenAI API to test that you can connect to an OpenAI or Azure-hosted GPT LLM, send a simple prompt, and receive a text completion response.

Prerequisites

  1. Ensure you have an OpenAI or Azure OpenAI GPT model accessible along with appropriate API keys / credentials.

  2. Ensure you have installed Python 3 and PIP on your workstation.

  3. In a terminal on your workstation, from the root folder of this project, run the following command to copy an example environment configuration file to a new file into the same root folder called .env, and then edit the values for the properties shown in this new .env file to reflect your specific environment settings:

    cp 'EXAMPLE.env' '.env'
  4. In the terminal, initialise the required Python environment for you to be able to execute the application correctly.

    python3 -m pip install --user virtualenv
    python3 -m venv my-test-env
    source my-test-env/bin/activate
    python -m pip install --upgrade pip
    python -m pip install -r requirements.txt

Execution

From the terminal, execute the followwing command:

python test-gpt-conn.py