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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ __pycache__
/*_data.json
/*_embeddings.bin

# pytest configuration
pytest.local.ini

# Coverage
.coverage
.coverage.*
Expand Down
3 changes: 2 additions & 1 deletion typeagent/knowpro/answer_response_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from typing import Literal, Annotated
from typing_extensions import Doc
from pydantic.dataclasses import dataclass

from .dataclasses import dataclass

AnswerType = Literal[
"NoAnswer", # If question cannot be accurately answered from [ANSWER CONTEXT]
Expand Down
35 changes: 35 additions & 0 deletions typeagent/knowpro/dataclasses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Compatibility helpers for pydantic dataclasses."""

from collections.abc import Callable
from typing import Any, cast, overload

from typing_extensions import dataclass_transform

from pydantic.dataclasses import dataclass as _pydantic_dataclass

from .field_helpers import CamelCaseField


@overload
def dataclass[T](__cls: type[T], /, **kwargs: Any) -> type[T]: ...


@overload
def dataclass[T](**kwargs: Any) -> Callable[[type[T]], type[T]]: ...


@dataclass_transform(field_specifiers=(CamelCaseField,))
def dataclass[T](
__cls: type[T] | None = None, /, **kwargs: Any
) -> Callable[[type[T]], type[T]] | type[T]:
"""Wrapper that preserves pydantic behavior while informing type-checkers."""

def wrap(cls: type[T]) -> type[T]:
return cast(type[T], _pydantic_dataclass(cls, **kwargs))

if __cls is None:
return wrap

return wrap(__cls)
3 changes: 2 additions & 1 deletion typeagent/knowpro/date_time_schema.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

from pydantic.dataclasses import dataclass
from typing import Annotated
from typing_extensions import Doc

from .dataclasses import dataclass


@dataclass
class DateVal:
Expand Down
Loading