# This file was auto-generated by Fern from our API Definition.

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.pagination import AsyncPager, SyncPager
from ..core.request_options import RequestOptions
from ..types.components_schemas_initial_instruction import ComponentsSchemasInitialInstruction
from ..types.instruction_id import InstructionId
from ..types.instruction_name import InstructionName
from ..types.template_type import TemplateType
from ..types.test_instruction_response import TestInstructionResponse
from ..types.tool import Tool
from .raw_client import AsyncRawInstructionsClient, RawInstructionsClient

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class InstructionsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawInstructionsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawInstructionsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawInstructionsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        filter: typing.Optional[str] = None,
        type: typing.Optional[typing.Literal["initial"]] = None,
        enabled: typing.Optional[bool] = None,
        limit: typing.Optional[int] = None,
        page_key: typing.Optional[str] = None,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SyncPager[ComponentsSchemasInitialInstruction]:
        """
        List all instructions available to the authenticated user, with optional filtering and pagination.

        Parameters
        ----------
        filter : typing.Optional[str]
            A regular expression against instruction names and descriptions to filter the results.

        type : typing.Optional[typing.Literal["initial"]]
            Filter instructions by type.

        enabled : typing.Optional[bool]
            Filter instructions by enabled status.

        limit : typing.Optional[int]
            The maximum number of instructions to return in the list.

        page_key : typing.Optional[str]
            Used to retrieve the next page of instructions after the limit has been reached.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SyncPager[ComponentsSchemasInitialInstruction]
            List of available instructions.

        Examples
        --------
        from vectara import Vectara

        client = Vectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )
        response = client.instructions.list(
            filter="support.*",
            enabled=True,
        )
        for item in response:
            yield item
        # alternatively, you can paginate page-by-page
        for page in response.iter_pages():
            yield page
        """
        return self._raw_client.list(
            filter=filter,
            type=type,
            enabled=enabled,
            limit=limit,
            page_key=page_key,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            request_options=request_options,
        )

    def create(
        self,
        *,
        name: InstructionName,
        template: str,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        description: typing.Optional[str] = OMIT,
        template_type: typing.Optional[TemplateType] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        enabled: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ComponentsSchemasInitialInstruction:
        """
        Create a new instruction that can guide agent behavior.

        Parameters
        ----------
        name : InstructionName

        template : str
            The instruction template content using the specified template engine.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        description : typing.Optional[str]
            A detailed description of what this instruction does.

        template_type : typing.Optional[TemplateType]

        metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
            Arbitrary metadata associated with the instruction.

        enabled : typing.Optional[bool]
            Whether the instruction should be enabled upon creation.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ComponentsSchemasInitialInstruction
            The instruction has been created successfully.

        Examples
        --------
        from vectara import Vectara

        client = Vectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )
        client.instructions.create(
            name="Customer Support Initial Instruction",
            template="You are a helpful customer support agent for Acme Corp. Today's date is ${currentDate}. You have access to the following tools: #foreach($tool in $tools)${tool.name}#if($foreach.hasNext), #end#end",
        )
        """
        _response = self._raw_client.create(
            name=name,
            template=template,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            description=description,
            template_type=template_type,
            metadata=metadata,
            enabled=enabled,
            request_options=request_options,
        )
        return _response.data

    def get(
        self,
        instruction_id: InstructionId,
        *,
        version: typing.Optional[int] = None,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ComponentsSchemasInitialInstruction:
        """
        Retrieve the details of a specific instruction by its ID, including its template and configuration.

        Parameters
        ----------
        instruction_id : InstructionId
            The unique identifier of the instruction to retrieve.

        version : typing.Optional[int]
            The specific version of the instruction to retrieve. If not specified, the latest version will be returned.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ComponentsSchemasInitialInstruction
            The requested instruction details.

        Examples
        --------
        from vectara import Vectara

        client = Vectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )
        client.instructions.get(
            instruction_id="ins_customer_support_init",
            version=1,
        )
        """
        _response = self._raw_client.get(
            instruction_id,
            version=version,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            request_options=request_options,
        )
        return _response.data

    def delete(
        self,
        instruction_id: InstructionId,
        *,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Permanently delete an instruction and all its associated configuration. This action cannot be undone.

        Parameters
        ----------
        instruction_id : InstructionId
            The unique identifier of the instruction to delete.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        from vectara import Vectara

        client = Vectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )
        client.instructions.delete(
            instruction_id="ins_customer_support_init",
        )
        """
        _response = self._raw_client.delete(
            instruction_id,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            request_options=request_options,
        )
        return _response.data

    def update(
        self,
        instruction_id: InstructionId,
        *,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        name: typing.Optional[InstructionName] = OMIT,
        description: typing.Optional[str] = OMIT,
        template: typing.Optional[str] = OMIT,
        template_type: typing.Optional[TemplateType] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        enabled: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ComponentsSchemasInitialInstruction:
        """
        Update an existing instruction's template, metadata, and configuration.

        Parameters
        ----------
        instruction_id : InstructionId
            The unique identifier of the instruction to update.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        name : typing.Optional[InstructionName]

        description : typing.Optional[str]
            A detailed description of what this instruction does.

        template : typing.Optional[str]
            The instruction template content using the specified template engine.

        template_type : typing.Optional[TemplateType]

        metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
            Arbitrary metadata associated with the instruction.

        enabled : typing.Optional[bool]
            Whether the instruction is enabled.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ComponentsSchemasInitialInstruction
            The instruction has been updated successfully.

        Examples
        --------
        from vectara import Vectara

        client = Vectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )
        client.instructions.update(
            instruction_id="ins_customer_support_init",
        )
        """
        _response = self._raw_client.update(
            instruction_id,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            name=name,
            description=description,
            template=template,
            template_type=template_type,
            metadata=metadata,
            enabled=enabled,
            request_options=request_options,
        )
        return _response.data

    def test(
        self,
        instruction_id: InstructionId,
        *,
        version: typing.Optional[int] = None,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        context: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        tools: typing.Optional[typing.Sequence[Tool]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TestInstructionResponse:
        """
        Test an instruction by rendering its template with provided context data and tools.

        Parameters
        ----------
        instruction_id : InstructionId
            The unique identifier of the instruction to test.

        version : typing.Optional[int]
            The specific version of the instruction to test. If not specified, the latest version will be used.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        context : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
            Context data to use when rendering the instruction template.

        tools : typing.Optional[typing.Sequence[Tool]]
            List of tools to include in the instruction context for testing.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        TestInstructionResponse
            The instruction has been tested successfully and the rendered result is returned.

        Examples
        --------
        from vectara import Vectara

        client = Vectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )
        client.instructions.test(
            instruction_id="ins_customer_support_init",
            version=1,
        )
        """
        _response = self._raw_client.test(
            instruction_id,
            version=version,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            context=context,
            tools=tools,
            request_options=request_options,
        )
        return _response.data

    def delete_version(
        self,
        instruction_id: InstructionId,
        version: int,
        *,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Permanently delete the specified version of the instruction. This action cannot be undone.

        Parameters
        ----------
        instruction_id : InstructionId
            The unique identifier of the instruction to delete.

        version : int
            The specific version of the instruction to delete.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        from vectara import Vectara

        client = Vectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )
        client.instructions.delete_version(
            instruction_id="ins_customer_support_init",
            version=1,
        )
        """
        _response = self._raw_client.delete_version(
            instruction_id,
            version,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            request_options=request_options,
        )
        return _response.data


class AsyncInstructionsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawInstructionsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawInstructionsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawInstructionsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        filter: typing.Optional[str] = None,
        type: typing.Optional[typing.Literal["initial"]] = None,
        enabled: typing.Optional[bool] = None,
        limit: typing.Optional[int] = None,
        page_key: typing.Optional[str] = None,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncPager[ComponentsSchemasInitialInstruction]:
        """
        List all instructions available to the authenticated user, with optional filtering and pagination.

        Parameters
        ----------
        filter : typing.Optional[str]
            A regular expression against instruction names and descriptions to filter the results.

        type : typing.Optional[typing.Literal["initial"]]
            Filter instructions by type.

        enabled : typing.Optional[bool]
            Filter instructions by enabled status.

        limit : typing.Optional[int]
            The maximum number of instructions to return in the list.

        page_key : typing.Optional[str]
            Used to retrieve the next page of instructions after the limit has been reached.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncPager[ComponentsSchemasInitialInstruction]
            List of available instructions.

        Examples
        --------
        import asyncio

        from vectara import AsyncVectara

        client = AsyncVectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )


        async def main() -> None:
            response = await client.instructions.list(
                filter="support.*",
                enabled=True,
            )
            async for item in response:
                yield item

            # alternatively, you can paginate page-by-page
            async for page in response.iter_pages():
                yield page


        asyncio.run(main())
        """
        return await self._raw_client.list(
            filter=filter,
            type=type,
            enabled=enabled,
            limit=limit,
            page_key=page_key,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            request_options=request_options,
        )

    async def create(
        self,
        *,
        name: InstructionName,
        template: str,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        description: typing.Optional[str] = OMIT,
        template_type: typing.Optional[TemplateType] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        enabled: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ComponentsSchemasInitialInstruction:
        """
        Create a new instruction that can guide agent behavior.

        Parameters
        ----------
        name : InstructionName

        template : str
            The instruction template content using the specified template engine.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        description : typing.Optional[str]
            A detailed description of what this instruction does.

        template_type : typing.Optional[TemplateType]

        metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
            Arbitrary metadata associated with the instruction.

        enabled : typing.Optional[bool]
            Whether the instruction should be enabled upon creation.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ComponentsSchemasInitialInstruction
            The instruction has been created successfully.

        Examples
        --------
        import asyncio

        from vectara import AsyncVectara

        client = AsyncVectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )


        async def main() -> None:
            await client.instructions.create(
                name="Customer Support Initial Instruction",
                template="You are a helpful customer support agent for Acme Corp. Today's date is ${currentDate}. You have access to the following tools: #foreach($tool in $tools)${tool.name}#if($foreach.hasNext), #end#end",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            name=name,
            template=template,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            description=description,
            template_type=template_type,
            metadata=metadata,
            enabled=enabled,
            request_options=request_options,
        )
        return _response.data

    async def get(
        self,
        instruction_id: InstructionId,
        *,
        version: typing.Optional[int] = None,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ComponentsSchemasInitialInstruction:
        """
        Retrieve the details of a specific instruction by its ID, including its template and configuration.

        Parameters
        ----------
        instruction_id : InstructionId
            The unique identifier of the instruction to retrieve.

        version : typing.Optional[int]
            The specific version of the instruction to retrieve. If not specified, the latest version will be returned.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ComponentsSchemasInitialInstruction
            The requested instruction details.

        Examples
        --------
        import asyncio

        from vectara import AsyncVectara

        client = AsyncVectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )


        async def main() -> None:
            await client.instructions.get(
                instruction_id="ins_customer_support_init",
                version=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get(
            instruction_id,
            version=version,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            request_options=request_options,
        )
        return _response.data

    async def delete(
        self,
        instruction_id: InstructionId,
        *,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Permanently delete an instruction and all its associated configuration. This action cannot be undone.

        Parameters
        ----------
        instruction_id : InstructionId
            The unique identifier of the instruction to delete.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from vectara import AsyncVectara

        client = AsyncVectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )


        async def main() -> None:
            await client.instructions.delete(
                instruction_id="ins_customer_support_init",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(
            instruction_id,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            request_options=request_options,
        )
        return _response.data

    async def update(
        self,
        instruction_id: InstructionId,
        *,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        name: typing.Optional[InstructionName] = OMIT,
        description: typing.Optional[str] = OMIT,
        template: typing.Optional[str] = OMIT,
        template_type: typing.Optional[TemplateType] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        enabled: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ComponentsSchemasInitialInstruction:
        """
        Update an existing instruction's template, metadata, and configuration.

        Parameters
        ----------
        instruction_id : InstructionId
            The unique identifier of the instruction to update.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        name : typing.Optional[InstructionName]

        description : typing.Optional[str]
            A detailed description of what this instruction does.

        template : typing.Optional[str]
            The instruction template content using the specified template engine.

        template_type : typing.Optional[TemplateType]

        metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
            Arbitrary metadata associated with the instruction.

        enabled : typing.Optional[bool]
            Whether the instruction is enabled.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ComponentsSchemasInitialInstruction
            The instruction has been updated successfully.

        Examples
        --------
        import asyncio

        from vectara import AsyncVectara

        client = AsyncVectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )


        async def main() -> None:
            await client.instructions.update(
                instruction_id="ins_customer_support_init",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            instruction_id,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            name=name,
            description=description,
            template=template,
            template_type=template_type,
            metadata=metadata,
            enabled=enabled,
            request_options=request_options,
        )
        return _response.data

    async def test(
        self,
        instruction_id: InstructionId,
        *,
        version: typing.Optional[int] = None,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        context: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        tools: typing.Optional[typing.Sequence[Tool]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TestInstructionResponse:
        """
        Test an instruction by rendering its template with provided context data and tools.

        Parameters
        ----------
        instruction_id : InstructionId
            The unique identifier of the instruction to test.

        version : typing.Optional[int]
            The specific version of the instruction to test. If not specified, the latest version will be used.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        context : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
            Context data to use when rendering the instruction template.

        tools : typing.Optional[typing.Sequence[Tool]]
            List of tools to include in the instruction context for testing.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        TestInstructionResponse
            The instruction has been tested successfully and the rendered result is returned.

        Examples
        --------
        import asyncio

        from vectara import AsyncVectara

        client = AsyncVectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )


        async def main() -> None:
            await client.instructions.test(
                instruction_id="ins_customer_support_init",
                version=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.test(
            instruction_id,
            version=version,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            context=context,
            tools=tools,
            request_options=request_options,
        )
        return _response.data

    async def delete_version(
        self,
        instruction_id: InstructionId,
        version: int,
        *,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Permanently delete the specified version of the instruction. This action cannot be undone.

        Parameters
        ----------
        instruction_id : InstructionId
            The unique identifier of the instruction to delete.

        version : int
            The specific version of the instruction to delete.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from vectara import AsyncVectara

        client = AsyncVectara(
            api_key="YOUR_API_KEY",
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )


        async def main() -> None:
            await client.instructions.delete_version(
                instruction_id="ins_customer_support_init",
                version=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_version(
            instruction_id,
            version,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            request_options=request_options,
        )
        return _response.data
