MCPcopy Create free account
hub / github.com/Bistutu/FluentRead / tongyiMsgTemplate

Function tongyiMsgTemplate

entrypoints/utils/template.ts:90–131  ·  view source on GitHub ↗
(origin: string)

Source from the content-addressed store, hash-verified

88
89// 通义千问
90export function tongyiMsgTemplate(origin: string) {
91 let model = config.model[config.service] === customModelString ? config.customModel[config.service] : config.model[config.service]
92 const normalTemplate = () => {
93 let system = config.system_role[config.service] || defaultOption.system_role;
94 let user = (config.user_role[config.service] || defaultOption.user_role)
95 .replace('{{to}}', config.to).replace('{{origin}}', origin);
96
97 return JSON.stringify({
98 "model": model,
99 "enable_thinking": false,
100 "messages": [
101 {"role": "system", "content": system},
102 {"role": "user", "content": user},
103 ]
104 })
105 }
106 // 翻译模型qwen-mt-plus和qwen-mt-turbo的格式和通用的不同
107 const mtModelTemplate = () => {
108 const langMap = [
109 {value: "zh-Hans", target: "zh"},
110 {value: "en"},
111 {value: "ja"},
112 {value: "ko"},
113 {value: "fr"},
114 {value: "ru"},
115 ]
116 let targetItem = langMap.find(i => i.value === config.to) || langMap[0]
117 let targetLang = targetItem.target || targetItem.value
118 return JSON.stringify({
119 "model": model,
120 "messages": [
121 {"role": "user", "content": origin},
122 ],
123 "translation_options": {
124 "source_lang": "auto",
125 "target_lang": targetLang
126 }
127 })
128 }
129 return model.startsWith("qwen-mt") ? mtModelTemplate() : normalTemplate()
130
131}
132
133// 文心一言
134export function yiyanMsgTemplate(origin: string) {

Callers 1

tongyiFunction · 0.90

Calls 2

mtModelTemplateFunction · 0.85
normalTemplateFunction · 0.85

Tested by

no test coverage detected