Show HN: Superfunctions – AI prompt templates as an API
42 points| trentearl | 2 years ago |superfunctions.versoly.page
I'm working on a web app that allows Ai prompts to function as an API. I want to make it easier for developers to use Ai. I've found it painful to monitor, cache, and iterate on prompts. superfunctions.com is designed to be the simplest building block to create Ai powered apps and scripts.
Simplest example I can think of: You want an api to convert human-named colors to hex You can write a prompt like: "convert {{query.color}} to color, only output hex for css" and then you can call your prompt with https://superfn.com/fn/color-to-hex?color=blue and the response will contain: #0000FF
Watch a short video intro: https://www.youtube.com/watch?v=KdO1TBUbRuA
Login without needing an account: https://superfunctions.com/login/anon
I'm still sorting out a few bugs, but it's usable in it's current state.
This is my first solo project, so I'm very open to feedback and suggestions.
-Trent
Palmik|2 years ago
trentearl|2 years ago
Superfunctions is differentiated because it's much less opinionated and a bit simpler. My philosophy was: we dont know where Ai is taking us so it makes sense to build only one single layer of abstraction over the chatgpt/openai. Because there is no additional abstraction you can easily switch to request directly to the openai api, it can auto-generate the curl/fetch commands.
I've built a few apps that use superfunctions as a backend, one of which is for my day job which is in a very regulated industry and we can use azure apis but we can't just call random websites. So I need it to be more portable.
Of the ones you listed promptitude looks the most similar, and looks really well done.
quickthrower2|2 years ago
And beyond that interesting generative AI use case. The big challenge is thinking what is possible.
The next step might be simple chaining (of APIs not LLMs). So the API calls another API (e.g. get celeb news) then gives that info and a prompt to return a value. For example the same celeb api but with latest news in under 140 characters.
trentearl|2 years ago
Actually, this project is born out of the chaining idea youre talking about. I've been dogfooding this with another app like google translate for language learners (https://languageread.com/ ugly and early for now). It requires a lot of chaining, and splitting text, and composing prompts.
So my first attempt for superfunctions focused on that chaining idea, my approach was prompts backed by AWS stepfunctions. I pretty quickly realized that it would help a lot to have a more primitive layer, so I switched focus to build a lower level layer that turns prompts into single units of execution.
Right now for that language learning app, I'm chaining everything on the client using bluebird promises (going to blog about this soon), this approach comes with a lot of pain points, so I'm still hoping add that composability/chaining functionality as a layer on top of superfunctions later.
boo-ga-ga|2 years ago
trentearl|2 years ago
Yes the cacheing is super helpful for certain use cases, like composing multiple prompts. I'm working on an app for learning languages via reading, where you see the translated text with grammar and when you hover over a word it shows the matching word from translation to source. This kind of app entails many Ai requests, because youre looping and feeding the result of one prompt into other prompts. Kind of like aws step functions. The cacheing really makes these kind of orchestrated workflows possible from a developer experience perspective.
frob|2 years ago
trentearl|2 years ago
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
mdaniel|2 years ago
Kind of related to that, if a user created a new app, it's weird that the new app would be 403 to that user
trentearl|2 years ago
An app is just way to group multiple related functions/prompts.
It was throwing a 403 because it thought the app didnt belong to your user. Im storing those permissions in the session and recently introduced a bug that only updated the user app permissions on login.
Youre one of the first users, so thanks for reporting that. Let me know if you have any other feedback.
askIoT|2 years ago
yawnxyz|2 years ago