| 4 | |
| 5 | // openai 格式的消息模板(通用模板) |
| 6 | export function commonMsgTemplate(origin: string) { |
| 7 | // 检测是否使用自定义模型 |
| 8 | let model = config.model[config.service] === customModelString ? config.customModel[config.service] : config.model[config.service] |
| 9 | |
| 10 | // 删除模型名称中的中文括号及其内容,如"gpt-4(推荐)" -> "gpt-4" |
| 11 | model = model.replace(/(.*)/g, ""); |
| 12 | |
| 13 | let system = config.system_role[config.service] || defaultOption.system_role; |
| 14 | let user = (config.user_role[config.service] || defaultOption.user_role) |
| 15 | .replace('{{to}}', config.to).replace('{{origin}}', origin); |
| 16 | |
| 17 | return JSON.stringify({ |
| 18 | 'model': model, |
| 19 | "temperature": 1.0, |
| 20 | 'messages': [ |
| 21 | {'role': 'system', 'content': system}, |
| 22 | {'role': 'user', 'content': user}, |
| 23 | ] |
| 24 | }) |
| 25 | } |
| 26 | |
| 27 | // deepseek |
| 28 | export function deepseekMsgTemplate(origin: string) { |