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 { ChatCompletionRequestMessage, ChatCompletionRequestMessage$Outbound } from "./chatcompletionrequestmessage.js"; import { ChatCompletionTool, ChatCompletionTool$Outbound } from "./chatcompletiontool.js"; import { ChatCompletionToolChoiceOption, ChatCompletionToolChoiceOption$Outbound } from "./chatcompletiontoolchoiceoption.js"; import { CreateChatCompletionResponse, CreateChatCompletionResponse$Outbound } from "./createchatcompletionresponse.js"; import { CreateChatCompletionStreamResponse } from "./createchatcompletionstreamresponse.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * Up to 4 sequences where the API will stop generating further tokens. The returned text will contain the stop sequence. * * @remarks */ export type Stop = string | Array; /** * Must be one of `text`, `json_object`, or `grammar`. */ export declare const CreateChatCompletionType: { readonly Text: "text"; readonly JsonObject: "json_object"; readonly Grammar: "grammar"; }; /** * Must be one of `text`, `json_object`, or `grammar`. */ export type CreateChatCompletionType = 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 SchemaField = {}; /** * 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 ResponseFormat = { /** * Must be one of `text`, `json_object`, or `grammar`. */ type?: CreateChatCompletionType | 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?: SchemaField | 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 ContextLengthExceededBehavior: { 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 ContextLengthExceededBehavior = ClosedEnum; export type CreateChatCompletionLogprobs = number | boolean; export type CreateChatCompletionRequestBody = { /** * The name of the model to use. */ model: string; /** * A list of messages comprising the conversation so far. */ messages: Array; /** * A list of tools the model may call. Currently, only functions are supported as a tool. * * @remarks * Use this to provide a list of functions the model may generate JSON inputs for. * See the guide for more information and the list of supported models: https://docs.fireworks.ai/docs/function-calling#supported-models */ tools?: Array | undefined; /** * Controls which (if any) tool is called by the model. * * @remarks * `none` means the model will not call any tool and instead generates a message. * `auto` means the model can pick between generating a message or calling one or more tools. * `required` or "any" means the model must call one or more tools. * Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. * * `none` is the default when no tools are present. `auto` is the default if tools are present. */ toolChoice?: ChatCompletionToolChoiceOption | undefined; /** * The maximum number of tokens to generate in the completion. * * @remarks * * If the token count of your prompt (previous messages) 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 | undefined; /** * The size to which to truncate chat prompts. Earlier user/assistant messages will be evicted to fit the prompt into this length. * * @remarks * * This should usually be set to a number << the max context size of the model, to allow enough remaining tokens for generating a response. * * If omitted, you may receive "prompt too long" errors in your responses as conversations grow. Note that even with this set, you may still receive "prompt too long" errors if individual messages are too long for the model context window. */ promptTruncateLen?: number | null | 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?: ResponseFormat | null | undefined; stream?: boolean | 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?: ContextLengthExceededBehavior | 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; logprobs?: number | boolean | null | undefined; topLogprobs?: number | null | undefined; echo?: boolean | 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 CreateChatCompletionResponse1 = CreateChatCompletionResponse | EventStream; /** @internal */ export declare const Stop$inboundSchema: z.ZodType; /** @internal */ export type Stop$Outbound = string | Array; /** @internal */ export declare const Stop$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 Stop$ { /** @deprecated use `Stop$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `Stop$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `Stop$Outbound` instead. */ type Outbound = Stop$Outbound; } export declare function stopToJSON(stop: Stop): string; export declare function stopFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const CreateChatCompletionType$inboundSchema: z.ZodNativeEnum; /** @internal */ export declare const CreateChatCompletionType$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 CreateChatCompletionType$ { /** @deprecated use `CreateChatCompletionType$inboundSchema` instead. */ const inboundSchema: z.ZodNativeEnum<{ readonly Text: "text"; readonly JsonObject: "json_object"; readonly Grammar: "grammar"; }>; /** @deprecated use `CreateChatCompletionType$outboundSchema` instead. */ const outboundSchema: z.ZodNativeEnum<{ readonly Text: "text"; readonly JsonObject: "json_object"; readonly Grammar: "grammar"; }>; } /** @internal */ export declare const SchemaField$inboundSchema: z.ZodType; /** @internal */ export type SchemaField$Outbound = {}; /** @internal */ export declare const SchemaField$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 SchemaField$ { /** @deprecated use `SchemaField$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `SchemaField$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `SchemaField$Outbound` instead. */ type Outbound = SchemaField$Outbound; } export declare function schemaFieldToJSON(schemaField: SchemaField): string; export declare function schemaFieldFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const ResponseFormat$inboundSchema: z.ZodType; /** @internal */ export type ResponseFormat$Outbound = { type: string | null; schema_field?: SchemaField$Outbound | null | undefined; grammar: string | null; }; /** @internal */ export declare const ResponseFormat$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 ResponseFormat$ { /** @deprecated use `ResponseFormat$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `ResponseFormat$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `ResponseFormat$Outbound` instead. */ type Outbound = ResponseFormat$Outbound; } export declare function responseFormatToJSON(responseFormat: ResponseFormat): string; export declare function responseFormatFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const ContextLengthExceededBehavior$inboundSchema: z.ZodNativeEnum; /** @internal */ export declare const ContextLengthExceededBehavior$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 ContextLengthExceededBehavior$ { /** @deprecated use `ContextLengthExceededBehavior$inboundSchema` instead. */ const inboundSchema: z.ZodNativeEnum<{ readonly Truncate: "truncate"; readonly Error: "error"; }>; /** @deprecated use `ContextLengthExceededBehavior$outboundSchema` instead. */ const outboundSchema: z.ZodNativeEnum<{ readonly Truncate: "truncate"; readonly Error: "error"; }>; } /** @internal */ export declare const CreateChatCompletionLogprobs$inboundSchema: z.ZodType; /** @internal */ export type CreateChatCompletionLogprobs$Outbound = number | boolean; /** @internal */ export declare const CreateChatCompletionLogprobs$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 CreateChatCompletionLogprobs$ { /** @deprecated use `CreateChatCompletionLogprobs$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `CreateChatCompletionLogprobs$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `CreateChatCompletionLogprobs$Outbound` instead. */ type Outbound = CreateChatCompletionLogprobs$Outbound; } export declare function createChatCompletionLogprobsToJSON(createChatCompletionLogprobs: CreateChatCompletionLogprobs): string; export declare function createChatCompletionLogprobsFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const CreateChatCompletionRequestBody$inboundSchema: z.ZodType; /** @internal */ export type CreateChatCompletionRequestBody$Outbound = { model: string; messages: Array; tools?: Array | undefined; tool_choice?: ChatCompletionToolChoiceOption$Outbound | undefined; max_tokens: number; prompt_truncate_len: number | null; 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?: ResponseFormat$Outbound | null | undefined; stream: boolean; context_length_exceeded_behavior?: string | undefined; user?: string | null | undefined; speculation?: string | null | undefined; min_p: number; typical_p: number; repetition_penalty: number; logprobs?: number | boolean | null | undefined; top_logprobs?: number | null | undefined; echo: boolean; 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 CreateChatCompletionRequestBody$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 CreateChatCompletionRequestBody$ { /** @deprecated use `CreateChatCompletionRequestBody$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `CreateChatCompletionRequestBody$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `CreateChatCompletionRequestBody$Outbound` instead. */ type Outbound = CreateChatCompletionRequestBody$Outbound; } export declare function createChatCompletionRequestBodyToJSON(createChatCompletionRequestBody: CreateChatCompletionRequestBody): string; export declare function createChatCompletionRequestBodyFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const CreateChatCompletionResponse1$inboundSchema: z.ZodType; /** @internal */ export type CreateChatCompletionResponse1$Outbound = CreateChatCompletionResponse$Outbound | never; /** @internal */ export declare const CreateChatCompletionResponse1$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 CreateChatCompletionResponse1$ { /** @deprecated use `CreateChatCompletionResponse1$inboundSchema` instead. */ const inboundSchema: z.ZodType; /** @deprecated use `CreateChatCompletionResponse1$outboundSchema` instead. */ const outboundSchema: z.ZodType; /** @deprecated use `CreateChatCompletionResponse1$Outbound` instead. */ type Outbound = CreateChatCompletionResponse1$Outbound; } export declare function createChatCompletionResponse1ToJSON(createChatCompletionResponse1: CreateChatCompletionResponse1): string; export declare function createChatCompletionResponse1FromJSON(jsonString: string): SafeParseResult; //# sourceMappingURL=createchatcompletionop.d.ts.map