pkse76
(세기 이)
August 9, 2023, 6:50am
1
hello. It’s nothing else, in order to link with Chat-GPT with CURL, there is an issue while creating Json data.
curl https://api.openai.com/v1/chat/completions -i
-H “Authorization: Bearer $OPENAI_API_KEY”
-H “Content-Type: application/json”
-d ‘{
“model”: “gpt-3.5-turbo”,
“messages”: [{“role”: “user”, “content”: “야!”}]
}’
I want to make an http request as above, but I don’t know how to create the data of the message part in the json data.
JObject.FromObject(
New With{
key.model = “gpt-35-turbo”,
key.prompt = “hi”,
key.message = JArray(key.)
key.max_tokens = 800,
key.temperature = 0.7,
key.frequency_penalty = 0,
key.presence_penalty = 0
}).toString
I have currently created Json data as above, but please guide me on what to do to create the message part of the first curl request.
TY
Hi, in curl request you need to provide your OpenAI API key and message is prompt which you send to ChatGPT.
For Ex.
curl https://api.openai.com/v1/completions
-H “Content-Type: application/json”
-H “Authorization: Bearer Your_API_Key”
-d ‘{
“model”: “text-davinci-003”,
“prompt”: “Say this is a test”,
“max_tokens”: 7,
“temperature”: 0
}’
pkse76
(세기 이)
August 9, 2023, 7:15am
4
Thanks for the answer. But what I’m curious about is
'{
“model”: “gpt-3.5-turbo”,
“messages”: [{“role”: “user”, “content”: “Hey!”}]
}’
I wonder how to make this part into Json format!
loginerror
(Maciej Kuźmicz)
August 9, 2023, 8:48am
6
Hi @pkse76
Please try like so:
Hi @amelt.kavana
Please try like that:
[image]
new JArray(new JObject(new JProperty("text","Salve, mondo!"))).ToString
You might have to import this namespace in the Imports panel to make it work:
Newtonsoft.Json.Linq
(or via hints from the same topic)
Another way would be to have it ready in a text file, and use Read Text File activity to load it to a string variable that you can then pass it in the HTTP Request Body property.
And yet another way, it would be to simply hard-code it as a one line of text in the Body property (you would then escape each double quotation mark with another one), like so:
"{""model"":""gpt-3.5-turbo"",""messages"":[{""role"":""user"",""content"":""Hey!""}]}"
Hi,
You need to pass the data in following way,
JObject.FromObject(New With {
key.model = “gpt-3.5-turbo”,
key.messages = New Object() {
New With {
key.role = “user”,
key.content = “Hey”
}
}
}).ToString()
pkse76
(세기 이)
August 16, 2023, 6:32am
8
That was something I was curious about, thanks for the answer!
pkse76
(세기 이)
August 16, 2023, 6:33am
9
Your sharing has been very helpful! Thanks for the great help!