/**
 * OpenAI Node - Version 2
 * Discriminator: resource=text, operation=response
 */


interface Credentials {
  openAiApi: CredentialReference;
}

/** Generate a model response with GPT 3, 4, 5, etc. using Responses API */
export type LcOpenAiV2TextResponseParams = {
  resource: 'text';
  operation: 'response';
/**
 * Model
 * @searchListMethod modelSearch
 * @default {"mode":"list","value":""}
 */
    modelId?: { __rl: true; mode: 'list' | 'id'; value: string; cachedResultName?: string };
/**
 * Messages
 * @default {"values":[{"type":"text"}]}
 */
    responses?: {
        /** Message
     */
    values?: Array<{
      /** Type
       * @default text
       */
      type?: 'text' | 'image' | 'file' | Expression<string>;
      /** Role in shaping the model's response, it tells the model how it should behave and interact with the user
       * @default user
       */
      role?: 'user' | 'assistant' | 'system' | Expression<string>;
      /** The content of the message to be send
       * @displayOptions.show { type: ["text"] }
       */
      content?: string | Expression<string>;
      /** Image Type
       * @displayOptions.show { type: ["image"] }
       * @default url
       */
      imageType?: 'url' | 'fileId' | 'base64' | Expression<string>;
      /** URL of the image to be sent
       * @displayOptions.show { type: ["image"], imageType: ["url"] }
       */
      imageUrl?: string | Expression<string>;
      /** Name of the binary property which contains the image(s)
       * @hint The name of the input field containing the binary file data to be processed
       * @displayOptions.show { type: ["image"], imageType: ["base64"] }
       * @default data
       */
      binaryPropertyName?: string | Expression<string>;
      /** ID of the file to be sent
       * @displayOptions.show { type: ["image"], imageType: ["fileId"] }
       */
      fileId?: string | Expression<string>;
      /** The detail level of the image to be sent to the model
       * @displayOptions.show { type: ["image"] }
       * @default auto
       */
      imageDetail?: 'auto' | 'low' | 'high' | Expression<string>;
      /** File Type
       * @displayOptions.show { type: ["file"] }
       * @default url
       */
      fileType?: 'url' | 'fileId' | 'base64' | Expression<string>;
      /** URL of the file to be sent. Accepts base64 encoded files as well.
       * @displayOptions.show { type: ["file"], fileType: ["url"] }
       */
      fileUrl?: string | Expression<string>;
      /** ID of the file to be sent
       * @displayOptions.show { type: ["file"], fileType: ["fileId"] }
       */
      fileId?: string | Expression<string>;
      /** Name of the binary property which contains the file
       * @hint The name of the input field containing the binary file data to be processed
       * @displayOptions.show { type: ["file"], fileType: ["base64"] }
       * @default data
       */
      binaryPropertyName?: string | Expression<string>;
      /** File Name
       * @displayOptions.show { type: ["file"], fileType: ["base64"] }
       */
      fileName?: string | Expression<string>;
    }>;
  };
/**
 * Whether to return a simplified version of the response instead of the raw data
 * @default true
 */
    simplify?: boolean | Expression<boolean>;
/**
 * Hide Tools
 * @displayOptions.show { modelId: ["gpt-3.5-turbo-16k-0613", "dall-e-3", "text-embedding-3-large", "dall-e-2", "whisper-1", "tts-1-hd-1106", "tts-1-hd", "gpt-4-0314", "text-embedding-3-small", "gpt-4-32k-0314", "gpt-3.5-turbo-0301", "gpt-4-vision-preview", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-instruct-0914", "tts-1", "davinci-002", "gpt-3.5-turbo-instruct", "babbage-002", "tts-1-1106", "text-embedding-ada-002"] }
 * @default hide
 */
    hideTools?: unknown;
/**
 * Built-in Tools
 * @default {}
 */
    builtInTools?: {
    /** Web Search
     * @default {"searchContextSize":"medium"}
     */
    webSearch?: {
    /** High level guidance for the amount of context window space to use for the search
     * @default medium
     */
    searchContextSize?: 'low' | 'medium' | 'high' | Expression<string>;
    /** Comma-separated list of domains to search. Only domains in this list will be searched.
     */
    allowedDomains?: string | Expression<string>;
    /** Country
     */
    country?: string | Expression<string>;
    /** City
     */
    city?: string | Expression<string>;
    /** Region
     */
    region?: string | Expression<string>;
  };
    /** File Search
     * @default {"vectorStoreIds":"[]"}
     */
    fileSearch?: {
    /** The vector store IDs to use for the file search. Vector stores are managed via OpenAI Dashboard.
     * @default []
     */
    vectorStoreIds?: IDataObject | string | Expression<string>;
    /** Filters
     * @default {}
     */
    filters?: IDataObject | string | Expression<string>;
    /** Max Results
     * @default 1
     */
    maxResults?: number | Expression<number>;
  };
    /** Whether to allow the model to execute code in a sandboxed environment
     * @default true
     */
    codeInterpreter?: boolean | Expression<boolean>;
  };
/**
 * Options
 * @default {}
 */
    options?: {
    /** The conversation that this response belongs to. Input items and output items from this response are automatically added to this conversation after this response completes.
     */
    conversationId?: string | Expression<string>;
    /** Specify additional output data to include in the model response
     * @default []
     */
    include?: Array<'code_interpreter_call.outputs' | 'computer_call_output.output.image_url' | 'file_search_call.results' | 'message.input_image.image_url' | 'message.output_text.logprobs' | 'reasoning.encrypted_content' | 'web_search_call.action.sources'>;
    /** Instructions for the model to follow
     */
    instructions?: string | Expression<string>;
    /** The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768).
     * @default 16
     */
    maxTokens?: number | Expression<number>;
    /** The maximum number of tool iteration cycles the LLM will run before stopping. A single iteration can contain multiple tool calls. Set to 0 for no limit.
     * @default 15
     */
    maxToolsIterations?: number | Expression<number>;
    /** The maximum number of total calls to built-in tools that can be processed in a response. This maximum number applies across all built-in tool calls, not per individual tool. Any further attempts to call a tool by the model will be ignored.
     * @default 15
     */
    maxToolCalls?: number | Expression<number>;
    /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
     * @default {}
     */
    metadata?: IDataObject | string | Expression<string>;
    /** Whether to allow parallel tool calls. If true, the model can call multiple tools at once.
     * @default false
     */
    parallelToolCalls?: boolean | Expression<boolean>;
    /** The ID of the previous response to continue from. Cannot be used in conjunction with Conversation ID.
     */
    previousResponseId?: string | Expression<string>;
    /** Configure the reusable prompt template configured via OpenAI Dashboard. &lt;a href="https://platform.openai.com/docs/guides/prompt-engineering#reusable-prompts"&gt;Learn more&lt;/a&gt;.
     * @default {"promptOptions":[{"promptId":""}]}
     */
    promptConfig?: {
        /** Prompt
     */
    promptOptions?: {
      /** The unique identifier of the prompt template to use
       */
      promptId?: string | Expression<string>;
      /** Optional version of the prompt template
       */
      version?: string | Expression<string>;
      /** Variables to be substituted into the prompt template
       * @default {}
       */
      variables?: IDataObject | string | Expression<string>;
    };
  };
    /** Used by OpenAI to cache responses for similar requests to optimize your cache hit rates
     */
    promptCacheKey?: string | Expression<string>;
    /** Reasoning
     * @default {"reasoningOptions":[{"effort":"medium","summary":"none"}]}
     */
    reasoning?: {
        /** Reasoning
     */
    reasoningOptions?: {
      /** Effort
       * @default medium
       */
      effort?: 'low' | 'medium' | 'high' | Expression<string>;
      /** A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process.
       * @default auto
       */
      summary?: 'none' | 'auto' | 'concise' | 'detailed' | Expression<string>;
    };
  };
    /** A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies. The IDs should be a string that uniquely identifies each user.
     */
    safetyIdentifier?: string | Expression<string>;
    /** The service tier to use for the request
     * @default auto
     */
    serviceTier?: 'auto' | 'flex' | 'default' | 'priority' | Expression<string>;
    /** Whether to store the generated model response for later retrieval via API
     * @default true
     */
    store?: boolean | Expression<boolean>;
    /** Output Format
     * @default {"textOptions":[{"type":"text"}]}
     */
    textFormat?: {
        /** Text
     */
    textOptions?: {
      /** Type
       */
      type?: 'text' | 'json_schema' | 'json_object' | Expression<string>;
      /** Verbosity
       * @default medium
       */
      verbosity?: 'low' | 'medium' | 'high' | Expression<string>;
      /** The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
       * @displayOptions.show { type: ["json_schema"] }
       * @default my_schema
       */
      name?: string | Expression<string>;
      /** The schema of the response format
       * @displayOptions.show { type: ["json_schema"] }
       */
      schema?: IDataObject | string | Expression<string>;
      /** The description of the response format
       * @displayOptions.show { type: ["json_schema"] }
       */
      description?: string | Expression<string>;
      /** Whether to require that the AI will always generate responses that match the provided JSON Schema
       * @displayOptions.show { type: ["json_schema"] }
       * @default false
       */
      strict?: boolean | Expression<boolean>;
    };
  };
    /** An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability
     * @default 0
     */
    topLogprobs?: number | Expression<number>;
    /** 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. We generally recommend altering this or top_p but not both
     * @default 1
     */
    temperature?: number | Expression<number>;
    /** An alternative to sampling with temperature, controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.
     * @default 1
     */
    topP?: number | Expression<number>;
    /** Whether to truncate the input to the model's context window size. When disabled will throw a 400 error instead.
     * @default false
     */
    truncation?: boolean | Expression<boolean>;
    /** Background Mode
     * @default {"values":[{"backgroundMode":true}]}
     */
    backgroundMode?: {
        /** Bakground
     */
    values?: {
      /** Whether to run the model in background mode. If true, the model will run in background mode.
       * @default false
       */
      enabled?: boolean | Expression<boolean>;
      /** The timeout for the background mode in seconds. If 0, the timeout is infinite.
       * @default 300
       */
      timeout?: number | Expression<number>;
    };
  };
  };
};

export interface LcOpenAiV2TextResponseSubnodeConfig {
  tools?: ToolInstance[];
  memory?: MemoryInstance;
}

export type LcOpenAiV2TextResponseNode = {
  type: '@n8n/n8n-nodes-langchain.openAi';
  version: 2;
  credentials?: Credentials;
  isTrigger: true;
  config: NodeConfig<LcOpenAiV2TextResponseParams> & { subnodes?: LcOpenAiV2TextResponseSubnodeConfig };
};