Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make constructors forward-compatible #56

Merged
merged 1 commit into from
Sep 27, 2024
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
1 change: 1 addition & 0 deletions gptscript/confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ def __init__(self,
id: str = "",
accept: bool = "",
message: str = "",
**kwargs,
):
self.id = id
self.accept = accept
Expand Down
3 changes: 3 additions & 0 deletions gptscript/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self,
ephemeral: bool = False,
expiresAt: datetime = None,
refreshToken: str = "",
**kwargs,
):
self.context = context
self.toolName = toolName
Expand Down Expand Up @@ -62,6 +63,7 @@ def to_json(self):

return json.dumps(req)


class CredentialRequest:
def __init__(self,
content: str = "",
Expand All @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions gptscript/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self,
name: str = "",
entryToolId: str = "",
toolSet: dict[str, Tool] = None,
**kwargs,
):
self.name = name
self.entryToolId = entryToolId
Expand All @@ -67,6 +68,7 @@ def __init__(self,
end: str = "",
state: RunState = RunState.Creating,
chatState: str = "",
**kwargs,
):
self.id = id
self.type = type
Expand All @@ -88,6 +90,7 @@ class Call:
def __init__(self,
toolID: str = "",
input: str = "",
**kwargs,
):
self.toolID = toolID
self.input = input
Expand All @@ -97,6 +100,7 @@ class Output:
def __init__(self,
content: str = "",
subCalls: dict[str, Call] = None,
**kwargs,
):
self.content = content
self.subCalls = subCalls
Expand All @@ -106,6 +110,7 @@ class InputContext:
def __init__(self,
toolID: str = "",
content: str = "",
**kwargs,
):
self.toolID = toolID
self.content = content
Expand All @@ -116,6 +121,7 @@ def __init__(self,
promptTokens: int = 0,
completionTokens: int = 0,
totalTokens: int = 0,
**kwargs,
):
self.promptTokens = promptTokens
self.completionTokens = completionTokens
Expand Down Expand Up @@ -144,6 +150,7 @@ def __init__(self,
toolResults: int = 0,
llmRequest: Any = None,
llmResponse: Any = None,
**kwargs,
):
self.id = id
self.tool = tool
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gptscript/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class PromptResponse:
def __init__(self,
id: str = "",
responses: dict[str, str] = None,
**kwargs,
):
self.id = id
self.responses = responses
1 change: 1 addition & 0 deletions gptscript/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
7 changes: 7 additions & 0 deletions gptscript/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def __init__(self,
type: str = "string",
description: str = "",
default: str = "",
**kwargs,
):
self.type = type
self.description = description
Expand All @@ -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
Expand Down Expand Up @@ -66,6 +68,7 @@ def __init__(self,
instructions: str = "",
type: str = "",
metaData: dict[str, str] = None,
**kwargs,
):
self.name = name
self.description = description
Expand Down Expand Up @@ -111,6 +114,7 @@ def __init__(self,
reference: str = "",
arg: str = "",
toolID: str = "",
**kwargs,
):
self.named = named
self.reference = reference
Expand All @@ -128,6 +132,7 @@ def __init__(self,
Path: str = "",
Name: str = "",
Revision: str = "",
**kwargs,
):
self.VCS = VCS
self.Root = Root
Expand All @@ -141,6 +146,7 @@ def __init__(self,
location: str = "",
lineNo: int = 0,
repo: Repo = None,
**kwargs,
):
self.location = location
self.lineNo = lineNo
Expand Down Expand Up @@ -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,
Expand Down