QueryGPT
(by Michael Walsh_1)
Allows the user to query chatgpt using Open AI's API. The User must provide their own API key.
Downloads:
16
Support Email

This Grasshopper Python scripting component interacts with the OpenAI API to generate responses based on a user-provided text prompt. It uses the OpenAI GPT-3.5-turbo model to generate natural language responses, making it useful for tasks such as text generation, translation, summarization, and more.

Update: Query GPT+ Now available. Allows user to pick model: Query GPT+

Inputs:

prompt: (String) - The text input that you want to process with the OpenAI API. This is the message or query you send to the AI, and it will generate a response based on this input. For example: "Translate 'Hello, how are you?' to French."

api_key: (String) - Your OpenAI API key that authorizes access to the API. It must be a valid key associated with an OpenAI account that has access to the desired model (e.g., gpt-3.5-turbo).

Outputs:

Response: (String) - The main output containing the AI-generated response from the OpenAI API. If the request is successful, this output will display the assistant's reply based on the provided prompt.

Status: (String) - Provides the status of the API request. It includes error messages, debug information, or success messages, offering context on the request's outcome. This output is helpful for understanding if something went wrong or confirming a successful request.

How It Works:

Setup: The component first checks if the required inputs (prompt and api_key) are provided. If either input is missing, it outputs an error message.

Request Construction: It constructs an HTTP POST request to the OpenAI API endpoint (https://api.openai.com/v1/chat/completions) with the necessary headers and JSON-formatted data payload. The payload contains the model specification (gpt-3.5-turbo) and the user's prompt.

Sending the Request: The component sends the request asynchronously and waits for a response from the API.

Processing the Response: Upon receiving a response:

If successful, it extracts and outputs the assistant's generated response under the Response output.

If an error occurs, it captures detailed error information and outputs it under the Status output.

Error Handling: The component includes comprehensive error handling to catch and output any exceptions or API errors, providing clarity on any issues encountered.

Please follow these steps to create an API Key: https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key

Created by Michael Walsh and Reinhardt Swart as part of their thesis project, 'Democratised Design.

Icon from: <a href="https://www.flaticon.com/free-icons/question-mark" title="question mark icons">Question mark icons created by Talha Dogar - Flaticon</a>

  • License Type:
License Cost:
Downloads
For instructions on installing Grasshopper Add-Ons, please see FAQ for details.
Title
Description
Platform
 
QueryGPT
2024-09-05
Grasshopper for Rhino 7 for Win
Reviews