Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 8 additions & 43 deletions src/openai/types/chat/chat_completion_custom_tool_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,22 @@

from __future__ import annotations

from typing import Union
from typing_extensions import Literal, Required, TypeAlias, TypedDict
from typing_extensions import Literal, Required, TypedDict

__all__ = [
"ChatCompletionCustomToolParam",
"Custom",
"CustomFormat",
"CustomFormatText",
"CustomFormatGrammar",
"CustomFormatGrammarGrammar",
]
from ..shared_params.custom_tool_input_format import CustomToolInputFormat

__all__ = ["ChatCompletionCustomToolParam"]

class CustomFormatText(TypedDict, total=False):
type: Required[Literal["text"]]
"""Unconstrained text format. Always `text`."""


class CustomFormatGrammarGrammar(TypedDict, total=False):
definition: Required[str]
"""The grammar definition."""

syntax: Required[Literal["lark", "regex"]]
"""The syntax of the grammar definition. One of `lark` or `regex`."""


class CustomFormatGrammar(TypedDict, total=False):
grammar: Required[CustomFormatGrammarGrammar]
"""Your chosen grammar."""

type: Required[Literal["grammar"]]
"""Grammar format. Always `grammar`."""


CustomFormat: TypeAlias = Union[CustomFormatText, CustomFormatGrammar]


class Custom(TypedDict, total=False):
class ChatCompletionCustomToolParam(TypedDict, total=False):
name: Required[str]
"""The name of the custom tool, used to identify it in tool calls."""

type: Required[Literal["custom"]]
"""The type of the custom tool. Always `custom`."""

description: str
"""Optional description of the custom tool, used to provide more context."""

format: CustomFormat
format: CustomToolInputFormat
"""The input format for the custom tool. Default is unconstrained text."""


class ChatCompletionCustomToolParam(TypedDict, total=False):
custom: Required[Custom]
"""Properties of the custom tool."""

type: Required[Literal["custom"]]
"""The type of the custom tool. Always `custom`."""