mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-14 08:42:08 +10:00
fix: openai chat completions api upgrade, closes #1586
This commit is contained in:
@ -82,7 +82,7 @@ export const OpenAISettings = () => {
|
|||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>{t`API Key`}</FormLabel>
|
<FormLabel>{t`API Key`}</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input type="password" placeholder="sk-..." {...field} />
|
<Input type="password" placeholder="sk-..." {...field} disabled={isEnabled} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|||||||
@ -17,8 +17,8 @@ type Mood = "casual" | "professional" | "confident" | "friendly";
|
|||||||
export const changeTone = async (text: string, mood: Mood) => {
|
export const changeTone = async (text: string, mood: Mood) => {
|
||||||
const prompt = PROMPT.replace("{mood}", mood).replace("{input}", text);
|
const prompt = PROMPT.replace("{mood}", mood).replace("{input}", text);
|
||||||
|
|
||||||
const result = await openai().completions.create({
|
const result = await openai().chat.completions.create({
|
||||||
prompt,
|
messages: [{ role: "user", content: prompt }],
|
||||||
model: "gpt-3.5-turbo",
|
model: "gpt-3.5-turbo",
|
||||||
max_tokens: 1024,
|
max_tokens: 1024,
|
||||||
temperature: 0.5,
|
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.`);
|
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) => {
|
export const fixGrammar = async (text: string) => {
|
||||||
const prompt = PROMPT.replace("{input}", text);
|
const prompt = PROMPT.replace("{input}", text);
|
||||||
|
|
||||||
const result = await openai().completions.create({
|
const result = await openai().chat.completions.create({
|
||||||
prompt,
|
messages: [{ role: "user", content: prompt }],
|
||||||
model: "gpt-3.5-turbo",
|
model: "gpt-3.5-turbo",
|
||||||
max_tokens: 1024,
|
max_tokens: 1024,
|
||||||
temperature: 0,
|
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.`);
|
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) => {
|
export const improveWriting = async (text: string) => {
|
||||||
const prompt = PROMPT.replace("{input}", text);
|
const prompt = PROMPT.replace("{input}", text);
|
||||||
|
|
||||||
const result = await openai().completions.create({
|
const result = await openai().chat.completions.create({
|
||||||
prompt,
|
messages: [{ role: "user", content: prompt }],
|
||||||
model: "gpt-3.5-turbo",
|
model: "gpt-3.5-turbo",
|
||||||
max_tokens: 1024,
|
max_tokens: 1024,
|
||||||
temperature: 0,
|
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.`);
|
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