diff --git a/src/blackbox/fastchat.py b/src/blackbox/fastchat.py index 8e97a64..fb0188c 100755 --- a/src/blackbox/fastchat.py +++ b/src/blackbox/fastchat.py @@ -64,10 +64,17 @@ class Fastchat(Blackbox): user_model_name = data.get("model_name") user_prompt = data.get("prompt") user_template = data.get("template") - # user_template 是定义LLM的语气,例如template = "使用小丑的语气说话。",user_template可以为空字串,或者是用户自定义的语气,或者是使用我们提供的语气 if user_prompt is None: return JSONResponse(content={"error": "question is required"}, status_code=status.HTTP_400_BAD_REQUEST) - if user_model_name is None: - return JSONResponse(content={"error": "model selection is required"}, status_code=status.HTTP_400_BAD_REQUEST) + + if user_model_name is None or user_model_name.isspace(): + user_model_name = "Qwen1.5-14B-Chat" + + if user_template is None or user_template.isspace(): + # user_template 是定义LLM的语气,例如template = "使用小丑的语气说话。",user_template可以为空字串,或者是用户自定义的语气,或者是使用我们提供的语气 + user_template = "" + else: + user_template = f"使用{user_template}的语气说话。" + return JSONResponse(content={"Response": self.processing(user_model_name, user_prompt, user_template)}, status_code=status.HTTP_200_OK) \ No newline at end of file