Hello All,
I am a ChatGPT+ customer.
Following code is not working me:
When I use the “gpt-4-vision-preview” engine - I get “Too Many Requests” error.
I have also tried with older Models; my sample code suggest by chatGPT itself is herewith:
Hello All,
I am a ChatGPT+ customer.
Following code is not working me:
When I use the “gpt-4-vision-preview” engine - I get “Too Many Requests” error.
I have also tried with older Models; my sample code suggest by chatGPT itself is herewith:
where is the code? However If you constantly face this error try Contacting openai from OpenAI helpdesk,
Here is my code; getting “Too many requests” error on myResponse variable; Code is generated by ChatGPT itself
Private Async Sub SendQuery(query As String)
Try
' Replace 'YOUR_API_KEY' with your actual ChatGPT API key
Dim apiKey As String = "YOUR_API_KEY"
' Dim endpoint As String = "https://api.openai.com/v1/engines/davinci/completions"
' Dim endpoint As String = "https://api.openai.com/v1/engines/gpt-4-vision-preview/completions"
Using client As New HttpClient()
client.DefaultRequestHeaders.Add("Authorization", "Bearer " & apiKey)
Dim requestData = New With {
.prompt = query,
.max_tokens = 50 ' Adjust as needed
}
Dim json = Newtonsoft.Json.JsonConvert.SerializeObject(requestData)
Dim content = New StringContent(json, System.Text.Encoding.UTF8, "application/json")
' https://api.openai.com/v1/completions
Dim endpoint As String = "https://api.openai.com/v1/engines/gpt-3.5-turbo-instruct/completions"
Dim response = Await client.PostAsync(endpoint, content)
If response.IsSuccessStatusCode Then
Dim responseContent = Await response.Content.ReadAsStringAsync()
Dim jsonResponse As JObject = JObject.Parse(responseContent)
Dim completion = jsonResponse.SelectToken("choices[0].text").ToString()
' Display the completion in your application (e.g., in a textbox)
TextBox1.Text = completion
Else
' Handle error response
MessageBox.Show("Error: " & response.StatusCode.ToString())
End If
End Using
Catch ex As Exception
' Handle exceptions
MessageBox.Show("Error: " & ex.Message)
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim queryText As String = TextBox1.Text ' Get the query from a textbox
SendQuery(queryText)
End Sub
The code is nonsense.
You will need to write your own code inspired from the API reference (sidebar on the forum), properly accessing AI models on the chat completions method with messages.
Additionally, API is not affected by subscription to ChatGPT plus.
It is a service where you pay for the language data transmitted and received from models, and GPT-4 class AI models are only unlocked after having made a prepay credit to your account (and others would require a still-operational free trial grant).
Trying develop Windows App using VB . net for integrating ChatGPT; have been searching web but haven’t found any references.
Wondering if you have any working samples in VB . net? thnx
Made some progress with the help from OpenAI but am struck at JSON parsing…
Here is my updated code; any help will be greatly appreciated…
Private Async Sub SendQuery(query As String)
Try
' Replace 'YOUR_API_KEY' with your actual ChatGPT API key
Dim apiKey As String = "YOUR_API_KEY" ' Replace with your key
Dim apiKey As String = "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■FIBgSIrG"
Dim endpoint As String = "https://api.openai.com/v1/chat/completions"
' [{"role": "user", "content": query}],
Using client As New HttpClient()
client.DefaultRequestHeaders.Add("Authorization", "Bearer " & apiKey)
Dim requestData = New With {
.messages = New Object() {
New With {.role = "user", .content = query}
},
.model = "gpt-3.5-turbo",
.max_tokens = 50, ' Adjust as needed
.temperature = 0.5
}
Dim json = Newtonsoft.Json.JsonConvert.SerializeObject(requestData)
Dim content = New StringContent(json, System.Text.Encoding.UTF8, "application/json")
Dim response = Await client.PostAsync(endpoint, content)
If response.IsSuccessStatusCode Then
Dim responseContent = Await response.Content.ReadAsStringAsync()
Dim jsonResponse As JObject = JObject.Parse(responseContent)
Dim completion = jsonResponse.SelectToken("choices[0].text").ToString()
' Display the completion in your application (e.g., in a textbox)
TextBox1.Text = completion
Else
' Handle error response
MessageBox.Show("Error: " & response.StatusCode.ToString())
End If
End Using
Catch ex As Exception
' Handle exceptions
MessageBox.Show("Error: " & ex.Message)
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim queryText As String = TextBox1.Text ' Get the query from a textbox
SendQuery(queryText)
End Sub
I am getting an error when parsing with the JSON; OpenAI connection works fine now…
Issue with following lines:
If response.IsSuccessStatusCode Then
Dim responseContent = Await response.Content.ReadAsStringAsync()
Dim jsonResponse As JObject = JObject.Parse(responseContent)
Dim completion = jsonResponse.SelectToken("choices[0].text").ToString()
' Display the completion in your application (e.g., in a textbox)
TextBox1.Text = completion
Else
' Handle error response
MessageBox.Show("Error: " & response.StatusCode.ToString())
End If