import { Portkey } from "portkey";
interface AppConfig {
model: string;
provider: string;
}
const handler: Chat = async ({ userMessage, appConfig }) => {
const { model, provider } = appConfig;
// highlight-start
const portkey = new Portkey({
Authorization: "Bearer sk-xxxxx",
provider: provider,
// ...additional authorization params
});
const response = await portkey.chat.completions.create({
messages: [{ role: "user", content: userMessage }],
model: model,
});
// highlight-end
return {
message: response.choices[0].message.content,
};
};