Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions function_schema/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
get_type_hints,
)

from .types import FunctionSchema, Doc
from .types import FunctionSchema, Doc, DocMeta
from .utils import unwrap_doc


Expand Down Expand Up @@ -102,7 +102,7 @@ def get_function_schema(
# find description in param_args tuple
try:
description = next(
unwrap_doc(arg) for arg in param_args if isinstance(arg, Doc)
unwrap_doc(arg) for arg in param_args if isinstance(arg, DocMeta)
)
except StopIteration:
try:
Expand Down
10 changes: 8 additions & 2 deletions function_schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@
from typing_extensions import Doc
except ImportError:

@runtime_checkable
class Doc(Protocol):
class Doc:
documentation: str

def __init__(self, documentation: str, /):
self.documentation = documentation


@runtime_checkable
class DocMeta(Protocol):
"""Represents the protocol for the Doc class."""

documentation: str


class ParamSchema(TypedDict):
"""
Represents the schema for a parameter.
Expand Down