From e34149f4693ee36563cc25ee5610f35343e156d7 Mon Sep 17 00:00:00 2001 From: Abram Date: Wed, 20 Dec 2023 00:32:44 +0100 Subject: [PATCH 1/3] Update - modified BinaryParam sdk type --- agenta-cli/agenta/sdk/types.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/agenta-cli/agenta/sdk/types.py b/agenta-cli/agenta/sdk/types.py index 3dc07cb6ef..408c6ade3e 100644 --- a/agenta-cli/agenta/sdk/types.py +++ b/agenta-cli/agenta/sdk/types.py @@ -29,23 +29,12 @@ def __modify_schema__(cls, field_schema): field_schema.update({"x-parameter": "text"}) -class BoolMeta(type): - """ - This meta class handles the behavior of a boolean without - directly inheriting from it (avoiding the conflict - that comes from inheriting bool). - """ - - def __new__(cls, name: str, bases: tuple, namespace: dict): - if "default" in namespace and namespace["default"] not in [0, 1]: - raise ValueError("Must provide either 0 or 1") - namespace["default"] = bool(namespace.get("default", 0)) - instance = super().__new__(cls, name, bases, namespace) - instance.default = 0 +class BinaryParam(int): + def __new__(cls, value: bool = False): + instance = super().__new__(cls, int(value)) + instance.default = value return instance - -class BinaryParam(int, metaclass=BoolMeta): @classmethod def __modify_schema__(cls, field_schema): field_schema.update( From c6412cb805b2f3d18d55cda4f72bed0fb796e7bc Mon Sep 17 00:00:00 2001 From: Abram Date: Wed, 20 Dec 2023 00:33:13 +0100 Subject: [PATCH 2/3] Update - include boolean type in handleParamChange function --- .../src/components/Playground/Views/ParametersCards.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/agenta-web/src/components/Playground/Views/ParametersCards.tsx b/agenta-web/src/components/Playground/Views/ParametersCards.tsx index 8a298e0d70..aaffb16bb5 100644 --- a/agenta-web/src/components/Playground/Views/ParametersCards.tsx +++ b/agenta-web/src/components/Playground/Views/ParametersCards.tsx @@ -63,7 +63,7 @@ const useStyles = createUseStyles({ interface ModelParametersProps { optParams: Parameter[] | null onChange: (param: Parameter, value: number | string) => void - handleParamChange: (name: string, value: number | string) => void + handleParamChange: (name: string, value: number | string | boolean) => void } export const ModelParameters: React.FC = ({ @@ -73,8 +73,7 @@ export const ModelParameters: React.FC = ({ }) => { const classes = useStyles() const handleCheckboxChange = (paramName: string, checked: boolean) => { - const value = checked ? 1 : 0 - handleParamChange(paramName, value) + handleParamChange(paramName, checked) } return ( <> From 79e8de87ed7270a3159963558ce5f6564cb413d9 Mon Sep 17 00:00:00 2001 From: Abram Date: Wed, 20 Dec 2023 00:34:05 +0100 Subject: [PATCH 3/3] Update - modified default parameter --- examples/chat_json_format/app.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/chat_json_format/app.py b/examples/chat_json_format/app.py index 8f9d234480..a47f659c35 100644 --- a/examples/chat_json_format/app.py +++ b/examples/chat_json_format/app.py @@ -1,5 +1,4 @@ import agenta as ag -from agenta.sdk.types import BinaryParam from openai import OpenAI client = OpenAI() @@ -20,7 +19,7 @@ model=ag.MultipleChoiceParam("gpt-3.5-turbo", CHAT_LLM_GPT), max_tokens=ag.IntParam(-1, -1, 4000), prompt_system=ag.TextParam(SYSTEM_PROMPT), - force_json_response=BinaryParam(), + force_json_response=ag.BinaryParam(False), )