mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-14 00:32:35 +10:00
fix: openai chat completions api upgrade, closes #1586
This commit is contained in:
@ -82,7 +82,7 @@ export const OpenAISettings = () => {
|
||||
<FormItem>
|
||||
<FormLabel>{t`API Key`}</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="password" placeholder="sk-..." {...field} />
|
||||
<Input type="password" placeholder="sk-..." {...field} disabled={isEnabled} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
||||
@ -17,8 +17,8 @@ type Mood = "casual" | "professional" | "confident" | "friendly";
|
||||
export const changeTone = async (text: string, mood: Mood) => {
|
||||
const prompt = PROMPT.replace("{mood}", mood).replace("{input}", text);
|
||||
|
||||
const result = await openai().completions.create({
|
||||
prompt,
|
||||
const result = await openai().chat.completions.create({
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
model: "gpt-3.5-turbo",
|
||||
max_tokens: 1024,
|
||||
temperature: 0.5,
|
||||
@ -30,5 +30,5 @@ export const changeTone = async (text: string, mood: Mood) => {
|
||||
throw new Error(t`OpenAI did not return any choices for your text.`);
|
||||
}
|
||||
|
||||
return result.choices[0].text;
|
||||
return result.choices[0].message.content ?? text;
|
||||
};
|
||||
|
||||
@ -15,8 +15,8 @@ Revised Text: """`;
|
||||
export const fixGrammar = async (text: string) => {
|
||||
const prompt = PROMPT.replace("{input}", text);
|
||||
|
||||
const result = await openai().completions.create({
|
||||
prompt,
|
||||
const result = await openai().chat.completions.create({
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
model: "gpt-3.5-turbo",
|
||||
max_tokens: 1024,
|
||||
temperature: 0,
|
||||
@ -28,5 +28,5 @@ export const fixGrammar = async (text: string) => {
|
||||
throw new Error(t`OpenAI did not return any choices for your text.`);
|
||||
}
|
||||
|
||||
return result.choices[0].text;
|
||||
return result.choices[0].message.content ?? text;
|
||||
};
|
||||
|
||||
@ -15,8 +15,8 @@ Revised Text: """`;
|
||||
export const improveWriting = async (text: string) => {
|
||||
const prompt = PROMPT.replace("{input}", text);
|
||||
|
||||
const result = await openai().completions.create({
|
||||
prompt,
|
||||
const result = await openai().chat.completions.create({
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
model: "gpt-3.5-turbo",
|
||||
max_tokens: 1024,
|
||||
temperature: 0,
|
||||
@ -28,5 +28,5 @@ export const improveWriting = async (text: string) => {
|
||||
throw new Error(t`OpenAI did not return any choices for your text.`);
|
||||
}
|
||||
|
||||
return result.choices[0].text;
|
||||
return result.choices[0].message.content ?? text;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user