|
|
|
|
|
|
|
|
|
|
|
import os |
|
|
|
|
|
|
|
|
from flask_login import current_user |
|
|
from flask_login import current_user |
|
|
from flask_restful import Resource, reqparse |
|
|
from flask_restful import Resource, reqparse |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args() |
|
|
args = parser.parse_args() |
|
|
|
|
|
|
|
|
account = current_user |
|
|
account = current_user |
|
|
|
|
|
PROMPT_GENERATION_MAX_TOKENS = int(os.getenv('PROMPT_GENERATION_MAX_TOKENS', '512')) |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
rules = LLMGenerator.generate_rule_config( |
|
|
rules = LLMGenerator.generate_rule_config( |
|
|
tenant_id=account.current_tenant_id, |
|
|
tenant_id=account.current_tenant_id, |
|
|
instruction=args['instruction'], |
|
|
instruction=args['instruction'], |
|
|
model_config=args['model_config'], |
|
|
model_config=args['model_config'], |
|
|
no_variable=args['no_variable'] |
|
|
|
|
|
|
|
|
no_variable=args['no_variable'], |
|
|
|
|
|
rule_config_max_tokens=PROMPT_GENERATION_MAX_TOKENS |
|
|
) |
|
|
) |
|
|
except ProviderTokenNotInitError as ex: |
|
|
except ProviderTokenNotInitError as ex: |
|
|
raise ProviderNotInitializeError(ex.description) |
|
|
raise ProviderNotInitializeError(ex.description) |