-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aef9047
commit d74844f
Showing
33 changed files
with
158 additions
and
2,749 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import OpenAI from 'openai'; | ||
|
||
import logger from '@/lib/logger'; | ||
|
||
const openai = new OpenAI({ | ||
apiKey: process.env.OPENAI_API_KEY, | ||
}); | ||
|
||
interface Props { | ||
message: string; | ||
} | ||
export const getPersonName = async ({ message }: Props) => { | ||
const response = await openai.chat.completions.create({ | ||
model: 'gpt-3.5-turbo', | ||
messages: [ | ||
{ | ||
role: 'system', | ||
content: | ||
"You are a string parser. You will be given a string that contains a person's name. You have to extract the name from the string. Only return the name and nothing else.", | ||
}, | ||
{ | ||
role: 'user', | ||
content: message, | ||
}, | ||
], | ||
temperature: 0.7, | ||
max_tokens: 64, | ||
top_p: 1, | ||
}); | ||
|
||
const name = response.choices[0].message.content; | ||
if (!name) { | ||
logger('Response: ', JSON.stringify(response)); | ||
throw new Error('Name not found'); | ||
} | ||
logger(`Got user ${name}`); | ||
return name; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.