|
|
|
|
|
by frob
1036 days ago
|
|
Interesting project. How do you propose to sanitize the results? I used your example endpoint above and called it for chartreuse. Instead of just giving me a direct hex code like `#0000FF` for the blue example, it returned `The hex code for chartreuse in CSS is #7FFF00.`, which I'm pretty sure most systems would choke on. It seems to do this for a about 1/3 to 1/4 of my queries. Asking for a color it doesn't like causes it to choke and return an "I'm sorry, I cannot blah blah blah" response. |
|
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