ChatGPT与Remix?Api服务在浏览器url地址中对话详解(ChatGPT与人的价值)学会了吗

随心笔谈12个月前发布 admin
92 0

async function runCompletion(messages: any) {
const response=await fetch(
“https://api.openai-proxy.com/v1/chat/completions”,
{
method: “POST”,
headers: {
“Content-Type”: “application/json”,
Authorization: “Bearer ” + process.env.OPENAI_API_KEY,
},
body: JSON.stringify({
model: “gpt-3.5-turbo”,
messages: [{ role: “user”, content: messages }],
}),
}
).then((res)=> res.json())
return await response.choices[0].message.content;
}
export async function loader({ request }: any) {
const url=new URL(request.url);
const text=url.searchParams.get(“text”)!;
return runCompletion(text);
}

© 版权声明

相关文章