From ee7b25b8cf1ea7c1dbe7ea486b6d83ebf1c59d16 Mon Sep 17 00:00:00 2001 From: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:30:45 +0200 Subject: [PATCH] Remove unecessary literal_eval (#4570) --- haystack/nodes/prompt/prompt_template.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/haystack/nodes/prompt/prompt_template.py b/haystack/nodes/prompt/prompt_template.py index 0f158233b..55bcc211c 100644 --- a/haystack/nodes/prompt/prompt_template.py +++ b/haystack/nodes/prompt/prompt_template.py @@ -2,6 +2,7 @@ from typing import Optional, List, Union, Tuple, Dict, Iterator, Any import logging import os import ast +import json from abc import ABC from uuid import uuid4 @@ -21,7 +22,7 @@ from haystack.schema import Document, MultiLabel logger = logging.getLogger(__name__) -PROMPT_TEMPLATE_ALLOWED_FUNCTIONS = ast.literal_eval( +PROMPT_TEMPLATE_ALLOWED_FUNCTIONS = json.loads( os.environ.get(HAYSTACK_PROMPT_TEMPLATE_ALLOWED_FUNCTIONS, '["join", "to_strings", "replace", "enumerate", "str"]') ) PROMPT_TEMPLATE_SPECIAL_CHAR_ALIAS = {"new_line": "\n", "tab": "\t", "double_quote": '"', "carriage_return": "\r"}