You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have released a new major version of our SDK, and we recommend upgrading promptly.
Regarding this new sdk...
I'll admit it I'm a newb. I've been using ChatGPT to create a rather extensive app that has been working great. I took a break from the project and suddenly i could not get answers from the api. I installed wsl and ubuntu did the whole grit thing and still i am unable to resolve the errors in my code. GPT4 Turbo is of no help with the issue and despite my best efforts I've killed a couple of days work on the project effectively going in circles attempting to fix the issue. If there is anybody willing to take a look at my code and advise me on how I can get things going again, I would be most grateful...
Here is my code as is now
client = OpenAI()
Load environment variables from the .env file
load_dotenv()
Retrieve and set the API key from the .env file
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
Define the model to be used
model_id = "gpt-4-turbo-2024-04-09" # Replace with the correct model ID you are using
def chatgpt_conversation(conversation_log):
print("Debug - Sending message to OpenAI: ", conversation_log[-1]['content'])
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {OPENAI_API_KEY}"
}
data = {
"model": model_id,
"messages": conversation_log,
"temperature": 0.7
}
response = requests.post('https://api.openai.com/v1/chat/completions', json=data, headers=headers)
if response.status_code == 200:
response_data = response.json()
assistant_response = response_data['choices'][0]['message']['content'].strip()
conversation_log.append({'role': 'assistant', 'content': assistant_response})
print("Debug - Received response from GPT-4:", assistant_response)
else:
error_message = f"Failed to get a valid response from OpenAI API: {response.text}"
print("Debug - Error in communicating with GPT-4:", error_message)
conversation_log.append({'role': 'assistant', 'content': error_message})
return conversation_log
Example usage
conversation_history = [
{'role': 'user', 'content': 'How may I help you?'},
{'role': 'user', 'content': 'Hi'}
]
For some reason it thinks part of my request contains json data and currently it does not need to send json data for the chatbot section of my app. there is another call by the "assessment portion" of my app that will need to compare text from a json file against user entered text to assess compliance.
Kind regards,
Eddie Van Halen
The text was updated successfully, but these errors were encountered:
We have released a new major version of our SDK, and we recommend upgrading promptly.
Regarding this new sdk...
I'll admit it I'm a newb. I've been using ChatGPT to create a rather extensive app that has been working great. I took a break from the project and suddenly i could not get answers from the api. I installed wsl and ubuntu did the whole grit thing and still i am unable to resolve the errors in my code. GPT4 Turbo is of no help with the issue and despite my best efforts I've killed a couple of days work on the project effectively going in circles attempting to fix the issue. If there is anybody willing to take a look at my code and advise me on how I can get things going again, I would be most grateful...
Here is my code as is now
client = OpenAI()
Load environment variables from the .env file
load_dotenv()
Retrieve and set the API key from the .env file
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
Define the model to be used
model_id = "gpt-4-turbo-2024-04-09" # Replace with the correct model ID you are using
def chatgpt_conversation(conversation_log):
print("Debug - Sending message to OpenAI: ", conversation_log[-1]['content'])
Example usage
conversation_history = [
{'role': 'user', 'content': 'How may I help you?'},
{'role': 'user', 'content': 'Hi'}
]
updated_conversation = chatgpt_conversation(conversation_history)
print("Final conversation log:", updated_conversation)
For some reason it thinks part of my request contains json data and currently it does not need to send json data for the chatbot section of my app. there is another call by the "assessment portion" of my app that will need to compare text from a json file against user entered text to assess compliance.
Kind regards,
Eddie Van Halen
The text was updated successfully, but these errors were encountered: