From 48bb1ab5f17cc7c26d5c86b5e9e7031ab7f71e42 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Fri, 27 Sep 2024 10:07:08 -0400 Subject: [PATCH] fix: make constructors forward-compatible Signed-off-by: Donnie Adams --- gptscript/confirm.py | 1 + gptscript/credentials.py | 3 +++ gptscript/frame.py | 8 ++++++++ gptscript/prompt.py | 1 + gptscript/text.py | 1 + gptscript/tool.py | 7 +++++++ 6 files changed, 21 insertions(+) diff --git a/gptscript/confirm.py b/gptscript/confirm.py index 53abcbc..ec1054b 100644 --- a/gptscript/confirm.py +++ b/gptscript/confirm.py @@ -3,6 +3,7 @@ def __init__(self, id: str = "", accept: bool = "", message: str = "", + **kwargs, ): self.id = id self.accept = accept diff --git a/gptscript/credentials.py b/gptscript/credentials.py index 5662ff0..9821b8c 100644 --- a/gptscript/credentials.py +++ b/gptscript/credentials.py @@ -22,6 +22,7 @@ def __init__(self, ephemeral: bool = False, expiresAt: datetime = None, refreshToken: str = "", + **kwargs, ): self.context = context self.toolName = toolName @@ -62,6 +63,7 @@ def to_json(self): return json.dumps(req) + class CredentialRequest: def __init__(self, content: str = "", @@ -77,6 +79,7 @@ def __init__(self, self.contexts = contexts self.name = name + def to_credential(c) -> Credential: expiresAt = c["expiresAt"] if expiresAt is not None: diff --git a/gptscript/frame.py b/gptscript/frame.py index 3073802..06a314e 100644 --- a/gptscript/frame.py +++ b/gptscript/frame.py @@ -43,6 +43,7 @@ def __init__(self, name: str = "", entryToolId: str = "", toolSet: dict[str, Tool] = None, + **kwargs, ): self.name = name self.entryToolId = entryToolId @@ -67,6 +68,7 @@ def __init__(self, end: str = "", state: RunState = RunState.Creating, chatState: str = "", + **kwargs, ): self.id = id self.type = type @@ -88,6 +90,7 @@ class Call: def __init__(self, toolID: str = "", input: str = "", + **kwargs, ): self.toolID = toolID self.input = input @@ -97,6 +100,7 @@ class Output: def __init__(self, content: str = "", subCalls: dict[str, Call] = None, + **kwargs, ): self.content = content self.subCalls = subCalls @@ -106,6 +110,7 @@ class InputContext: def __init__(self, toolID: str = "", content: str = "", + **kwargs, ): self.toolID = toolID self.content = content @@ -116,6 +121,7 @@ def __init__(self, promptTokens: int = 0, completionTokens: int = 0, totalTokens: int = 0, + **kwargs, ): self.promptTokens = promptTokens self.completionTokens = completionTokens @@ -144,6 +150,7 @@ def __init__(self, toolResults: int = 0, llmRequest: Any = None, llmResponse: Any = None, + **kwargs, ): self.id = id self.tool = tool @@ -196,6 +203,7 @@ def __init__(self, fields: list[str] = None, metadata: dict[str, str] = None, sensitive: bool = False, + **kwargs, ): self.id = id self.time = time diff --git a/gptscript/prompt.py b/gptscript/prompt.py index 3765fad..d27e130 100644 --- a/gptscript/prompt.py +++ b/gptscript/prompt.py @@ -2,6 +2,7 @@ class PromptResponse: def __init__(self, id: str = "", responses: dict[str, str] = None, + **kwargs, ): self.id = id self.responses = responses diff --git a/gptscript/text.py b/gptscript/text.py index 59d8d9c..f441f8f 100644 --- a/gptscript/text.py +++ b/gptscript/text.py @@ -5,6 +5,7 @@ class Text: def __init__(self, fmt: str = "", text: str = "", + **kwargs, ): if fmt == "" and text.startswith("!"): fmt = text[1:text.index("\n")] diff --git a/gptscript/tool.py b/gptscript/tool.py index d15e77b..e6e6096 100644 --- a/gptscript/tool.py +++ b/gptscript/tool.py @@ -6,6 +6,7 @@ def __init__(self, type: str = "string", description: str = "", default: str = "", + **kwargs, ): self.type = type self.description = description @@ -20,6 +21,7 @@ def __init__(self, type: str = "object", properties: dict[str, Property] = None, required: list[str] = None, + **kwargs, ): self.type = type self.properties = properties @@ -66,6 +68,7 @@ def __init__(self, instructions: str = "", type: str = "", metaData: dict[str, str] = None, + **kwargs, ): self.name = name self.description = description @@ -111,6 +114,7 @@ def __init__(self, reference: str = "", arg: str = "", toolID: str = "", + **kwargs, ): self.named = named self.reference = reference @@ -128,6 +132,7 @@ def __init__(self, Path: str = "", Name: str = "", Revision: str = "", + **kwargs, ): self.VCS = VCS self.Root = Root @@ -141,6 +146,7 @@ def __init__(self, location: str = "", lineNo: int = 0, repo: Repo = None, + **kwargs, ): self.location = location self.lineNo = lineNo @@ -186,6 +192,7 @@ def __init__(self, localTools: dict[str, str] = None, source: SourceRef = None, workingDir: str = "", + **kwargs, ): super().__init__(name, description, maxTokens, modelName, modelProvider, jsonResponse, temperature, cache, chat, internalPrompt, arguments, tools, globalTools, globalModelName, context, exportContext, export,