#!/usr/bin/env python3 import sys import requests from colorama import init, Fore, Style # Define the API endpoint API_ENDPOINT = "https://api.openai.com/v1/chat/completions" # Set up your API key and headers API_KEY = "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" headers = { "Authorization": "Bearer " + API_KEY, "Content-Type": "application/json" } # Send a prompt to the model def send_prompt(prompt): data = { "model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}] } response = requests.post(API_ENDPOINT, json=data, headers=headers) response_data = response.json() # Extract the assistant's reply assistant_reply = response_data["choices"][0]["message"]["content"] return assistant_reply # Check if a question was provided as a command-line argument if len(sys.argv) > 1: question = sys.argv[1] reply = send_prompt(question) print(Fore.YELLOW) print(reply) else: print("Please provide a question as a command-line argument.") print("\033[0m") # Reset text color to default (white)