diff --git a/SupportPC.py b/SupportPC.py index 8f90b86..fa8e06e 100644 --- a/SupportPC.py +++ b/SupportPC.py @@ -1,6 +1,8 @@ import sys import requests import json +import os +import openai from PyQt5.QtWidgets import QApplication, QMainWindow, QGridLayout, QTextEdit, QPushButton, QLineEdit, QWidget @@ -49,6 +51,40 @@ class MainWindow(QMainWindow): endpoint = 'https://api.openai.com/v1/completions' apiKey = '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' + # Load your API key from an environment variable or secret management service + openai.api_key = os.getenv("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") + + response = openai.Completion.create(model="gpt-3.5-turbo", prompt="Say this is a test", temperature=0, max_tokens=7) + + openai.ChatCompletion.create( + model="gpt-3.5-turbo", + messages=[ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Who won the world series in 2020?"}, + {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."}, + {"role": "user", "content": "Where was it played?"} + ] + ) + + """ + { + 'id': 'chatcmpl-6p9XYPYSTTRi0xEviKjjilqrWU2Ve', + 'object': 'chat.completion', + 'created': 1677649420, + 'model': 'gpt-3.5-turbo', + 'usage': {'prompt_tokens': 56, 'completion_tokens': 31, 'total_tokens': 87}, + 'choices': [ + { + 'message': { + 'role': 'assistant', + 'content': 'The 2020 World Series was played in Arlington, Texas at the Globe Life Field, which was the new home stadium for the Texas Rangers.'}, + 'finish_reason': 'stop', + 'index': 0 + } + ] + } + """ + # Define the request headers (if needed) headers = { "Content-Type": "application/json",