diff --git a/src/chainlit/action.py b/src/chainlit/action.py index 0c92c809d0..566b2fb5c0 100644 --- a/src/chainlit/action.py +++ b/src/chainlit/action.py @@ -1,15 +1,14 @@ from typing import Optional -from dataclasses_json import dataclass_json +from dataclasses_json import DataClassJsonMixin from pydantic.dataclasses import dataclass from chainlit.context import get_emitter from chainlit.telemetry import trace_event -@dataclass_json @dataclass -class Action: +class Action(DataClassJsonMixin): # Name of the action, this should be used in the action_callback name: str # The value associated with the action. This is useful to differentiate between multiple actions with the same name. diff --git a/src/chainlit/client/base.py b/src/chainlit/client/base.py index 681a72c0e5..d855daa4d2 100644 --- a/src/chainlit/client/base.py +++ b/src/chainlit/client/base.py @@ -11,7 +11,7 @@ Union, ) -from dataclasses_json import dataclass_json +from dataclasses_json import DataClassJsonMixin from pydantic.dataclasses import dataclass from chainlit.types import ( @@ -77,9 +77,8 @@ class PageInfo: T = TypeVar("T") -@dataclass_json @dataclass -class PaginatedResponse(Generic[T]): +class PaginatedResponse(DataClassJsonMixin, Generic[T]): pageInfo: PageInfo data: List[T] diff --git a/src/chainlit/config.py b/src/chainlit/config.py index f1084314c1..66d3848dd6 100644 --- a/src/chainlit/config.py +++ b/src/chainlit/config.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Union import tomli -from dataclasses_json import dataclass_json +from dataclasses_json import DataClassJsonMixin from pydantic.dataclasses import dataclass from chainlit.logger import logger @@ -109,32 +109,28 @@ class RunSettings: ci: bool = False -@dataclass_json @dataclass() -class PaletteOptions: +class PaletteOptions(DataClassJsonMixin): main: Optional[str] = "" light: Optional[str] = "" dark: Optional[str] = "" -@dataclass_json @dataclass() -class Palette: +class Palette(DataClassJsonMixin): primary: PaletteOptions = None background: Optional[str] = "" paper: Optional[str] = "" -@dataclass_json @dataclass() -class Theme: +class Theme(DataClassJsonMixin): light: Palette = None dark: Palette = None -@dataclass_json @dataclass() -class UISettings: +class UISettings(DataClassJsonMixin): name: str description: str = "" hide_cot: bool = False @@ -171,9 +167,8 @@ def validate(self): return True -@dataclass_json @dataclass() -class ProjectSettings: +class ProjectSettings(DataClassJsonMixin): # Enables Cloud features if provided id: Optional[str] = None # Whether the app is available to anonymous users or only to team members. diff --git a/src/chainlit/types.py b/src/chainlit/types.py index 34bf0397bb..8b7a078811 100644 --- a/src/chainlit/types.py +++ b/src/chainlit/types.py @@ -1,6 +1,6 @@ from typing import Any, Dict, List, Literal, Optional, TypedDict, Union -from dataclasses_json import dataclass_json +from dataclasses_json import DataClassJsonMixin from pydantic import BaseModel from pydantic.dataclasses import dataclass @@ -11,18 +11,16 @@ ElementSize = Literal["small", "medium", "large"] -@dataclass_json @dataclass -class AskSpec: +class AskSpec(DataClassJsonMixin): """Specification for asking the user.""" timeout: int type: Literal["text", "file"] -@dataclass_json @dataclass -class AskFileSpec(AskSpec): +class AskFileSpec(AskSpec, DataClassJsonMixin): """Specification for asking the user for a file.""" accept: Union[List[str], Dict[str, List[str]]] @@ -44,9 +42,8 @@ class AskFileResponse: content: bytes -@dataclass_json @dataclass -class LLMSettings: +class LLMSettings(DataClassJsonMixin): model_name: str = "text-davinci-003" stop: Optional[List[str]] = None temperature: float = 0