mirror of
https://github.com/lightbroker/llmsecops-research.git
synced 2026-07-30 08:08:54 +02:00
add env var for prompt template dir; error handling
This commit is contained in:
@@ -13,10 +13,11 @@ class PromptTemplateRepository(AbstractPromptTemplateRepository):
|
||||
return os.path.join(self.templates_dir, template_filename)
|
||||
|
||||
def get(self, id: str) -> PromptTemplate:
|
||||
path = self._create_path_from_id(id)
|
||||
try:
|
||||
return load_prompt(self._create_path_from_id(id))
|
||||
return load_prompt(path)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(f'Failed to load template from path "{path}":\n{e}')
|
||||
return None
|
||||
|
||||
def add(self, id: str, prompt_template: PromptTemplate) -> None:
|
||||
|
||||
@@ -186,6 +186,10 @@ class TextGenerationCompletionService(
|
||||
prompt_template = self.prompt_template_service.get(
|
||||
id=self.constants.PromptTemplateIds.PHI_3_MINI_4K_INSTRUCT_BASIC
|
||||
)
|
||||
|
||||
if prompt_template is None:
|
||||
raise ValueError(f"Prompt template not found for ID: {self.constants.PromptTemplateIds.PHI_3_MINI_4K_INSTRUCT_BASIC}")
|
||||
|
||||
return (
|
||||
{ "question": RunnablePassthrough() }
|
||||
| prompt_template
|
||||
|
||||
Reference in New Issue
Block a user