Fix basedpyright type errors (#25435)

Signed-off-by: -LAN- <laipz8200@outlook.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
-LAN- 2025-09-10 01:54:26 +08:00 • committed by GitHub
commit 08dd3f7b50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
100 changed files with 847 additions and 497 deletions

View file

@ -101,9 +101,22 @@ class SimplePromptTransform(PromptTransform):
with_memory_prompt=histories is not None,
)
variables = {k: inputs[k] for k in prompt_template_config["custom_variable_keys"] if k in inputs}
custom_variable_keys_obj = prompt_template_config["custom_variable_keys"]
special_variable_keys_obj = prompt_template_config["special_variable_keys"]
for v in prompt_template_config["special_variable_keys"]:
# Type check for custom_variable_keys
if not isinstance(custom_variable_keys_obj, list):
raise TypeError(f"Expected list for custom_variable_keys, got {type(custom_variable_keys_obj)}")
custom_variable_keys = cast(list[str], custom_variable_keys_obj)
# Type check for special_variable_keys
if not isinstance(special_variable_keys_obj, list):
raise TypeError(f"Expected list for special_variable_keys, got {type(special_variable_keys_obj)}")
special_variable_keys = cast(list[str], special_variable_keys_obj)
variables = {k: inputs[k] for k in custom_variable_keys if k in inputs}
for v in special_variable_keys:
# support #context#, #query# and #histories#
if v == "#context#":
variables["#context#"] = context or ""
@ -113,9 +126,16 @@ class SimplePromptTransform(PromptTransform):
variables["#histories#"] = histories or ""
prompt_template = prompt_template_config["prompt_template"]
if not isinstance(prompt_template, PromptTemplateParser):
raise TypeError(f"Expected PromptTemplateParser, got {type(prompt_template)}")
prompt = prompt_template.format(variables)
return prompt, prompt_template_config["prompt_rules"]
prompt_rules = prompt_template_config["prompt_rules"]
if not isinstance(prompt_rules, dict):
raise TypeError(f"Expected dict for prompt_rules, got {type(prompt_rules)}")
return prompt, prompt_rules
def get_prompt_template(
self,
@ -126,11 +146,11 @@ class SimplePromptTransform(PromptTransform):
has_context: bool,
query_in_prompt: bool,
with_memory_prompt: bool = False,
):
) -> dict[str, object]:
prompt_rules = self._get_prompt_rule(app_mode=app_mode, provider=provider, model=model)
custom_variable_keys = []
special_variable_keys = []
custom_variable_keys: list[str] = []
special_variable_keys: list[str] = []
prompt = ""
for order in prompt_rules["system_prompt_orders"]: