from datetime import date, datetime  # noqa: F401
from typing import Dict, List  # noqa: F401

from timestep.api.openai.v1 import util
from timestep.api.openai.v1.models.assistants_api_response_format_option import \
    AssistantsApiResponseFormatOption  # noqa: E501
from timestep.api.openai.v1.models.assistants_api_tool_choice_option import \
    AssistantsApiToolChoiceOption  # noqa: E501
from timestep.api.openai.v1.models.base_model import Model
from timestep.api.openai.v1.models.create_run_request_model import \
    CreateRunRequestModel  # noqa: E501
from timestep.api.openai.v1.models.create_thread_and_run_request_tool_resources import \
    CreateThreadAndRunRequestToolResources  # noqa: E501
from timestep.api.openai.v1.models.create_thread_and_run_request_tools_inner import \
    CreateThreadAndRunRequestToolsInner  # noqa: E501
from timestep.api.openai.v1.models.create_thread_request import \
    CreateThreadRequest  # noqa: E501
from timestep.api.openai.v1.models.truncation_object import \
    TruncationObject  # noqa: E501


class CreateThreadAndRunRequest(Model):
    """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

    Do not edit the class manually.
    """

    def __init__(self, assistant_id=None, thread=None, model=None, instructions=None, tools=None, tool_resources=None, metadata=None, temperature=1, top_p=1, stream=None, max_prompt_tokens=None, max_completion_tokens=None, truncation_strategy=None, tool_choice=None, parallel_tool_calls=True, response_format=None):  # noqa: E501
        """CreateThreadAndRunRequest - a model defined in OpenAPI

        :param assistant_id: The assistant_id of this CreateThreadAndRunRequest.  # noqa: E501
        :type assistant_id: str
        :param thread: The thread of this CreateThreadAndRunRequest.  # noqa: E501
        :type thread: CreateThreadRequest
        :param model: The model of this CreateThreadAndRunRequest.  # noqa: E501
        :type model: CreateRunRequestModel
        :param instructions: The instructions of this CreateThreadAndRunRequest.  # noqa: E501
        :type instructions: str
        :param tools: The tools of this CreateThreadAndRunRequest.  # noqa: E501
        :type tools: List[CreateThreadAndRunRequestToolsInner]
        :param tool_resources: The tool_resources of this CreateThreadAndRunRequest.  # noqa: E501
        :type tool_resources: CreateThreadAndRunRequestToolResources
        :param metadata: The metadata of this CreateThreadAndRunRequest.  # noqa: E501
        :type metadata: object
        :param temperature: The temperature of this CreateThreadAndRunRequest.  # noqa: E501
        :type temperature: float
        :param top_p: The top_p of this CreateThreadAndRunRequest.  # noqa: E501
        :type top_p: float
        :param stream: The stream of this CreateThreadAndRunRequest.  # noqa: E501
        :type stream: bool
        :param max_prompt_tokens: The max_prompt_tokens of this CreateThreadAndRunRequest.  # noqa: E501
        :type max_prompt_tokens: int
        :param max_completion_tokens: The max_completion_tokens of this CreateThreadAndRunRequest.  # noqa: E501
        :type max_completion_tokens: int
        :param truncation_strategy: The truncation_strategy of this CreateThreadAndRunRequest.  # noqa: E501
        :type truncation_strategy: TruncationObject
        :param tool_choice: The tool_choice of this CreateThreadAndRunRequest.  # noqa: E501
        :type tool_choice: AssistantsApiToolChoiceOption
        :param parallel_tool_calls: The parallel_tool_calls of this CreateThreadAndRunRequest.  # noqa: E501
        :type parallel_tool_calls: bool
        :param response_format: The response_format of this CreateThreadAndRunRequest.  # noqa: E501
        :type response_format: AssistantsApiResponseFormatOption
        """
        self.openapi_types = {
            'assistant_id': str,
            'thread': CreateThreadRequest,
            'model': CreateRunRequestModel,
            'instructions': str,
            'tools': List[CreateThreadAndRunRequestToolsInner],
            'tool_resources': CreateThreadAndRunRequestToolResources,
            'metadata': object,
            'temperature': float,
            'top_p': float,
            'stream': bool,
            'max_prompt_tokens': int,
            'max_completion_tokens': int,
            'truncation_strategy': TruncationObject,
            'tool_choice': AssistantsApiToolChoiceOption,
            'parallel_tool_calls': bool,
            'response_format': AssistantsApiResponseFormatOption
        }

        self.attribute_map = {
            'assistant_id': 'assistant_id',
            'thread': 'thread',
            'model': 'model',
            'instructions': 'instructions',
            'tools': 'tools',
            'tool_resources': 'tool_resources',
            'metadata': 'metadata',
            'temperature': 'temperature',
            'top_p': 'top_p',
            'stream': 'stream',
            'max_prompt_tokens': 'max_prompt_tokens',
            'max_completion_tokens': 'max_completion_tokens',
            'truncation_strategy': 'truncation_strategy',
            'tool_choice': 'tool_choice',
            'parallel_tool_calls': 'parallel_tool_calls',
            'response_format': 'response_format'
        }

        self._assistant_id = assistant_id
        self._thread = thread
        self._model = model
        self._instructions = instructions
        self._tools = tools
        self._tool_resources = tool_resources
        self._metadata = metadata
        self._temperature = temperature
        self._top_p = top_p
        self._stream = stream
        self._max_prompt_tokens = max_prompt_tokens
        self._max_completion_tokens = max_completion_tokens
        self._truncation_strategy = truncation_strategy
        self._tool_choice = tool_choice
        self._parallel_tool_calls = parallel_tool_calls
        self._response_format = response_format

    @classmethod
    def from_dict(cls, dikt) -> 'CreateThreadAndRunRequest':
        """Returns the dict as a model

        :param dikt: A dict.
        :type: dict
        :return: The CreateThreadAndRunRequest of this CreateThreadAndRunRequest.  # noqa: E501
        :rtype: CreateThreadAndRunRequest
        """
        return util.deserialize_model(dikt, cls)

    @property
    def assistant_id(self) -> str:
        """Gets the assistant_id of this CreateThreadAndRunRequest.

        The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.  # noqa: E501

        :return: The assistant_id of this CreateThreadAndRunRequest.
        :rtype: str
        """
        return self._assistant_id

    @assistant_id.setter
    def assistant_id(self, assistant_id: str):
        """Sets the assistant_id of this CreateThreadAndRunRequest.

        The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.  # noqa: E501

        :param assistant_id: The assistant_id of this CreateThreadAndRunRequest.
        :type assistant_id: str
        """
        if assistant_id is None:
            raise ValueError("Invalid value for `assistant_id`, must not be `None`")  # noqa: E501

        self._assistant_id = assistant_id

    @property
    def thread(self) -> CreateThreadRequest:
        """Gets the thread of this CreateThreadAndRunRequest.


        :return: The thread of this CreateThreadAndRunRequest.
        :rtype: CreateThreadRequest
        """
        return self._thread

    @thread.setter
    def thread(self, thread: CreateThreadRequest):
        """Sets the thread of this CreateThreadAndRunRequest.


        :param thread: The thread of this CreateThreadAndRunRequest.
        :type thread: CreateThreadRequest
        """

        self._thread = thread

    @property
    def model(self) -> CreateRunRequestModel:
        """Gets the model of this CreateThreadAndRunRequest.


        :return: The model of this CreateThreadAndRunRequest.
        :rtype: CreateRunRequestModel
        """
        return self._model

    @model.setter
    def model(self, model: CreateRunRequestModel):
        """Sets the model of this CreateThreadAndRunRequest.


        :param model: The model of this CreateThreadAndRunRequest.
        :type model: CreateRunRequestModel
        """

        self._model = model

    @property
    def instructions(self) -> str:
        """Gets the instructions of this CreateThreadAndRunRequest.

        Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis.  # noqa: E501

        :return: The instructions of this CreateThreadAndRunRequest.
        :rtype: str
        """
        return self._instructions

    @instructions.setter
    def instructions(self, instructions: str):
        """Sets the instructions of this CreateThreadAndRunRequest.

        Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis.  # noqa: E501

        :param instructions: The instructions of this CreateThreadAndRunRequest.
        :type instructions: str
        """

        self._instructions = instructions

    @property
    def tools(self) -> List[CreateThreadAndRunRequestToolsInner]:
        """Gets the tools of this CreateThreadAndRunRequest.

        Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.  # noqa: E501

        :return: The tools of this CreateThreadAndRunRequest.
        :rtype: List[CreateThreadAndRunRequestToolsInner]
        """
        return self._tools

    @tools.setter
    def tools(self, tools: List[CreateThreadAndRunRequestToolsInner]):
        """Sets the tools of this CreateThreadAndRunRequest.

        Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.  # noqa: E501

        :param tools: The tools of this CreateThreadAndRunRequest.
        :type tools: List[CreateThreadAndRunRequestToolsInner]
        """
        if tools is not None and len(tools) > 20:
            raise ValueError("Invalid value for `tools`, number of items must be less than or equal to `20`")  # noqa: E501

        self._tools = tools

    @property
    def tool_resources(self) -> CreateThreadAndRunRequestToolResources:
        """Gets the tool_resources of this CreateThreadAndRunRequest.


        :return: The tool_resources of this CreateThreadAndRunRequest.
        :rtype: CreateThreadAndRunRequestToolResources
        """
        return self._tool_resources

    @tool_resources.setter
    def tool_resources(self, tool_resources: CreateThreadAndRunRequestToolResources):
        """Sets the tool_resources of this CreateThreadAndRunRequest.


        :param tool_resources: The tool_resources of this CreateThreadAndRunRequest.
        :type tool_resources: CreateThreadAndRunRequestToolResources
        """

        self._tool_resources = tool_resources

    @property
    def metadata(self) -> object:
        """Gets the metadata of this CreateThreadAndRunRequest.

        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. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.   # noqa: E501

        :return: The metadata of this CreateThreadAndRunRequest.
        :rtype: object
        """
        return self._metadata

    @metadata.setter
    def metadata(self, metadata: object):
        """Sets the metadata of this CreateThreadAndRunRequest.

        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. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.   # noqa: E501

        :param metadata: The metadata of this CreateThreadAndRunRequest.
        :type metadata: object
        """

        self._metadata = metadata

    @property
    def temperature(self) -> float:
        """Gets the temperature of this CreateThreadAndRunRequest.

        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.   # noqa: E501

        :return: The temperature of this CreateThreadAndRunRequest.
        :rtype: float
        """
        return self._temperature

    @temperature.setter
    def temperature(self, temperature: float):
        """Sets the temperature of this CreateThreadAndRunRequest.

        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.   # noqa: E501

        :param temperature: The temperature of this CreateThreadAndRunRequest.
        :type temperature: float
        """
        if temperature is not None and temperature > 2:  # noqa: E501
            raise ValueError("Invalid value for `temperature`, must be a value less than or equal to `2`")  # noqa: E501
        if temperature is not None and temperature < 0:  # noqa: E501
            raise ValueError("Invalid value for `temperature`, must be a value greater than or equal to `0`")  # noqa: E501

        self._temperature = temperature

    @property
    def top_p(self) -> float:
        """Gets the top_p of this CreateThreadAndRunRequest.

        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.  We generally recommend altering this or temperature but not both.   # noqa: E501

        :return: The top_p of this CreateThreadAndRunRequest.
        :rtype: float
        """
        return self._top_p

    @top_p.setter
    def top_p(self, top_p: float):
        """Sets the top_p of this CreateThreadAndRunRequest.

        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.  We generally recommend altering this or temperature but not both.   # noqa: E501

        :param top_p: The top_p of this CreateThreadAndRunRequest.
        :type top_p: float
        """
        if top_p is not None and top_p > 1:  # noqa: E501
            raise ValueError("Invalid value for `top_p`, must be a value less than or equal to `1`")  # noqa: E501
        if top_p is not None and top_p < 0:  # noqa: E501
            raise ValueError("Invalid value for `top_p`, must be a value greater than or equal to `0`")  # noqa: E501

        self._top_p = top_p

    @property
    def stream(self) -> bool:
        """Gets the stream of this CreateThreadAndRunRequest.

        If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.   # noqa: E501

        :return: The stream of this CreateThreadAndRunRequest.
        :rtype: bool
        """
        return self._stream

    @stream.setter
    def stream(self, stream: bool):
        """Sets the stream of this CreateThreadAndRunRequest.

        If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.   # noqa: E501

        :param stream: The stream of this CreateThreadAndRunRequest.
        :type stream: bool
        """

        self._stream = stream

    @property
    def max_prompt_tokens(self) -> int:
        """Gets the max_prompt_tokens of this CreateThreadAndRunRequest.

        The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.   # noqa: E501

        :return: The max_prompt_tokens of this CreateThreadAndRunRequest.
        :rtype: int
        """
        return self._max_prompt_tokens

    @max_prompt_tokens.setter
    def max_prompt_tokens(self, max_prompt_tokens: int):
        """Sets the max_prompt_tokens of this CreateThreadAndRunRequest.

        The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.   # noqa: E501

        :param max_prompt_tokens: The max_prompt_tokens of this CreateThreadAndRunRequest.
        :type max_prompt_tokens: int
        """
        if max_prompt_tokens is not None and max_prompt_tokens < 256:  # noqa: E501
            raise ValueError("Invalid value for `max_prompt_tokens`, must be a value greater than or equal to `256`")  # noqa: E501

        self._max_prompt_tokens = max_prompt_tokens

    @property
    def max_completion_tokens(self) -> int:
        """Gets the max_completion_tokens of this CreateThreadAndRunRequest.

        The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.   # noqa: E501

        :return: The max_completion_tokens of this CreateThreadAndRunRequest.
        :rtype: int
        """
        return self._max_completion_tokens

    @max_completion_tokens.setter
    def max_completion_tokens(self, max_completion_tokens: int):
        """Sets the max_completion_tokens of this CreateThreadAndRunRequest.

        The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.   # noqa: E501

        :param max_completion_tokens: The max_completion_tokens of this CreateThreadAndRunRequest.
        :type max_completion_tokens: int
        """
        if max_completion_tokens is not None and max_completion_tokens < 256:  # noqa: E501
            raise ValueError("Invalid value for `max_completion_tokens`, must be a value greater than or equal to `256`")  # noqa: E501

        self._max_completion_tokens = max_completion_tokens

    @property
    def truncation_strategy(self) -> TruncationObject:
        """Gets the truncation_strategy of this CreateThreadAndRunRequest.


        :return: The truncation_strategy of this CreateThreadAndRunRequest.
        :rtype: TruncationObject
        """
        return self._truncation_strategy

    @truncation_strategy.setter
    def truncation_strategy(self, truncation_strategy: TruncationObject):
        """Sets the truncation_strategy of this CreateThreadAndRunRequest.


        :param truncation_strategy: The truncation_strategy of this CreateThreadAndRunRequest.
        :type truncation_strategy: TruncationObject
        """

        self._truncation_strategy = truncation_strategy

    @property
    def tool_choice(self) -> AssistantsApiToolChoiceOption:
        """Gets the tool_choice of this CreateThreadAndRunRequest.


        :return: The tool_choice of this CreateThreadAndRunRequest.
        :rtype: AssistantsApiToolChoiceOption
        """
        return self._tool_choice

    @tool_choice.setter
    def tool_choice(self, tool_choice: AssistantsApiToolChoiceOption):
        """Sets the tool_choice of this CreateThreadAndRunRequest.


        :param tool_choice: The tool_choice of this CreateThreadAndRunRequest.
        :type tool_choice: AssistantsApiToolChoiceOption
        """

        self._tool_choice = tool_choice

    @property
    def parallel_tool_calls(self) -> bool:
        """Gets the parallel_tool_calls of this CreateThreadAndRunRequest.

        Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use.  # noqa: E501

        :return: The parallel_tool_calls of this CreateThreadAndRunRequest.
        :rtype: bool
        """
        return self._parallel_tool_calls

    @parallel_tool_calls.setter
    def parallel_tool_calls(self, parallel_tool_calls: bool):
        """Sets the parallel_tool_calls of this CreateThreadAndRunRequest.

        Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use.  # noqa: E501

        :param parallel_tool_calls: The parallel_tool_calls of this CreateThreadAndRunRequest.
        :type parallel_tool_calls: bool
        """

        self._parallel_tool_calls = parallel_tool_calls

    @property
    def response_format(self) -> AssistantsApiResponseFormatOption:
        """Gets the response_format of this CreateThreadAndRunRequest.


        :return: The response_format of this CreateThreadAndRunRequest.
        :rtype: AssistantsApiResponseFormatOption
        """
        return self._response_format

    @response_format.setter
    def response_format(self, response_format: AssistantsApiResponseFormatOption):
        """Sets the response_format of this CreateThreadAndRunRequest.


        :param response_format: The response_format of this CreateThreadAndRunRequest.
        :type response_format: AssistantsApiResponseFormatOption
        """

        self._response_format = response_format
