Skip to content

Commit 11d9840

Browse files
committed
fix typing validation
1 parent 72fa88d commit 11d9840

File tree

9 files changed

+58
-45
lines changed

9 files changed

+58
-45
lines changed

patchwork/common/utils/step_typing.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ def validate_step_type_config_with_inputs(
7676
or f"Missing required input data because {key_name} is set: {', '.join(missing_and_keys)}",
7777
)
7878

79-
# or_keys = set(step_type_config.or_op)
80-
# if len(or_keys) > 0:
81-
# missing_or_keys = or_keys.difference(input_keys)
82-
# if not is_key_set and len(missing_or_keys) == len(or_keys):
83-
# return (
84-
# False,
85-
# step_type_config.msg
86-
# or f"Missing required input: At least one of {', '.join(sorted([key_name, *or_keys]))} has to be set",
87-
# )
79+
or_keys = set(step_type_config.or_op)
80+
if len(or_keys) > 0:
81+
missing_or_keys = or_keys.difference(input_keys)
82+
if not is_key_set and len(missing_or_keys) == len(or_keys):
83+
return (
84+
False,
85+
step_type_config.msg
86+
or f"Missing required input: At least one of {', '.join(sorted([key_name, *or_keys]))} has to be set",
87+
)
8888

8989
xor_keys = set(step_type_config.xor_op)
9090
if len(xor_keys) > 0:

patchwork/steps/AgenticLLM/typed.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ class AgenticLLMInputs(TypedDict, total=False):
1111
user_prompt: str
1212
max_llm_calls: Annotated[int, StepTypeConfig(is_config=True)]
1313
openai_api_key: Annotated[
14-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "anthropic_api_key"])
14+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"])
1515
]
1616
anthropic_api_key: Annotated[
17-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "openai_api_key"])
17+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "openai_api_key"])
1818
]
1919
patched_api_key: Annotated[
2020
str,
2121
StepTypeConfig(
2222
is_config=True,
23-
or_op=["openai_api_key", "google_api_key", "anthropic_api_key"],
23+
or_op=["openai_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"],
2424
msg=f"""\
2525
Model API key not found.
2626
Please login at: "{TOKEN_URL}"
@@ -31,7 +31,10 @@ class AgenticLLMInputs(TypedDict, total=False):
3131
),
3232
]
3333
google_api_key: Annotated[
34-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key"])
34+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "client_is_gcp"])
35+
]
36+
client_is_gcp: Annotated[
37+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "google_api_key"])
3538
]
3639

3740

patchwork/steps/CallLLM/typed.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ class CallLLMInputs(TypedDict, total=False):
1313
model_args: Annotated[str, StepTypeConfig(is_config=True)]
1414
client_args: Annotated[str, StepTypeConfig(is_config=True)]
1515
openai_api_key: Annotated[
16-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "anthropic_api_key"])
16+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"])
1717
]
1818
anthropic_api_key: Annotated[
19-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "openai_api_key"])
19+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "openai_api_key"])
2020
]
2121
patched_api_key: Annotated[
2222
str,
2323
StepTypeConfig(
2424
is_config=True,
25-
or_op=["openai_api_key", "google_api_key", "anthropic_api_key"],
25+
or_op=["openai_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"],
2626
msg=f"""\
2727
Model API key not found.
2828
Please login at: "{TOKEN_URL}"
@@ -33,7 +33,10 @@ class CallLLMInputs(TypedDict, total=False):
3333
),
3434
]
3535
google_api_key: Annotated[
36-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key"])
36+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "client_is_gcp"])
37+
]
38+
client_is_gcp: Annotated[
39+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "google_api_key"])
3740
]
3841
file: Annotated[str, StepTypeConfig(is_path=True)]
3942

patchwork/steps/FileAgent/typed.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ class FileAgentInputs(__ReconcilationAgentRequiredInputs, total=False):
1111
base_path: str
1212
prompt_value: Dict[str, Any]
1313
max_llm_calls: Annotated[int, StepTypeConfig(is_config=True)]
14-
openai_api_key: Annotated[
15-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "anthropic_api_key"])
16-
]
17-
anthropic_api_key: Annotated[
18-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "openai_api_key"])
19-
]
20-
google_api_key: Annotated[
21-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key"])
22-
]
14+
anthropic_api_key: Annotated[str, StepTypeConfig(is_config=True)]
2315

2416

2517
class FileAgentOutputs(TypedDict):

