import { removeObjectEmptyFields } from "https://deno.land/x/windmill_helpers@v1.0.0/mod.ts";
import {
Configuration,
CreateCompletionRequest,
OpenAIApi,
} from "npm:openai@3.1.0";
/**
* You can read about the parameters at
* https://beta.openai.com/docs/api-reference/completions/create
*/
type Openai = {
api_key: string;
organization_id: string;
};
export async function main(
auth: Openai,
model = "text-davinci-003",
prompt?: string,
suffix?: string,
max_tokens?: number,
temperature?: number,
top_p?: number,
n?: number,
stream?: boolean,
logprobs?: number,
echo?: boolean,
stop?: string,
presence_penalty?: number,
frequency_penalty?: number,
best_of?: number,
logit_bias?: object,
) {
const configuration = new Configuration({
apiKey: auth.api_key,
organization: auth.organization_id,
});
const openai = new OpenAIApi(configuration);
const request = removeObjectEmptyFields({
model,
prompt,
suffix,
max_tokens,
temperature,
top_p,
n,
stream,
logprobs,
echo,
stop,
presence_penalty,
frequency_penalty,
best_of,
logit_bias,
}) as CreateCompletionRequest;
const response = await openai.createCompletion(request);
return response.data;
}
Submitted by admin 480 days ago
import { removeObjectEmptyFields } from 'https://deno.land/x/windmill_helpers@v1.0.0/mod.ts'
import { Configuration, CreateCompletionRequest, OpenAIApi } from "npm:openai@3.1.0"
/**
* You can read about the parameters at
* https://beta.openai.com/docs/api-reference/completions/create
*/
type Openai = {
api_key: string;
organization_id: string;
};
export async function main(
auth: Openai,
model = 'text-davinci-003',
prompt?: string,
suffix?: string,
max_tokens?: number,
temperature?: number,
top_p?: number,
n?: number,
stream?: boolean,
logprobs?: number,
echo?: boolean,
stop?: string,
presence_penalty?: number,
frequency_penalty?: number,
best_of?: number,
logit_bias?: object
) {
const configuration = new Configuration({
apiKey: auth.api_key,
organization: auth.organization_id
});
const openai = new OpenAIApi(configuration);
const request = removeObjectEmptyFields({
model,
prompt,
suffix,
max_tokens,
temperature,
top_p,
n,
stream,
logprobs,
echo,
stop,
presence_penalty,
frequency_penalty,
best_of,
logit_bias
}) as CreateCompletionRequest
const response = await openai.createCompletion(request)
return response.data
}
Submitted by admin 483 days ago
import type { Resource } from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { removeObjectEmptyFields } from 'https://deno.land/x/windmill_helpers@v1.0.0/mod.ts'
import { Configuration, CreateCompletionRequest, OpenAIApi } from "npm:openai@3.1.0"
/**
* You can read about the parameters at
* https://beta.openai.com/docs/api-reference/completions/create
*/
export async function main(
auth: Resource<'openai'>,
model = 'text-davinci-003',
prompt?: string,
suffix?: string,
max_tokens?: number,
temperature?: number,
top_p?: number,
n?: number,
stream?: boolean,
logprobs?: number,
echo?: boolean,
stop?: string,
presence_penalty?: number,
frequency_penalty?: number,
best_of?: number,
logit_bias?: object
) {
const configuration = new Configuration({
apiKey: auth.api_key,
organization: auth.organization_id
});
const openai = new OpenAIApi(configuration);
const request = removeObjectEmptyFields({
model,
prompt,
suffix,
max_tokens,
temperature,
top_p,
n,
stream,
logprobs,
echo,
stop,
presence_penalty,
frequency_penalty,
best_of,
logit_bias
}) as CreateCompletionRequest
const response = await openai.createCompletion(request)
return response.data
}
Submitted by adam186 612 days ago
import type { Resource } from "https://deno.land/x/windmill@v1.70.1/mod.ts";
import { removeObjectEmptyFields } from 'https://deno.land/x/windmill_helpers@v1.0.0/mod.ts'
import { Configuration, CreateCompletionRequest, OpenAIApi } from "npm:openai@3.1.0"
/**
* You can read about the parameters at
* https://beta.openai.com/docs/api-reference/completions/create
*/
export async function main(
auth: Resource<'openai'>,
model = 'text-davinci-003',
prompt?: string,
suffix?: string,
max_tokens?: number,
temperature?: number,
top_p?: number,
n?: number,
stream?: boolean,
logprobs?: number,
echo?: boolean,
stop?: string,
presence_penalty?: number,
frequency_penalty?: number,
best_of?: number,
logit_bias?: object
) {
const configuration = new Configuration({
apiKey: auth.api_key,
organization: auth.organization_id
});
const openai = new OpenAIApi(configuration);
const request = removeObjectEmptyFields({
model,
prompt,
suffix,
max_tokens,
temperature,
top_p,
n,
stream,
logprobs,
echo,
stop,
presence_penalty,
frequency_penalty,
best_of,
logit_bias
}) as CreateCompletionRequest
const response = await openai.createCompletion(request)
return response.data
}
Submitted by adam186 646 days ago
import type { Resource } from "https://deno.land/x/windmill@v1.52.0/mod.ts";
import { removeObjectEmptyFields } from 'https://deno.land/x/windmill_helpers@v1.0.0/mod.ts'
import { Configuration, CreateCompletionRequest, OpenAIApi } from "npm:openai@3.1.0"
/**
* You can read about the parameters at
* https://beta.openai.com/docs/api-reference/completions/create
*/
export async function main(
auth: Resource<'openai'>,
model = 'text-davinci-003',
prompt?: string,
suffix?: string,
max_tokens?: number,
temperature?: number,
top_p?: number,
n?: number,
stream?: boolean,
logprobs?: number,
echo?: boolean,
stop?: string,
presence_penalty?: number,
frequency_penalty?: number,
best_of?: number,
logit_bias?: object
) {
const configuration = new Configuration({
apiKey: auth.api_key,
organization: auth.organization_id
});
const openai = new OpenAIApi(configuration);
const request = removeObjectEmptyFields({
model,
prompt,
suffix,
max_tokens,
temperature,
top_p,
n,
stream,
logprobs,
echo,
stop,
presence_penalty,
frequency_penalty,
best_of,
logit_bias
}) as CreateCompletionRequest
const response = await openai.createCompletion(request)
return response.data
}
Submitted by adam186 724 days ago