import { CreateCompletionRequest, CreateCompletionResponse } from "../generated/textGen"; import { Client } from "./client"; import { Stream } from "./stream"; /** * The {@link CreateCompletionRequest} for non-streaming requests. */ export type CreateCompletionRequestNonStream = CreateCompletionRequest & { stream?: false; }; /** * The {@link CreateCompletionRequest} for streaming requests. */ export type CreateCompletionRequestStream = CreateCompletionRequest & { stream: true; }; export declare class CompletionsAPI { private readonly client; constructor(client: Client); /** * Create a non-streaming Completions request. * * @param request - The non-streaming Completions request. * @param endpoint - An optional custom endpoint to call. If not provided, the * endpoint defaults to `https://text.octoai.run/v1/completions`. * * @example * ```ts * import { Client } from "@octoai/client"; * * const client = new Client(process.env.OCTOAI_TOKEN); * * const response = await client.create({ * model: "llama-2-13b-chat", * prompt: "Write a blog about Seattle", * }); * * console.log(response.choices[0].text); * // Seattle is a vibrant and eclectic city... * ``` */ create(request: CreateCompletionRequestNonStream, endpoint?: string): Promise; /** * Create a streaming Completions request. * * @param request - The streaming Completions request. * @param endpoint - An optional custom endpoint to call. If not provided, the * endpoint defaults to `https://text.octoai.run/v1/completions` or the * secureLink API if secureLink is set to true on client instantiation. * * @example * ```ts * import { Client } from "@octoai/client"; * * const client = new Client(process.env.OCTOAI_TOKEN); * * const stream = await client.create({ * model: "llama-2-13b-chat", * prompt: "Write a blog about Seattle", * stream: true, * }); * * let result = ""; * * for await (const chunk of stream) { * result += chunk.choices[0].text; * } * * stream.controller.abort(); * * console.log(result); * // Seattle is a vibrant and eclectic city... * ``` */ create(request: CreateCompletionRequestStream, endpoint?: string): Promise>; }