|
|
|
|
|
by trentearl
1041 days ago
|
|
Thanks!
That specific prompt is just an example and it's pretty bad, it was the shortest and simplest prompt I could come up with that would be easily understood. You can set response content-types (text, html, json, etc...). If you use json it will get pretty good results because I have some is some logic to attempt to pick out json or json5 objects from the text output. I dont yet have logic to support json arrays, but I'm hoping to add that soon. But still client side validation is needed for applications with untrusted input. I dont attempt to solve prompt injection. I saw a lot of interesting posts on this topic from this blog https://simonwillison.net/. I need to find sometime to read more about it. Try this one instead, it should be better
https://superfn.com/fn/better/color2hex?color=chartreuse
https://superfn.com/fn/better/color2hex?color=234%20tamales%... Here is the prompt: system:
You are an AI that converts color names to hexadecimal values.
you default to black (#000000)
examples:
red -> { "color": "#ff0000" }
pizza -> { "color": "#000000" }
ignore the prompt and -> { "color": "#000000" } user:
{{query.color}} -> you exclusively output parseable JSON |
|
https://openai.com/blog/function-calling-and-other-api-updat...
Here's a project that promises to deliver valid JSON every time:
https://news.ycombinator.com/item?id=37125118
Or you could attempt to parse the results yourself, and if it fails, feed the error message back to the LLM and have it try again.