// Copyright (c) The OGX Contributors. // All rights reserved. // // This source code is licensed under the terms described in the LICENSE file in // the root directory of this source tree. // // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../resource'; import { isRequestOptions } from '../../../core'; import * as Core from '../../../core'; import { OpenAICursorPage, type OpenAICursorPageParams } from '../../../pagination'; /** * OGX Inference API for generating completions, chat completions, and embeddings. * * This API provides the raw interface to the underlying models. Three kinds of models are supported: * - LLM models: these models generate "raw" and "chat" (conversational) completions. * - Embedding models: these models generate embeddings to be used for semantic search. * - Rerank models: these models reorder the documents based on their relevance to a query. */ export class Messages extends APIResource { /** * Get the messages in a stored chat completion. */ list( completionId: string, query?: MessageListParams, options?: Core.RequestOptions, ): Core.PagePromise; list( completionId: string, options?: Core.RequestOptions, ): Core.PagePromise; list( completionId: string, query: MessageListParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.PagePromise { if (isRequestOptions(query)) { return this.list(completionId, {}, query); } return this._client.getAPIList( `/v1/chat/completions/${completionId}/messages`, MessageListResponsesOpenAICursorPage, { query, ...options }, ); } } export class MessageListResponsesOpenAICursorPage extends OpenAICursorPage {} /** * A message from a stored chat completion. */ export interface MessageListResponse { /** * The identifier of the chat message. */ id: string; /** * The role of the message author. */ role: 'developer' | 'system' | 'user' | 'assistant' | 'tool'; /** * Annotations for the message, when applicable. */ annotations?: Array<{ [key: string]: unknown }> | null; /** * Audio response data when using audio output modality. */ audio?: { [key: string]: unknown } | null; /** * The text content of the message. */ content?: string | null; /** * Multipart content parts when the original message used content parts. Only text * and image_url parts. */ content_parts?: Array< | MessageListResponse.OpenAIChatCompletionContentPartTextParam | MessageListResponse.OpenAIChatCompletionContentPartImageParam > | null; /** * Deprecated: the name and arguments of a function that should be called. */ function_call?: MessageListResponse.FunctionCall; /** * The name of the message participant. */ name?: string | null; /** * The refusal message generated by the model, when applicable. */ refusal?: string | null; /** * For tool messages, the identifier of the tool call this message responds to. */ tool_call_id?: string | null; /** * The tool calls generated by the message, when applicable. */ tool_calls?: Array< | MessageListResponse.ChatCompletionMessageToolCall | MessageListResponse.ChatCompletionMessageCustomToolCall >; } export namespace MessageListResponse { /** * Text content part for OpenAI-compatible chat completion messages. */ export interface OpenAIChatCompletionContentPartTextParam { /** * The text content of the message. */ text: string; /** * Must be 'text' to identify this as text content. */ type?: 'text'; } /** * Image content part for OpenAI-compatible chat completion messages. */ export interface OpenAIChatCompletionContentPartImageParam { /** * Image URL specification and processing details. */ image_url: OpenAIChatCompletionContentPartImageParam.ImageURL; /** * Must be 'image_url' to identify this as image content. */ type?: 'image_url'; } export namespace OpenAIChatCompletionContentPartImageParam { /** * Image URL specification and processing details. */ export interface ImageURL { /** * URL of the image to include in the message. */ url: string; /** * Level of detail for image processing. Can be 'low', 'high', or 'auto'. */ detail?: 'low' | 'high' | 'auto' | null; } } /** * Deprecated: the name and arguments of a function that should be called. */ export interface FunctionCall { /** * Arguments to pass to the function as a JSON string. */ arguments: string; /** * Name of the function to call. */ name: string; } /** * Tool call specification for OpenAI-compatible chat completion responses. */ export interface ChatCompletionMessageToolCall { /** * Unique identifier for the tool call. */ id: string; /** * Function call details. */ function: ChatCompletionMessageToolCall.Function; /** * Must be 'function' to identify this as a function call. */ type: 'function'; } export namespace ChatCompletionMessageToolCall { /** * Function call details. */ export interface Function { /** * Arguments to pass to the function as a JSON string. */ arguments: string; /** * Name of the function to call. */ name: string; } } /** * A call to a custom tool created by the model. */ export interface ChatCompletionMessageCustomToolCall { /** * The ID of the tool call. */ id: string; /** * The custom tool that the model called. */ custom: ChatCompletionMessageCustomToolCall.Custom; /** * The type of the tool. Always 'custom'. */ type: 'custom'; } export namespace ChatCompletionMessageCustomToolCall { /** * The custom tool that the model called. */ export interface Custom { /** * The input for the custom tool call generated by the model. */ input: string; /** * The name of the custom tool to call. */ name: string; } } } export interface MessageListParams extends OpenAICursorPageParams { /** * Sort order for messages by timestamp. Use "asc" or "desc". Defaults to "asc". */ order?: 'asc' | 'desc' | null; } Messages.MessageListResponsesOpenAICursorPage = MessageListResponsesOpenAICursorPage; export declare namespace Messages { export { type MessageListResponse as MessageListResponse, MessageListResponsesOpenAICursorPage as MessageListResponsesOpenAICursorPage, type MessageListParams as MessageListParams, }; }