feat: template for instruction generation

deploy/dev
stream 7 months ago
parent c3940f1eed
commit 0ee992733c

@ -196,8 +196,27 @@ class InstructionGenerateApi(Resource):
except InvokeError as e: except InvokeError as e:
raise CompletionRequestError(e.description) raise CompletionRequestError(e.description)
class InstructionGenerationTemplateApi(Resource):
@setup_required
@login_required
@account_initialization_required
def post(self) -> dict:
parser = reqparse.RequestParser()
parser.add_argument("type", type=str, required=True, default=False, location="json")
args = parser.parse_args()
match args["type"]:
case "prompt":
from core.llm_generator.prompts import INSTRUCTION_GENERATE_TEMPLATE_PROMPT
return { "data": INSTRUCTION_GENERATE_TEMPLATE_PROMPT }
case "code":
from core.llm_generator.prompts import INSTRUCTION_GENERATE_TEMPLATE_CODE
return { "data": INSTRUCTION_GENERATE_TEMPLATE_CODE }
case _:
raise ValueError(f"Invalid type: {args['type']}")
api.add_resource(RuleGenerateApi, "/rule-generate") api.add_resource(RuleGenerateApi, "/rule-generate")
api.add_resource(RuleCodeGenerateApi, "/rule-code-generate") api.add_resource(RuleCodeGenerateApi, "/rule-code-generate")
api.add_resource(RuleStructuredOutputGenerateApi, "/rule-structured-output-generate") api.add_resource(RuleStructuredOutputGenerateApi, "/rule-structured-output-generate")
api.add_resource(InstructionGenerateApi, "/instruction-generate") api.add_resource(InstructionGenerateApi, "/instruction-generate")
api.add_resource(InstructionGenerationTemplateApi, "/instruction-generate/template")

@ -409,3 +409,11 @@ Both your input and output should be in JSON format.
Your output must strictly follow the schema format, do not output any content outside of the JSON body. Your output must strictly follow the schema format, do not output any content outside of the JSON body.
""" # noqa: E501 """ # noqa: E501
INSTRUCTION_GENERATE_TEMPLATE_PROMPT = """
The output of this prompt is not as expected. You should edit the prompt according to the IDEAL OUTPUT.
""" # noqa: E501
INSTRUCTION_GENERATE_TEMPLATE_CODE = """
Please fix the errors in the error message.
""" # noqa: E501

Loading…
Cancel
Save