2023-05-15 08:51:32 +08:00
|
|
|
import json
|
|
|
|
|
2024-01-12 12:34:01 +08:00
|
|
|
from models.model import App, AppModelConfig
|
2023-05-15 08:51:32 +08:00
|
|
|
|
|
|
|
model_templates = {
|
|
|
|
# completion default mode
|
|
|
|
'completion_default': {
|
|
|
|
'app': {
|
|
|
|
'mode': 'completion',
|
|
|
|
'enable_site': True,
|
|
|
|
'enable_api': True,
|
|
|
|
'is_demo': False,
|
|
|
|
'api_rpm': 0,
|
|
|
|
'api_rph': 0,
|
|
|
|
'status': 'normal'
|
|
|
|
},
|
|
|
|
'model_config': {
|
|
|
|
'provider': 'openai',
|
2023-09-19 02:05:04 +08:00
|
|
|
'model_id': 'gpt-3.5-turbo-instruct',
|
2023-05-15 08:51:32 +08:00
|
|
|
'configs': {
|
|
|
|
'prompt_template': '',
|
|
|
|
'prompt_variables': [],
|
|
|
|
'completion_params': {
|
|
|
|
'max_token': 512,
|
|
|
|
'temperature': 1,
|
|
|
|
'top_p': 1,
|
|
|
|
'presence_penalty': 0,
|
|
|
|
'frequency_penalty': 0,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'model': json.dumps({
|
|
|
|
"provider": "openai",
|
2023-09-19 02:05:04 +08:00
|
|
|
"name": "gpt-3.5-turbo-instruct",
|
2023-10-12 23:13:10 +08:00
|
|
|
"mode": "completion",
|
2023-05-15 08:51:32 +08:00
|
|
|
"completion_params": {
|
|
|
|
"max_tokens": 512,
|
|
|
|
"temperature": 1,
|
|
|
|
"top_p": 1,
|
|
|
|
"presence_penalty": 0,
|
|
|
|
"frequency_penalty": 0
|
|
|
|
}
|
2023-09-10 00:12:34 +08:00
|
|
|
}),
|
|
|
|
'user_input_form': json.dumps([
|
|
|
|
{
|
|
|
|
"paragraph": {
|
|
|
|
"label": "Query",
|
|
|
|
"variable": "query",
|
|
|
|
"required": True,
|
|
|
|
"default": ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]),
|
|
|
|
'pre_prompt': '{{query}}'
|
2023-05-15 08:51:32 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
# chat default mode
|
|
|
|
'chat_default': {
|
|
|
|
'app': {
|
|
|
|
'mode': 'chat',
|
|
|
|
'enable_site': True,
|
|
|
|
'enable_api': True,
|
|
|
|
'is_demo': False,
|
|
|
|
'api_rpm': 0,
|
|
|
|
'api_rph': 0,
|
|
|
|
'status': 'normal'
|
|
|
|
},
|
|
|
|
'model_config': {
|
|
|
|
'provider': 'openai',
|
|
|
|
'model_id': 'gpt-3.5-turbo',
|
|
|
|
'configs': {
|
|
|
|
'prompt_template': '',
|
|
|
|
'prompt_variables': [],
|
|
|
|
'completion_params': {
|
|
|
|
'max_token': 512,
|
|
|
|
'temperature': 1,
|
|
|
|
'top_p': 1,
|
|
|
|
'presence_penalty': 0,
|
|
|
|
'frequency_penalty': 0,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'model': json.dumps({
|
|
|
|
"provider": "openai",
|
|
|
|
"name": "gpt-3.5-turbo",
|
2023-10-12 23:13:10 +08:00
|
|
|
"mode": "chat",
|
2023-05-15 08:51:32 +08:00
|
|
|
"completion_params": {
|
|
|
|
"max_tokens": 512,
|
|
|
|
"temperature": 1,
|
|
|
|
"top_p": 1,
|
|
|
|
"presence_penalty": 0,
|
|
|
|
"frequency_penalty": 0
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|