# frozen_string_literal: true

module OpenAI
  module Models
    module Beta
      # @see OpenAI::Resources::Beta::Threads#create
      class ThreadCreateParams < OpenAI::Internal::Type::BaseModel
        extend OpenAI::Internal::Type::RequestParameters::Converter
        include OpenAI::Internal::Type::RequestParameters

        # @!attribute messages
        #   A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
        #   start the thread with.
        #
        #   @return [Array<OpenAI::Models::Beta::ThreadCreateParams::Message>, nil]
        optional :messages, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::ThreadCreateParams::Message] }

        # @!attribute metadata
        #   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.
        #
        #   @return [Hash{Symbol=>String}, nil]
        optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true

        # @!attribute tool_resources
        #   A set of resources that are made available to the assistant's tools in this
        #   thread. The resources are specific to the type of tool. For example, the
        #   `code_interpreter` tool requires a list of file IDs, while the `file_search`
        #   tool requires a list of vector store IDs.
        #
        #   @return [OpenAI::Models::Beta::ThreadCreateParams::ToolResources, nil]
        optional :tool_resources, -> { OpenAI::Beta::ThreadCreateParams::ToolResources }, nil?: true

        # @!method initialize(messages: nil, metadata: nil, tool_resources: nil, request_options: {})
        #   Some parameter documentations has been truncated, see
        #   {OpenAI::Models::Beta::ThreadCreateParams} for more details.
        #
        #   @param messages [Array<OpenAI::Models::Beta::ThreadCreateParams::Message>] A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
        #
        #   @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
        #
        #   @param tool_resources [OpenAI::Models::Beta::ThreadCreateParams::ToolResources, nil] A set of resources that are made available to the assistant's tools in this thre
        #
        #   @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]

        class Message < OpenAI::Internal::Type::BaseModel
          # @!attribute content
          #   The text contents of the message.
          #
          #   @return [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>]
          required :content, union: -> { OpenAI::Beta::ThreadCreateParams::Message::Content }

          # @!attribute role
          #   The role of the entity that is creating the message. Allowed values include:
          #
          #   - `user`: Indicates the message is sent by an actual user and should be used in
          #     most cases to represent user-generated messages.
          #   - `assistant`: Indicates the message is generated by the assistant. Use this
          #     value to insert messages from the assistant into the conversation.
          #
          #   @return [Symbol, OpenAI::Models::Beta::ThreadCreateParams::Message::Role]
          required :role, enum: -> { OpenAI::Beta::ThreadCreateParams::Message::Role }

          # @!attribute attachments
          #   A list of files attached to the message, and the tools they should be added to.
          #
          #   @return [Array<OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment>, nil]
          optional :attachments,
                   -> {
                     OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::ThreadCreateParams::Message::Attachment]
                   },
                   nil?: true

          # @!attribute metadata
          #   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.
          #
          #   @return [Hash{Symbol=>String}, nil]
          optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true

          # @!method initialize(content:, role:, attachments: nil, metadata: nil)
          #   Some parameter documentations has been truncated, see
          #   {OpenAI::Models::Beta::ThreadCreateParams::Message} for more details.
          #
          #   @param content [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>] The text contents of the message.
          #
          #   @param role [Symbol, OpenAI::Models::Beta::ThreadCreateParams::Message::Role] The role of the entity that is creating the message. Allowed values include:
          #
          #   @param attachments [Array<OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment>, nil] A list of files attached to the message, and the tools they should be added to.
          #
          #   @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be

          # The text contents of the message.
          #
          # @see OpenAI::Models::Beta::ThreadCreateParams::Message#content
          module Content
            extend OpenAI::Internal::Type::Union

            # The text contents of the message.
            variant String

            # An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models).
            variant -> { OpenAI::Models::Beta::ThreadCreateParams::Message::Content::MessageContentPartParamArray }

            # @!method self.variants
            #   @return [Array(String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>)]

            # @type [OpenAI::Internal::Type::Converter]
            MessageContentPartParamArray =
              OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::Beta::Threads::MessageContentPartParam }]
          end

          # The role of the entity that is creating the message. Allowed values include:
          #
          # - `user`: Indicates the message is sent by an actual user and should be used in
          #   most cases to represent user-generated messages.
          # - `assistant`: Indicates the message is generated by the assistant. Use this
          #   value to insert messages from the assistant into the conversation.
          #
          # @see OpenAI::Models::Beta::ThreadCreateParams::Message#role
          module Role
            extend OpenAI::Internal::Type::Enum

            USER = :user
            ASSISTANT = :assistant

            # @!method self.values
            #   @return [Array<Symbol>]
          end

          class Attachment < OpenAI::Internal::Type::BaseModel
            # @!attribute file_id
            #   The ID of the file to attach to the message.
            #
            #   @return [String, nil]
            optional :file_id, String

            # @!attribute tools
            #   The tools to add this file to.
            #
            #   @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch>, nil]
            optional :tools,
                     -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::ThreadCreateParams::Message::Attachment::Tool] }

            # @!method initialize(file_id: nil, tools: nil)
            #   @param file_id [String] The ID of the file to attach to the message.
            #
            #   @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch>] The tools to add this file to.

            module Tool
              extend OpenAI::Internal::Type::Union

              discriminator :type

              variant :code_interpreter, -> { OpenAI::Beta::CodeInterpreterTool }

              variant :file_search, -> { OpenAI::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch }

              class FileSearch < OpenAI::Internal::Type::BaseModel
                # @!attribute type
                #   The type of tool being defined: `file_search`
                #
                #   @return [Symbol, :file_search]
                required :type, const: :file_search

                # @!method initialize(type: :file_search)
                #   @param type [Symbol, :file_search] The type of tool being defined: `file_search`
              end

              # @!method self.variants
              #   @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch)]
            end
          end
        end

        class ToolResources < OpenAI::Internal::Type::BaseModel
          # @!attribute code_interpreter
          #
          #   @return [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter, nil]
          optional :code_interpreter, -> { OpenAI::Beta::ThreadCreateParams::ToolResources::CodeInterpreter }

          # @!attribute file_search
          #
          #   @return [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch, nil]
          optional :file_search, -> { OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch }

          # @!method initialize(code_interpreter: nil, file_search: nil)
          #   A set of resources that are made available to the assistant's tools in this
          #   thread. The resources are specific to the type of tool. For example, the
          #   `code_interpreter` tool requires a list of file IDs, while the `file_search`
          #   tool requires a list of vector store IDs.
          #
          #   @param code_interpreter [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter]
          #   @param file_search [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch]

          # @see OpenAI::Models::Beta::ThreadCreateParams::ToolResources#code_interpreter
          class CodeInterpreter < OpenAI::Internal::Type::BaseModel
            # @!attribute file_ids
            #   A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
            #   available to the `code_interpreter` tool. There can be a maximum of 20 files
            #   associated with the tool.
            #
            #   @return [Array<String>, nil]
            optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]

            # @!method initialize(file_ids: nil)
            #   Some parameter documentations has been truncated, see
            #   {OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter} for
            #   more details.
            #
            #   @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
          end

          # @see OpenAI::Models::Beta::ThreadCreateParams::ToolResources#file_search
          class FileSearch < OpenAI::Internal::Type::BaseModel
            # @!attribute vector_store_ids
            #   The
            #   [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
            #   attached to this thread. There can be a maximum of 1 vector store attached to
            #   the thread.
            #
            #   @return [Array<String>, nil]
            optional :vector_store_ids, OpenAI::Internal::Type::ArrayOf[String]

            # @!attribute vector_stores
            #   A helper to create a
            #   [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
            #   with file_ids and attach it to this thread. There can be a maximum of 1 vector
            #   store attached to the thread.
            #
            #   @return [Array<OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore>, nil]
            optional :vector_stores,
                     -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore] }

            # @!method initialize(vector_store_ids: nil, vector_stores: nil)
            #   Some parameter documentations has been truncated, see
            #   {OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch} for more
            #   details.
            #
            #   @param vector_store_ids [Array<String>] The [vector store](https://platform.openai.com/docs/api-reference/vector-stores/
            #
            #   @param vector_stores [Array<OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore>] A helper to create a [vector store](https://platform.openai.com/docs/api-referen

            class VectorStore < OpenAI::Internal::Type::BaseModel
              # @!attribute chunking_strategy
              #   The chunking strategy used to chunk the file(s). If not set, will use the `auto`
              #   strategy.
              #
              #   @return [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static, nil]
              optional :chunking_strategy,
                       union: -> { OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy }

              # @!attribute file_ids
              #   A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
              #   add to the vector store. There can be a maximum of 10000 files in a vector
              #   store.
              #
              #   @return [Array<String>, nil]
              optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]

              # @!attribute metadata
              #   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.
              #
              #   @return [Hash{Symbol=>String}, nil]
              optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true

              # @!method initialize(chunking_strategy: nil, file_ids: nil, metadata: nil)
              #   Some parameter documentations has been truncated, see
              #   {OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore}
              #   for more details.
              #
              #   @param chunking_strategy [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
              #
              #   @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to ad
              #
              #   @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be

              # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
              # strategy.
              #
              # @see OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore#chunking_strategy
              module ChunkingStrategy
                extend OpenAI::Internal::Type::Union

                discriminator :type

                # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
                variant :auto,
                        -> { OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto }

                variant :static,
                        -> { OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static }

                class Auto < OpenAI::Internal::Type::BaseModel
                  # @!attribute type
                  #   Always `auto`.
                  #
                  #   @return [Symbol, :auto]
                  required :type, const: :auto

                  # @!method initialize(type: :auto)
                  #   The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
                  #   `800` and `chunk_overlap_tokens` of `400`.
                  #
                  #   @param type [Symbol, :auto] Always `auto`.
                end

                class Static < OpenAI::Internal::Type::BaseModel
                  # @!attribute static
                  #
                  #   @return [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static]
                  required :static,
                           -> { OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static }

                  # @!attribute type
                  #   Always `static`.
                  #
                  #   @return [Symbol, :static]
                  required :type, const: :static

                  # @!method initialize(static:, type: :static)
                  #   @param static [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static]
                  #
                  #   @param type [Symbol, :static] Always `static`.

                  # @see OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static#static
                  class Static < OpenAI::Internal::Type::BaseModel
                    # @!attribute chunk_overlap_tokens
                    #   The number of tokens that overlap between chunks. The default value is `400`.
                    #
                    #   Note that the overlap must not exceed half of `max_chunk_size_tokens`.
                    #
                    #   @return [Integer]
                    required :chunk_overlap_tokens, Integer

                    # @!attribute max_chunk_size_tokens
                    #   The maximum number of tokens in each chunk. The default value is `800`. The
                    #   minimum value is `100` and the maximum value is `4096`.
                    #
                    #   @return [Integer]
                    required :max_chunk_size_tokens, Integer

                    # @!method initialize(chunk_overlap_tokens:, max_chunk_size_tokens:)
                    #   Some parameter documentations has been truncated, see
                    #   {OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static}
                    #   for more details.
                    #
                    #   @param chunk_overlap_tokens [Integer] The number of tokens that overlap between chunks. The default value is `400`.
                    #
                    #   @param max_chunk_size_tokens [Integer] The maximum number of tokens in each chunk. The default value is `800`. The mini
                  end
                end

                # @!method self.variants
                #   @return [Array(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)]
              end
            end
          end
        end
      end
    end
  end
end
