diff --git a/python/src/aiconfig/schema.py b/python/src/aiconfig/schema.py index 7e7b9e864..e6730d339 100644 --- a/python/src/aiconfig/schema.py +++ b/python/src/aiconfig/schema.py @@ -355,7 +355,7 @@ def get_prompt(self, prompt_name: str) -> Prompt: raise IndexError("Prompt '{}' not found in config, available prompts are:\n {}".format(prompt_name, list(self.prompt_index.keys()))) return self.prompt_index[prompt_name] - def add_prompt(self, prompt_name: str, prompt_data: Prompt): + def add_prompt(self, prompt_name: str, prompt_data: Prompt, index: int | None = None): """ Adds a prompt to the .aiconfig. @@ -370,7 +370,10 @@ def add_prompt(self, prompt_name: str, prompt_data: Prompt): prompt_data.name = prompt_name self.prompt_index[prompt_name] = prompt_data - self.prompts.append(prompt_data) + if index is None: + self.prompts.append(prompt_data) + else: + self.prompts.insert(index, prompt_data) def update_prompt(self, prompt_name: str, prompt_data: Prompt): """