patchwork/steps/FixIssue/typed.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ class __FixIssueRequiredInputs(TypedDict):
1111
class FixIssueInputs(__FixIssueRequiredInputs, total=False):
1212
base_path: Annotated[str, StepTypeConfig(is_path=True)]
1313
openai_api_key: Annotated[
14-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "anthropic_api_key"])
14+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"])
1515
]
1616
anthropic_api_key: Annotated[
17-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "openai_api_key"])
17+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "openai_api_key"])
1818
]
1919
patched_api_key: Annotated[
2020
str,
2121
StepTypeConfig(
2222
is_config=True,
23-
or_op=["openai_api_key", "google_api_key", "anthropic_api_key"],
23+
or_op=["openai_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"],
2424
msg=f"""\
2525
Model API key not found.
2626
Please login at: "{TOKEN_URL}"
@@ -31,7 +31,10 @@ class FixIssueInputs(__FixIssueRequiredInputs, total=False):
3131
),
3232
]
3333
google_api_key: Annotated[
34-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key"])
34+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "client_is_gcp"])
35+
]
36+
client_is_gcp: Annotated[
37+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "google_api_key"])
3538
]
3639

3740

patchwork/steps/GitHubAgent/typed.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ class GitHubAgentInputs(__GitHubAgentRequiredInputs, total=False):
1212
prompt_value: Dict[str, Any]
1313
max_llm_calls: Annotated[int, StepTypeConfig(is_config=True)]
1414
openai_api_key: Annotated[
15-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "anthropic_api_key"])
15+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"])
1616
]
1717
anthropic_api_key: Annotated[
18-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "openai_api_key"])
18+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "openai_api_key"])
1919
]
2020
google_api_key: Annotated[
21-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key"])
21+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "client_is_gcp", "anthropic_api_key"])
22+
]
23+
client_is_gcp: Annotated[
24+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "google_api_key"])
2225
]
2326

2427

patchwork/steps/LLM/typed.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ class LLMInputs(__LLMInputsRequired, total=False):
2121
model_args: Annotated[str, StepTypeConfig(is_config=True)]
2222
client_args: Annotated[str, StepTypeConfig(is_config=True)]
2323
openai_api_key: Annotated[
24-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "anthropic_api_key"])
24+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"])
2525
]
2626
anthropic_api_key: Annotated[
27-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "openai_api_key"])
27+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "openai_api_key"])
2828
]
2929
patched_api_key: Annotated[
3030
str,
3131
StepTypeConfig(
3232
is_config=True,
33-
or_op=["openai_api_key", "google_api_key", "anthropic_api_key"],
33+
or_op=["openai_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"],
3434
msg=f"""\
3535
Model API key not found.
3636
Please login at: "{TOKEN_URL}"
@@ -41,7 +41,10 @@ class LLMInputs(__LLMInputsRequired, total=False):
4141
),
4242
]
4343
google_api_key: Annotated[
44-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key"])
44+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "client_is_gcp"])
45+
]
46+
client_is_gcp: Annotated[
47+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "google_api_key"])
4548
]
4649
file: Annotated[str, StepTypeConfig(is_path=True)]
4750
# ExtractModelResponseInputs

patchwork/steps/SimplifiedLLM/typed.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ class SimplifiedLLMInputs(__SimplifiedLLMInputsRequired, total=False):
1616
max_llm_calls: Annotated[int, StepTypeConfig(is_config=True)]
1717
model: Annotated[str, StepTypeConfig(is_config=True)]
1818
openai_api_key: Annotated[
19-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "anthropic_api_key"])
19+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"])
2020
]
2121
anthropic_api_key: Annotated[
22-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "openai_api_key"])
22+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "openai_api_key"])
2323
]
2424
patched_api_key: Annotated[
2525
str,
2626
StepTypeConfig(
2727
is_config=True,
28-
or_op=["openai_api_key", "google_api_key", "anthropic_api_key"],
28+
or_op=["openai_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"],
2929
msg=f"""\
3030
Model API key not found.
3131
Please login at: "{TOKEN_URL}"
@@ -36,7 +36,10 @@ class SimplifiedLLMInputs(__SimplifiedLLMInputsRequired, total=False):
3636
),
3737
]
3838
google_api_key: Annotated[
39-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key"])
39+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "client_is_gcp"])
40+
]
41+
client_is_gcp: Annotated[
42+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "google_api_key"])
4043
]
4144
json: Annotated[bool, StepTypeConfig(is_config=True)]
4245
json_example_schema: Annotated[str, StepTypeConfig(is_config=True)]

patchwork/steps/SimplifiedLLMOnce/typed.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ class SimplifiedLLMOnceInputs(__SimplifiedLLMOncePBInputsRequired, total=False):
1616
# CallLLMInputs
1717
model: Annotated[str, StepTypeConfig(is_config=True)]
1818
openai_api_key: Annotated[
19-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "anthropic_api_key"])
19+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"])
2020
]
2121
anthropic_api_key: Annotated[
22-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "openai_api_key"])
22+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "openai_api_key"])
2323
]
2424
patched_api_key: Annotated[
2525
str,
2626
StepTypeConfig(
2727
is_config=True,
28-
or_op=["openai_api_key", "google_api_key", "anthropic_api_key"],
28+
or_op=["openai_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"],
2929
msg=f"""\
3030
Model API key not found.
3131
Please login at: "{TOKEN_URL}"
@@ -36,7 +36,10 @@ class SimplifiedLLMOnceInputs(__SimplifiedLLMOncePBInputsRequired, total=False):
3636
),
3737
]
3838
google_api_key: Annotated[
39-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key"])
39+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "client_is_gcp"])
40+
]
41+
client_is_gcp: Annotated[
42+
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "google_api_key"])
4043
]
4144
file: Annotated[str, StepTypeConfig(is_path=True)]
4245

0 commit comments

Comments
 (0)