type Openai = {
api_key: string;
organization_id: string;
};
/**
* Create edit
* Creates a new edit for the provided input, instruction, and parameters.
*/
export async function main(
auth: Openai,
body: {
instruction: string;
model: string | ("text-davinci-edit-001" | "code-davinci-edit-001");
input?: string;
n?: number;
temperature?: number;
top_p?: number;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.openai.com/v1/edits`);
const response = await fetch(url, {
method: "POST",
headers: {
"OpenAI-Organization": auth.organization_id,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.api_key,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 372 days ago
type Openai = {
api_key: string;
organization_id: string;
};
/**
* Create edit
* Creates a new edit for the provided input, instruction, and parameters.
*/
export async function main(
auth: Openai,
body: {
instruction: string;
model: string | ("text-davinci-edit-001" | "code-davinci-edit-001");
input?: string;
n?: number;
temperature?: number;
top_p?: number;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.openai.com/v1/edits`);
const response = await fetch(url, {
method: "POST",
headers: {
"OpenAI-Organization": auth.organization_id,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.api_key,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 895 days ago