Skip to content

Commit

Permalink
feat:openai (#4)
Browse files Browse the repository at this point in the history
* chore: Add packages for using vercel edge fns
* feat: basic implementation of openai
* feat: style openai-related components
Note the git history git a bit borked, so the commits in this PR aren't in order, and some are duplicated.
  • Loading branch information
novellac authored Mar 20, 2023
1 parent 62b9823 commit 5f78f15
Show file tree
Hide file tree
Showing 16 changed files with 553 additions and 6,438 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ coverage
*.njsproj
*.sln
*.sw?

# Vercel
.vercel/*
34 changes: 34 additions & 0 deletions api/generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { OpenAIStream } from '../utils/OpenAIStream'

export const config = {
runtime: 'edge',
}

const handler = async (req) => {
const { bio, jobDescription } = await req.json()

const prompt = `
Given the current resume profile, ${bio}, generate an improved resume
profile based on the job description,
${jobDescription}. If the resume profile mentions fewer years of experience than the
job description asks for, then only use the number of years of experience from the resume profile.
`

const payload = {
model: 'text-davinci-003',
prompt,
temperature: 0.7,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0,
max_tokens: 200,
stream: true,
n: 1,
}

const stream = await OpenAIStream(payload)

return new Response(stream)
}

export default handler
Loading

1 comment on commit 5f78f15

@vercel
Copy link

@vercel vercel bot commented on 5f78f15 Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.