frdel commited on
Commit
77adec3
·
1 Parent(s): 0c17095

support kwargs in prompt var plugins

Browse files
Files changed (1) hide show
  1. python/helpers/files.py +5 -5
python/helpers/files.py CHANGED
@@ -19,12 +19,12 @@ import mimetypes
19
 
20
  class VariablesPlugin(ABC):
21
  @abstractmethod
22
- def get_variables(self, file: str, backup_dirs: list[str] | None = None) -> dict[str, Any]: # type: ignore
23
  pass
24
 
25
 
26
  def load_plugin_variables(
27
- file: str, backup_dirs: list[str] | None = None
28
  ) -> dict[str, Any]:
29
  if not file.endswith(".md"):
30
  return {}
@@ -48,7 +48,7 @@ def load_plugin_variables(
48
  plugin_file, VariablesPlugin, one_per_file=False
49
  )
50
  for cls in classes:
51
- return cls().get_variables(file, backup_dirs) # type: ignore < abstract class here is ok, it is always a subclass
52
 
53
  # load python code and extract variables variables from it
54
  # module = None
@@ -96,7 +96,7 @@ def parse_file(
96
 
97
  is_json = is_full_json_template(content)
98
  content = remove_code_fences(content)
99
- variables = load_plugin_variables(absolute_path, _directories) or {} # type: ignore
100
  variables.update(kwargs)
101
  if is_json:
102
  content = replace_placeholders_json(content, **variables)
@@ -135,7 +135,7 @@ def read_prompt_file(
135
  # content = remove_code_fences(f.read())
136
  content = f.read()
137
 
138
- variables = load_plugin_variables(_file, _directories) or {} # type: ignore
139
  variables.update(kwargs)
140
 
141
  # Replace placeholders with values from kwargs
 
19
 
20
  class VariablesPlugin(ABC):
21
  @abstractmethod
22
+ def get_variables(self, file: str, backup_dirs: list[str] | None = None, **kwargs) -> dict[str, Any]: # type: ignore
23
  pass
24
 
25
 
26
  def load_plugin_variables(
27
+ file: str, backup_dirs: list[str] | None = None, **kwargs
28
  ) -> dict[str, Any]:
29
  if not file.endswith(".md"):
30
  return {}
 
48
  plugin_file, VariablesPlugin, one_per_file=False
49
  )
50
  for cls in classes:
51
+ return cls().get_variables(file, backup_dirs, **kwargs) # type: ignore < abstract class here is ok, it is always a subclass
52
 
53
  # load python code and extract variables variables from it
54
  # module = None
 
96
 
97
  is_json = is_full_json_template(content)
98
  content = remove_code_fences(content)
99
+ variables = load_plugin_variables(absolute_path, _directories, **kwargs) or {} # type: ignore
100
  variables.update(kwargs)
101
  if is_json:
102
  content = replace_placeholders_json(content, **variables)
 
135
  # content = remove_code_fences(f.read())
136
  content = f.read()
137
 
138
+ variables = load_plugin_variables(_file, _directories, **kwargs) or {} # type: ignore
139
  variables.update(kwargs)
140
 
141
  # Replace placeholders with values from kwargs