import * as z from "zod"; import { EventStream } from "../lib/event-streams.js"; import { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { CreateCompletionResponse, CreateCompletionResponse$Outbound } from "./createcompletionresponse.js"; import { CreateCompletionResponseStream } from "./createcompletionresponsestream.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * The prompt to generate completions for. * * @remarks * It can be a single string or an array of strings. * It can also be an array of integers or an array of integer arrays, * which allows to pass already tokenized prompt. * If multiple prompts are specified, several choices with corresponding `index` will be returned in the output." */ export type Prompt = string | Array | Array | Array>; export type CreateCompletionLogprobs = number | boolean; /** * Up to 4 sequences where the API will stop generating further tokens. The returned text will contain the stop sequence. * * @remarks */ export type CreateCompletionStop = string | Array; /** * Must be one of `text`, `json_object`, or `grammar`. */ export declare const CreateCompletionType: { readonly Text: "text"; readonly JsonObject: "json_object"; readonly Grammar: "grammar"; }; /** * Must be one of `text`, `json_object`, or `grammar`. */ export type CreateCompletionType = ClosedEnum; /** * JSON schema according to https://json-schema.org/specification that can be provided if `"type": "json_object"`. * * @remarks * Can be provided as a JSON object or a JSON string. * If not provided when `type` is "json_object", it defaults to `{"type": "object"}`. * * Most common fields like `type`, `properties`, `items`, `required` and `anyOf` are supported. * * More sophisticated cases like `oneOf` might not be covered. * * Note: it's an OpenAI API extension. * * Example: `{"type": "object", "properties": {"foo": {"type": "string"}, "bar": {"type": "integer"}}, "required": ["foo"]}` */ export type CreateCompletionSchemaField = {}; /** * Allows to force the model to produce specific output format. * * @remarks * * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. * * Optional JSON schema can be provided as `response_format = {"type": "json_object", "schema": }`. * * **Important:** when using JSON mode, it's crucial to also instruct the model to produce JSON via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. In this case the return value might not be a valid JSON. */ export type CreateCompletionResponseFormat = { /** * Must be one of `text`, `json_object`, or `grammar`. */ type?: CreateCompletionType | null | undefined; /** * JSON schema according to https://json-schema.org/specification that can be provided if `"type": "json_object"`. * * @remarks * Can be provided as a JSON object or a JSON string. * If not provided when `type` is "json_object", it defaults to `{"type": "object"}`. * * Most common fields like `type`, `properties`, `items`, `required` and `anyOf` are supported. * * More sophisticated cases like `oneOf` might not be covered. * * Note: it's an OpenAI API extension. * * Example: `{"type": "object", "properties": {"foo": {"type": "string"}, "bar": {"type": "integer"}}, "required": ["foo"]}` */ schemaField?: CreateCompletionSchemaField | null | undefined; /** * A string representing the grammar when `type` is set to "grammar". * * @remarks * Required when `type` is "grammar". */ grammar?: string | null | undefined; }; /** * What to do if the token count of prompt plus `max_tokens` exceeds the model's context window. * * @remarks * * Passing `truncate` limits the `max_tokens` to at most `context_window_length - prompt_length`. This is the default. * * Passing `error` would trigger a request error. * * The default of 'truncate' is selected as it allows to ask for high `max_tokens` value while respecting the context window length without having to do client-side prompt tokenization. * * Note, that it differs from OpenAI's behavior that matches that of `error`. */ export declare const CreateCompletionContextLengthExceededBehavior: { readonly Truncate: "truncate"; readonly Error: "error"; }; /** * What to do if the token count of prompt plus `max_tokens` exceeds the model's context window. * * @remarks * * Passing `truncate` limits the `max_tokens` to at most `context_window_length - prompt_length`. This is the default. * * Passing `error` would trigger a request error. * * The default of 'truncate' is selected as it allows to ask for high `max_tokens` value while respecting the context window length without having to do client-side prompt tokenization. * * Note, that it differs from OpenAI's behavior that matches that of `error`. */ export type CreateCompletionContextLengthExceededBehavior = ClosedEnum; export type CreateCompletionRequestBody = { /** * The name of the model to use. */ model: string; /** * The prompt to generate completions for. * * @remarks * It can be a single string or an array of strings. * It can also be an array of integers or an array of integer arrays, * which allows to pass already tokenized prompt. * If multiple prompts are specified, several choices with corresponding `index` will be returned in the output." */ prompt: string | Array | Array | Array>; /** * The list of base64 encoded images for visual language completition generation. * * @remarks * They should be formatted as MIME_TYPE,\ * eg. data:image/jpeg;base64,\ * Additionally, the number of images provided should match the number of '\' special token in the prompt */ images?: Array | undefined; /** * The maximum number of tokens to generate in the completion. * * @remarks * * If the token count of your prompt plus `max_tokens` exceed the model's context length, the behavior is depends on `context_length_exceeded_behavior`. By default, `max_tokens` will be lowered to fit in the context window instead of returning an error. */ maxTokens?: number | null | undefined; logprobs?: number | boolean | null | undefined; echo?: boolean | undefined; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. * * @remarks * * We generally recommend altering this or `top_p` but not both. */ temperature?: number | null | undefined; /** * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. * * @remarks * * We generally recommend altering this or `temperature` but not both. */ topP?: number | null | undefined; /** * Top-k sampling is another sampling method where the k most probable next tokens are filtered and the probability mass is redistributed among only those k next tokens. The value of k controls the number of candidates for the next token at each step during text generation. * * @remarks */ topK?: number | null | undefined; /** * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. * * @remarks * * Reasonable value is around 0.1 to 1 if the aim is to just reduce repetitive samples somewhat. If the aim is to strongly suppress repetition, then one can increase the coefficients up to 2, but this can noticeably degrade the quality of samples. Negative values can be used to increase the likelihood of repetition. * * See also `presence_penalty` for penalizing tokens that have at least one appearance at a fixed rate. */ frequencyPenalty?: number | null | undefined; /** * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. * * @remarks * * Reasonable value is around 0.1 to 1 if the aim is to just reduce repetitive samples somewhat. If the aim is to strongly suppress repetition, then one can increase the coefficients up to 2, but this can noticeably degrade the quality of samples. Negative values can be used to increase the likelihood of repetition. * * See also `frequence_penalty` for penalizing tokens at an increasing rate depending on how often they appear. */ presencePenalty?: number | null | undefined; /** * How many completions to generate for each prompt. * * @remarks * * **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`. */ n?: number | null | undefined; /** * Up to 4 sequences where the API will stop generating further tokens. The returned text will contain the stop sequence. * * @remarks */ stop?: string | Array | null | undefined; /** * Allows to force the model to produce specific output format. * * @remarks * * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. * * Optional JSON schema can be provided as `response_format = {"type": "json_object", "schema": }`. * * **Important:** when using JSON mode, it's crucial to also instruct the model to produce JSON via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. In this case the return value might not be a valid JSON. */ responseFormat?: CreateCompletionResponseFormat | null | undefined; /** * Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) * * @remarks * as they become available, with the stream terminated by a `data: [DONE]` message. */ stream?: boolean | null | undefined; /** * What to do if the token count of prompt plus `max_tokens` exceeds the model's context window. * * @remarks * * Passing `truncate` limits the `max_tokens` to at most `context_window_length - prompt_length`. This is the default. * * Passing `error` would trigger a request error. * * The default of 'truncate' is selected as it allows to ask for high `max_tokens` value while respecting the context window length without having to do client-side prompt tokenization. * * Note, that it differs from OpenAI's behavior that matches that of `error`. */ contextLengthExceededBehavior?: CreateCompletionContextLengthExceededBehavior | undefined; /** * A unique identifier representing your end-user, which can help monitor and detect abuse */ user?: string | null | undefined; /** * User-provided speculation. * * @remarks * * It is useful for situations like partial text rewriting when the caller has a strong guess of what the generation might look like. This speculative guess can be used by Fireworks to speed up the response considerably. * * The speculation is always validated using deterministic (greedy) generation. I.e., the server will find the longest prefix of the "speculation" field that matches the model's generation with temperature=0. After that, it will proceed with normal generation respecting request parameters, including the temperature. */ speculation?: string | null | undefined; minP?: number | undefined; typicalP?: number | undefined; repetitionPenalty?: number | undefined; topLogprobs?: number | null | undefined; echoLast?: number | null | undefined; mirostatTarget?: number | null | undefined; mirostatLr?: number | undefined; minTokens?: number | undefined; ignoreEos?: boolean | undefined; promptCacheMaxLen?: number | null | undefined; rawOutput?: boolean | undefined; logitBias?: { [k: string]: number; } | undefined; forcedGeneration?: string | null | undefined; getLastActivation?: boolean | undefined; }; export type CreateCompletionResponse1 = CreateCompletionResponse | EventStream; /** @internal */ export declare const Prompt$inboundSchema: z.ZodType; /** @internal */ export type Prompt$Outbound = string | Array | Array | Array>; /** @internal */ export declare const Prompt$outboundSchema: z.ZodType; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export declare namespace Prompt$ { /** @deprecated use `Prompt$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `Prompt$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `Prompt$Outbound` instead. */ type Outbound = Prompt$Outbound; } export declare function promptToJSON(prompt: Prompt): string; export declare function promptFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const CreateCompletionLogprobs$inboundSchema: z.ZodType; /** @internal */ export type CreateCompletionLogprobs$Outbound = number | boolean; /** @internal */ export declare const CreateCompletionLogprobs$outboundSchema: z.ZodType; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export declare namespace CreateCompletionLogprobs$ { /** @deprecated use `CreateCompletionLogprobs$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `CreateCompletionLogprobs$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `CreateCompletionLogprobs$Outbound` instead. */ type Outbound = CreateCompletionLogprobs$Outbound; } export declare function createCompletionLogprobsToJSON(createCompletionLogprobs: CreateCompletionLogprobs): string; export declare function createCompletionLogprobsFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const CreateCompletionStop$inboundSchema: z.ZodType; /** @internal */ export type CreateCompletionStop$Outbound = string | Array; /** @internal */ export declare const CreateCompletionStop$outboundSchema: z.ZodType; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export declare namespace CreateCompletionStop$ { /** @deprecated use `CreateCompletionStop$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `CreateCompletionStop$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `CreateCompletionStop$Outbound` instead. */ type Outbound = CreateCompletionStop$Outbound; } export declare function createCompletionStopToJSON(createCompletionStop: CreateCompletionStop): string; export declare function createCompletionStopFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const CreateCompletionType$inboundSchema: z.ZodNativeEnum; /** @internal */ export declare const CreateCompletionType$outboundSchema: z.ZodNativeEnum; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export declare namespace CreateCompletionType$ { /** @deprecated use `CreateCompletionType$inboundSchema` instead. */ const inboundSchema: z.ZodNativeEnum<{ readonly Text: "text"; readonly JsonObject: "json_object"; readonly Grammar: "grammar"; }>; /** @deprecated use `CreateCompletionType$outboundSchema` instead. */ const outboundSchema: z.ZodNativeEnum<{ readonly Text: "text"; readonly JsonObject: "json_object"; readonly Grammar: "grammar"; }>; } /** @internal */ export declare const CreateCompletionSchemaField$inboundSchema: z.ZodType; /** @internal */ export type CreateCompletionSchemaField$Outbound = {}; /** @internal */ export declare const CreateCompletionSchemaField$outboundSchema: z.ZodType; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export declare namespace CreateCompletionSchemaField$ { /** @deprecated use `CreateCompletionSchemaField$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `CreateCompletionSchemaField$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `CreateCompletionSchemaField$Outbound` instead. */ type Outbound = CreateCompletionSchemaField$Outbound; } export declare function createCompletionSchemaFieldToJSON(createCompletionSchemaField: CreateCompletionSchemaField): string; export declare function createCompletionSchemaFieldFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const CreateCompletionResponseFormat$inboundSchema: z.ZodType; /** @internal */ export type CreateCompletionResponseFormat$Outbound = { type: string | null; schema_field?: CreateCompletionSchemaField$Outbound | null | undefined; grammar: string | null; }; /** @internal */ export declare const CreateCompletionResponseFormat$outboundSchema: z.ZodType; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export declare namespace CreateCompletionResponseFormat$ { /** @deprecated use `CreateCompletionResponseFormat$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `CreateCompletionResponseFormat$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `CreateCompletionResponseFormat$Outbound` instead. */ type Outbound = CreateCompletionResponseFormat$Outbound; } export declare function createCompletionResponseFormatToJSON(createCompletionResponseFormat: CreateCompletionResponseFormat): string; export declare function createCompletionResponseFormatFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const CreateCompletionContextLengthExceededBehavior$inboundSchema: z.ZodNativeEnum; /** @internal */ export declare const CreateCompletionContextLengthExceededBehavior$outboundSchema: z.ZodNativeEnum; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export declare namespace CreateCompletionContextLengthExceededBehavior$ { /** @deprecated use `CreateCompletionContextLengthExceededBehavior$inboundSchema` instead. */ const inboundSchema: z.ZodNativeEnum<{ readonly Truncate: "truncate"; readonly Error: "error"; }>; /** @deprecated use `CreateCompletionContextLengthExceededBehavior$outboundSchema` instead. */ const outboundSchema: z.ZodNativeEnum<{ readonly Truncate: "truncate"; readonly Error: "error"; }>; } /** @internal */ export declare const CreateCompletionRequestBody$inboundSchema: z.ZodType; /** @internal */ export type CreateCompletionRequestBody$Outbound = { model: string; prompt: string | Array | Array | Array>; images?: Array | undefined; max_tokens: number | null; logprobs?: number | boolean | null | undefined; echo: boolean; temperature: number | null; top_p: number | null; top_k?: number | null | undefined; frequency_penalty: number | null; presence_penalty: number | null; n: number | null; stop?: string | Array | null | undefined; response_format?: CreateCompletionResponseFormat$Outbound | null | undefined; stream: boolean | null; context_length_exceeded_behavior?: string | undefined; user?: string | null | undefined; speculation?: string | null | undefined; min_p: number; typical_p: number; repetition_penalty: number; top_logprobs?: number | null | undefined; echo_last?: number | null | undefined; mirostat_target?: number | null | undefined; mirostat_lr: number; min_tokens: number; ignore_eos: boolean; prompt_cache_max_len?: number | null | undefined; raw_output: boolean; logit_bias?: { [k: string]: number; } | undefined; forced_generation?: string | null | undefined; get_last_activation: boolean; }; /** @internal */ export declare const CreateCompletionRequestBody$outboundSchema: z.ZodType; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export declare namespace CreateCompletionRequestBody$ { /** @deprecated use `CreateCompletionRequestBody$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `CreateCompletionRequestBody$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `CreateCompletionRequestBody$Outbound` instead. */ type Outbound = CreateCompletionRequestBody$Outbound; } export declare function createCompletionRequestBodyToJSON(createCompletionRequestBody: CreateCompletionRequestBody): string; export declare function createCompletionRequestBodyFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const CreateCompletionResponse1$inboundSchema: z.ZodType; /** @internal */ export type CreateCompletionResponse1$Outbound = CreateCompletionResponse$Outbound | never; /** @internal */ export declare const CreateCompletionResponse1$outboundSchema: z.ZodType; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export declare namespace CreateCompletionResponse1$ { /** @deprecated use `CreateCompletionResponse1$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `CreateCompletionResponse1$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `CreateCompletionResponse1$Outbound` instead. */ type Outbound = CreateCompletionResponse1$Outbound; } export declare function createCompletionResponse1ToJSON(createCompletionResponse1: CreateCompletionResponse1): string; export declare function createCompletionResponse1FromJSON(jsonString: string): SafeParseResult; //# sourceMappingURL=createcompletionop.d.ts.map