Chicha
Difficulty using OpenAPI registry parameters with createRoute
app.openapi(
createRoute({
method: "get",
path: "/openai/models",
responses: { 200: { description: "Respond a message" } },
}),
async (c) => {
const openai = c.get("OpenAIClient");
const list = await openai.models.list();
return c.json(list);
}
);
app.openapi(
createRoute({
method: "post",
path: "/openai/content-generator/aboutUs",
requestBody: {
content: {
"application/json": {
schema: {
type: "object",
properties: {
company: { type: "string" },
companySpec: { type: "string" },
},
required: ["company", "companySpec"],
},
},
},
},
responses: {
200: { description: "Respond a message" },
},
}),
async (c) => {
const { company, companySpec } = await c.req.json();
websiteContent.company = company;
const openai = c.get("OpenAIClient");
const aboutUs = await openai.chat.completions.create({
model: "gpt-4-0125-preview",
messages: [
{
role: "system",
content:
generate me a brief description of ${company} company to put on the website in about us section. the company specialties are ${companySpec}
,
},
],
});
websiteContent.aboutUs = aboutUs.choices[0].message.content;
return c.json(aboutUs.choices[0].message.content);
}
);3 replies