2023-05-15 08:51:32 +08:00
|
|
|
# -*- coding:utf-8 -*-
|
|
|
|
from flask_restful import marshal_with, fields
|
|
|
|
|
|
|
|
from controllers.web import api
|
|
|
|
from controllers.web.wraps import WebApiResource
|
|
|
|
|
2023-07-27 13:08:57 +08:00
|
|
|
from models.model import App
|
|
|
|
|
2023-05-15 08:51:32 +08:00
|
|
|
|
|
|
|
class AppParameterApi(WebApiResource):
|
|
|
|
"""Resource for app variables."""
|
|
|
|
variable_fields = {
|
|
|
|
'key': fields.String,
|
|
|
|
'name': fields.String,
|
|
|
|
'description': fields.String,
|
|
|
|
'type': fields.String,
|
|
|
|
'default': fields.String,
|
|
|
|
'max_length': fields.Integer,
|
|
|
|
'options': fields.List(fields.String)
|
|
|
|
}
|
|
|
|
|
|
|
|
parameters_fields = {
|
|
|
|
'opening_statement': fields.String,
|
|
|
|
'suggested_questions': fields.Raw,
|
|
|
|
'suggested_questions_after_answer': fields.Raw,
|
2023-07-07 17:50:42 +08:00
|
|
|
'speech_to_text': fields.Raw,
|
2023-09-10 15:17:43 +08:00
|
|
|
'retriever_resource': fields.Raw,
|
2023-05-15 08:51:32 +08:00
|
|
|
'more_like_this': fields.Raw,
|
|
|
|
'user_input_form': fields.Raw,
|
2023-11-06 19:36:16 +08:00
|
|
|
'sensitive_word_avoidance': fields.Raw
|
2023-05-15 08:51:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@marshal_with(parameters_fields)
|
2023-07-27 13:08:57 +08:00
|
|
|
def get(self, app_model: App, end_user):
|
2023-05-15 08:51:32 +08:00
|
|
|
"""Retrieve app parameters."""
|
|
|
|
app_model_config = app_model.app_model_config
|
|
|
|
|
|
|
|
return {
|
|
|
|
'opening_statement': app_model_config.opening_statement,
|
|
|
|
'suggested_questions': app_model_config.suggested_questions_list,
|
|
|
|
'suggested_questions_after_answer': app_model_config.suggested_questions_after_answer_dict,
|
2023-08-12 00:57:00 +08:00
|
|
|
'speech_to_text': app_model_config.speech_to_text_dict,
|
2023-09-10 15:17:43 +08:00
|
|
|
'retriever_resource': app_model_config.retriever_resource_dict,
|
2023-05-15 08:51:32 +08:00
|
|
|
'more_like_this': app_model_config.more_like_this_dict,
|
2023-11-06 19:36:16 +08:00
|
|
|
'user_input_form': app_model_config.user_input_form_list,
|
|
|
|
'sensitive_word_avoidance': app_model_config.sensitive_word_avoidance_dict
|
2023-05-15 08:51:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
api.add_resource(AppParameterApi, '/parameters')
|