Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
19950187 authored and 19950187 committed Mar 19, 2024
1 parent 51b8f92 commit 8657f0a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
3 changes: 1 addition & 2 deletions core/basic_models/actions/string_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _generate_command_context(self, user: BaseUser, text_preprocessing_result: B

async def run(self, user: BaseUser, text_preprocessing_result: BaseTextPreprocessingResult,
params: Optional[Dict[str, Union[str, float, int]]] = None) -> List[Command]:
# Example: Command("ANSWER_TO_USER", {"answer": {"key1": "string1", "keyN": "stringN"}})
# Result command format: Command("ANSWER_TO_USER", {"answer": {"key1": "string1", "keyN": "stringN"}})
params = params or {}
command_params = self._generate_command_context(user, text_preprocessing_result, params)

Expand All @@ -161,7 +161,6 @@ def nodes(self):

async def run(self, user: User, text_preprocessing_result: BaseTextPreprocessingResult,
params: Optional[Dict[str, Union[str, float, int]]] = None) -> List[Command]:
# Example: Command("ANSWER_TO_USER", {"answer": {"key1": "string1", "keyN": "stringN"}})
command_params = dict()
params = copy(params) or {}
collected = user.parametrizer.collect(text_preprocessing_result, filter_params={"command": self.command})
Expand Down
4 changes: 2 additions & 2 deletions core/unified_template/unified_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import core.logging.logger_constants as log_const
from core.logging.logger_utils import log
from core.monitoring.monitoring import monitoring
from core.utils.loader import load_file

UNIFIED_TEMPLATE_TYPE_NAME = "unified_template"

Expand Down Expand Up @@ -102,7 +101,8 @@ def __init__(self, input):
templates_dir = os.path.join(app_config.STATIC_PATH, "references/templates")
for root, dirs, files in os.walk(templates_dir):
if file_name in files:
input["template"] = load_file(os.path.join(root, file_name))
with open(os.path.join(root, file_name)) as f:
input["template"] = f.read()
super().__init__(input)
return
raise Exception(f"Template {file_name} does not exist in templates directory {templates_dir}")
Expand Down
6 changes: 0 additions & 6 deletions core/utils/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,3 @@ def reverse_json_dict(data):
for value in values:
result[value] = key
return result


def load_file(file_path):
with open(file_path) as f:
file_content = f.read()
return file_content
12 changes: 5 additions & 7 deletions smart_kit/template/static/references/forms/hello_form.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@
"command": "ANSWER_TO_USER",
"nodes": {
"pronounceText": "Сколько лет ты программируешь на Python?",
"items": [
{
"bubble": {
"text": "Сколько лет ты программируешь на Python?"
}
}
]
"items": {
"type": "unified_template",
"file": "experience_items_template.jinja2",
"loader": "json"
}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{
[
{
"bubble": {
"text": "Сколько лет ты программируешь на Python?"
}
}
] |tojson
}}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ async def test_push_authentication_action_http_call(self, request_mock: Mock):
'RqUID': '3f68e69e-351b-4e6f-b251-480f0cb08a5d',
'Authorization': 'Basic QCE4OUZCLjRENjIuM0E1MS5BOUVCITAwMDEhOTZFNS5'
'BRTg5ITAwMDghQjFBRi5EQjdELjE1ODYuODRGMzpzZWNyZXQ='
# noqa
}
}
}
Expand Down

0 comments on commit 8657f0a

Please sign in to comment.