Skip to content

Commit

Permalink
feature: 接入阿里qwen-long
Browse files Browse the repository at this point in the history
  • Loading branch information
Bistutu committed May 25, 2024
1 parent fb47d88 commit 1d8879b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
</el-icon>
{{ buttonText }}
</el-link>
<el-link class="right" href="https://fr.unmeta.cn/introduce" target="_blank">
<el-link class="right" href="https://github.com/Bistutu/FluentRead" target="_blank">
<el-icon style="margin-right: 1px;font-size: 1.25em">
<Star/>
</el-icon>
插件介绍
GitHub开源
</el-link>
</template>

Expand Down
7 changes: 4 additions & 3 deletions components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<span class="popup-text popup-vertical-left">翻译服务</span>
</el-col>
<el-col :span="12">
<b>
<el-select v-model="config.service" placeholder="请选择翻译服务">
<el-option
class="select-left"
Expand All @@ -80,6 +81,7 @@
:disabled="item.disabled"
/>
</el-select>
</b>
</el-col>
</el-row>

Expand Down Expand Up @@ -134,7 +136,7 @@
<el-tooltip
class="box-item"
effect="dark"
content="你的令牌将存储在本地,流畅阅读不会获取你的任何token信息。对应服务的token获取方式请自行搜索,如:文心一言 api"
content="你的令牌将存储在本地,流畅阅读不会获取你的任何token信息。对应服务的token获取方式请自行搜索,如:Kimi api"
placement="top-start"
>
<span class="popup-text popup-vertical-left">token令牌<el-icon class="icon-margin"><ChatDotRound/></el-icon></span>
Expand Down Expand Up @@ -315,7 +317,7 @@
<script lang="ts" setup>
// Main 处理配置信息
import {computed, ref, watch} from 'vue'
import {defaultOption, models, options, services, servicesType} from "../entrypoints/utils/option";
import {models, options, servicesType} from "../entrypoints/utils/option";
import {Config} from "@/entrypoints/utils/model";
// 配置信息
Expand Down Expand Up @@ -378,5 +380,4 @@ let compute = ref({
.icon-margin {
margin-left: 0.25em;
}
</style>
6 changes: 5 additions & 1 deletion entrypoints/service/tongyi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ async function tongyi(config: Config, message: any) {

if (resp.ok) {
let result = await resp.json();
return result.output.text
if (config.model[config.service] === "qwen-long") return result.output.choices[0].message.content;
else return result.output.text
} else {
console.log(resp)
throw new Error(`翻译失败: ${resp.status} ${resp.statusText} body: ${await resp.text()}`);
}
}

export default tongyi;


//
2 changes: 1 addition & 1 deletion entrypoints/utils/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const models = new Map<string, Array<string>>([
[services.openai, ["gpt-3.5-turbo", "gpt-4o", "gpt-4", "gpt-4-turbo", customModelString]],
[services.gemini, ["gemini-pro", "gemini-1.5-pro", "gemini-1.5-flash", customModelString]],
[services.yiyan, ["ERNIE-Bot 4.0", "ERNIE-Bot", "ERNIE-Speed-8K", "ERNIE-Speed-128K"]], // 因文心一言模式不同,暂不支持自定义模型(还需根据model获取最终的url请求参数)
[services.tongyi, ["qwen-turbo", "qwen-plus", "qwen-max", "qwen-max-longcontext", customModelString]],
[services.tongyi, ["qwen-long","qwen-turbo", "qwen-plus", "qwen-max", "qwen-max-longcontext", customModelString]],
[services.zhipu, ["glm-4", "glm-4v", "glm-3-turbo", customModelString]],
[services.moonshot, ["moonshot-v1-8k", customModelString]],
[services.claude, ["claude3-Haiku", "claude3-Sonnet", "claude3-Opus"]], // claude 也不支持自定义模型
Expand Down

0 comments on commit 1d8879b

Please sign in to comment.