/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: c56babc22a20
 */
import { chatComplete } from "../funcs/chatComplete.js";
import { chatStream } from "../funcs/chatStream.js";
import { ClientSDK } from "../lib/sdks.js";
import { unwrapAsync } from "../types/fp.js";
import { convertToParsedChatCompletionResponse, transformToChatCompletionRequest, } from "../extra/structChat.js";
// #endregion imports
export class Chat extends ClientSDK {
    // #region sdk-class-body
    /**
     * Chat Completion with the response parsed in the same format as the input requestFormat.
     *
     * @remarks
     * The response will be parsed back to the initial Zod object passed in the requestFormat field.
     */
    async parse(request, options) {
        const ccr_request = transformToChatCompletionRequest(request);
        const response = await unwrapAsync(chatComplete(this, ccr_request, options));
        const parsed_response = convertToParsedChatCompletionResponse(response, request.responseFormat);
        return parsed_response;
    }
    /**
     * Stream chat completion with a parsed request input.
     *
     * @remarks
     * Unlike the .parse method, this method will return a stream of events containing the JSON response. It will not be parsed back to the initial Zod object.
     * If you need to parse the stream, see the examples/src/async_structured_outputs.ts file.
     */
    async parseStream(request, options) {
        const ccr_request = transformToChatCompletionRequest(request);
        return unwrapAsync(chatStream(this, ccr_request, options));
    }
    // #endregion sdk-class-body
    /**
     * Chat Completion
     */
    async complete(request, options) {
        return unwrapAsync(chatComplete(this, request, options));
    }
    /**
     * Stream chat completion
     *
     * @remarks
     * Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
     */
    async stream(request, options) {
        return unwrapAsync(chatStream(this, request, options));
    }
}
//# sourceMappingURL=chat.js.map