Never forget that Git Command
In the spirit of continiously trying out new tools, I wanted to get my hands on Vercel's edge runtime and play around with OpenAI's API! Fortunately for me, Vercel's own @nutlope had made a pretty awesome Twitter Bio tool using the tools I was trying to learn. You can find out about his project here.
Utilizing @nutlope's demo made this for quite the easy afternoon project. In order to test out the edge runtime it was easy as exporting the correct config in my api file:
export const config = {
runtime: 'edge',
}
Next, we needed to be able to take in an input (the prompt the user would input in the terminal window) and send that to OpenAI's API. OpenAI's API takes in a lot of variables such as the model you want to use, the prompt to send, max_tokens, etc. You can find out more about the parameters that you can tweak here. Below is the current payload we are sending for this demo:
const payload: OpenAIStreamPayload = {
model: 'text-davinci-003',
prompt: `Give me the git command that would do the following: ${prompt}`,
temperature: 0.7,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0,
max_tokens: 200,
stream: true,
n: 1,
}
As I am exploring these AI tools more and more, I am noticing that the integration is the easiest part. The most challenging party becomes the "prompt hacking". As you can tell, mine was rather simplistic: Give me the git command that would do the following:
. I am sure that there is a more efficient prompt I could feed it...
All in all, it is pretty amazing that with the modern day tools at our disposal, we can create something like this within a few short hours!