#\n\n in the beginning of the outputs

20 messages · Page 1 of 1 (latest)

ruby shell
#

hi, whenever i request https://api.openai.com/v1/completions
{
"model": "text-davinci-003",
"prompt": "what date today",
"max_tokens": 256,
"temperature": 0.7,
"top_p": 1,
"n": 1
}

i got extra \n\n

{
"id": "cmpl-72zbXBGbdV42HxWkyeacV9K5ykFgP",
"object": "text_completion",
"created": 1680947819,
"model": "text-davinci-003",
"choices": [
{
"text": "\n\nToday is August 13, 2020.",
"index": 0,
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 3,
"completion_tokens": 9,
"total_tokens": 12
}
}

#

other example

celest skiff
#

can you not simply strip out any new line /carriage returns from the front of the string?

ruby shell
ruby shell
#

so only me got the \n\n?

celest skiff
#

many languages include a .trim() function for this

ruby shell
#

Yes i know, so its by design right?

celest skiff
#

no, it's just that a large language model can output anything, so you have to do some text conditioning of the result

ruby shell
#

Since i tried in postman and all of my prompt gives extra /n/n

celest skiff
#

or... ask the AI to output it's results in JSON format and then desterilise it

celest skiff
ruby shell
#

Ok so it must be me, thanks

ruby shell
celest skiff
ruby shell
#

i know the solution is to trim it, but i think its unnecessary to be generated by the engine

#

from the ai itself hahahah

celest skiff
#

You should treat all output as unclean and trim it, as best practice