Skip to content

Commit

Permalink
perf: 优化模型配置选项
Browse files Browse the repository at this point in the history
!!!BREAKING CHANGES!!!
自定义的openai接口,请添加 /v1 路径
  • Loading branch information
rehiy committed Apr 13, 2024
1 parent 0be4a06 commit 9033dec
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 97 deletions.
5 changes: 0 additions & 5 deletions dbase/setting/extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ var (
FriendAccept = true
// 添加好友后的响应内容,留空则忽略
FriendHello = "群主去修仙了,请留言"
// 自动下载消息中的文件
AutoSaveFile = true
// 自动下载消息中的图片
AutoSaveImage = true
// 群聊撤回消息时响应的内容,留空则忽略
Expand Down Expand Up @@ -60,8 +58,6 @@ func Laod() {
FriendAccept = item.Value == "true"
case "FriendHello":
FriendHello = item.Value
case "AutoSaveFile":
AutoSaveImage = item.Value == "true"
case "AutoSaveImage":
AutoSaveImage = item.Value == "true"
case "RevokeMsg":
Expand Down Expand Up @@ -94,7 +90,6 @@ func DataMigrate() {
{0, "InvalidHandler", "text", "bot", InvalidHandler, "指令未注册", "未注册指令时响应的内容,仅对\"/\"开头的指令有效"},
{0, "FriendAccept", "bool", "bot", strconv.FormatBool(FriendAccept), "自动确认好友", "是否自动同意新的好友请求"},
{0, "FriendHello", "string", "bot", FriendHello, "好友打招呼", "添加好友后的响应内容"},
{0, "AutoSaveFile", "bool", "bot", strconv.FormatBool(AutoSaveFile), "自动保存文件", "是否自动下载消息中的文件"},
{0, "AutoSaveImage", "bool", "bot", strconv.FormatBool(AutoSaveImage), "自动保存图片", "是否自动下载消息中的图片"},
{0, "RevokeMsg", "string", "bot", RevokeMsg, "防撤回提醒", "群聊检测到撤回消息时响应的内容前缀"},
{0, "ModelDefault", "lmodel", "bot", ModelDefault, "默认 AI 模型", "/ai 指令默认使用的模型 Id"},
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/importcjj/sensitive v0.0.0-20200106142752-42d1c505be7b
github.com/mitchellh/mapstructure v1.5.0
github.com/opentdp/go-helper v0.7.2
github.com/rehiy/one-llm v0.2.1-0.20240329113024-83b57b0c6b06
github.com/rehiy/one-llm v0.3.0
github.com/robfig/cron/v3 v3.0.1
go.nanomsg.org/mangos/v3 v3.4.2
google.golang.org/protobuf v1.33.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeB
github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rehiy/one-llm v0.2.1-0.20240329113024-83b57b0c6b06 h1:FlSq860LN3qSoQvJVSS73wB9eFDSNTNIriwZMEi2pr4=
github.com/rehiy/one-llm v0.2.1-0.20240329113024-83b57b0c6b06/go.mod h1:Hvz5KUo9hy+fkwIDwG2ZtZtlHZzVrUhvAau+4/0oZZI=
github.com/rehiy/one-llm v0.3.0 h1:3mr7IZ+TtGaH2EiPiMSa4bJ3INiyVeP4FxSHw38z3CE=
github.com/rehiy/one-llm v0.3.0/go.mod h1:Hvz5KUo9hy+fkwIDwG2ZtZtlHZzVrUhvAau+4/0oZZI=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
Expand Down
41 changes: 12 additions & 29 deletions webview/src/apps/llmodel/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@
<div class="col-12">
<label class="form-label">服务商 *</label>
<select name="provider" class="form-select" [(ngModel)]="formdata.provider" required>
<option value="aliyun">阿里通义千问</option>
<option value="baidu">百度文心</option>
<option value="google">Google Gemini</option>
<option value="openai">OpenAI GPT</option>
<option value="tencent">腾讯混元</option>
<option value="xunfei">科大讯飞</option>
@for (item of aiModels | keyvalue; track item.key) {
<option [value]="item.key">{{item.value.name}}</option>
}
</select>
<div class="form-text">
未支持的服务商,可尝试使用协议兼容代理
Expand All @@ -65,26 +62,28 @@
<label class="form-label">模型 *</label>
<select name="model" class="form-select" [(ngModel)]="formdata.model" required>
<option value="-">不指定</option>
@if (formdata.provider === 'aliyun') {
@switch (formdata.provider) {
@case ('aliyun') {
<option value="qwen-max">qwen-max</option>
<option value="qwen-plus">qwen-plus</option>
}
@if (formdata.provider === 'baidu') {
@case ('baidu') {
<option value="completions_pro">ERNIE 4.0</option>
<option value="completions">ERNIE-3.5-8K</option>
}
@if (formdata.provider === 'google') {
@case('google') {
<option value="gemini-pro">gemini-pro</option>
}
@if (formdata.provider === 'openai') {
@case('openai') {
<option value="gpt-4">gpt-4</option>
<option value="gpt-4-32k">gpt-4-32k</option>
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
}
@if (formdata.provider === 'xunfei') {
@case ('xunfei') {
<option value="v3.5">星火 v3.5</option>
<option value="v3">星火 v3</option>
}
}
</select>
<div class="form-text">
必须和服务商对应,缺失模型请提 Issue 或 PR 补全
Expand All @@ -94,30 +93,14 @@
<label class="form-label">密钥 *</label>
<input type="text" name="secret" class="form-control" [(ngModel)]="formdata.secret" required />
<div class="form-text">
@switch (formdata.provider) {
@case ('xunfei') {
科大讯飞填写 APP-ID,API-KEY,API-SECRET
}
@case ('baidu') {
文心一言填写 API-KEY,API-SECRET
}
@case ('tencent') {
腾讯混元填写 APP-ID,API-KEY,API-SECRET
}
@case ('ali') {
阿里百炼(通义千问)填写 APP-ID,AGENT-KEY,ACCESS_KEY_ID,ACCESS_KEY_SECRET
}
@default {
请填写从服务商获取的 API-KEY
}
}
{{aiModels[formdata.provider].keystyle || '请填写从服务商获取的 API-KEY'}}
</div>
</div>
<div class="col-12">
<label class="form-label">接入点</label>
<input type="text" name="endpoint" class="form-control" [(ngModel)]="formdata.endpoint" />
<div class="form-text">
自定义接口地址,留空则使用官方接口
自定义接口地址,留空则使用官方接口:{{aiModels[formdata.provider].endpoint}}
</div>
</div>
<div class="col-12">
Expand Down
3 changes: 2 additions & 1 deletion webview/src/apps/llmodel/create.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';

import { UserLevels } from '../../openapi/const';
import { AiModels, UserLevels } from '../../openapi/const';
import { RobotApi, LlmodelCreateParam } from '../../openapi/wrobot';


Expand All @@ -11,6 +11,7 @@ import { RobotApi, LlmodelCreateParam } from '../../openapi/wrobot';
})
export class LLModelCreateComponent {

public aiModels = AiModels;
public userLevels = UserLevels;

public formdata: LlmodelCreateParam = {
Expand Down
41 changes: 12 additions & 29 deletions webview/src/apps/llmodel/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@
<div class="col-12">
<label class="form-label">服务商 *</label>
<select name="provider" class="form-select" [(ngModel)]="formdata.provider" required>
<option value="aliyun">阿里通义千问</option>
<option value="baidu">百度文心</option>
<option value="google">Google Gemini</option>
<option value="openai">OpenAI GPT</option>
<option value="tencent">腾讯混元</option>
<option value="xunfei">科大讯飞</option>
@for (item of aiModels | keyvalue; track item.key) {
<option [value]="item.key">{{item.value.name}}</option>
}
</select>
<div class="form-text">
未支持的服务商,可尝试使用协议兼容代理
Expand All @@ -65,26 +62,28 @@
<label class="form-label">模型 *</label>
<select name="model" class="form-select" [(ngModel)]="formdata.model" required>
<option value="-">不指定</option>
@if (formdata.provider === 'aliyun') {
@switch (formdata.provider) {
@case ('aliyun') {
<option value="qwen-max">qwen-max</option>
<option value="qwen-plus">qwen-plus</option>
}
@if (formdata.provider === 'baidu') {
@case ('baidu') {
<option value="completions_pro">ERNIE 4.0</option>
<option value="completions">ERNIE-3.5-8K</option>
}
@if (formdata.provider === 'google') {
@case('google') {
<option value="gemini-pro">gemini-pro</option>
}
@if (formdata.provider === 'openai') {
@case('openai') {
<option value="gpt-4">gpt-4</option>
<option value="gpt-4-32k">gpt-4-32k</option>
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
}
@if (formdata.provider === 'xunfei') {
@case ('xunfei') {
<option value="v3.5">星火 v3.5</option>
<option value="v3">星火 v3</option>
}
}
</select>
<div class="form-text">
必须和服务商对应,缺失模型请提 Issue 或 PR 补全
Expand All @@ -94,30 +93,14 @@
<label class="form-label">密钥 *</label>
<input type="text" name="secret" class="form-control" [(ngModel)]="formdata.secret" required />
<div class="form-text">
@switch (formdata.provider) {
@case ('xunfei') {
科大讯飞填写 APP-ID,API-KEY,API-SECRET
}
@case ('baidu') {
文心一言填写 API-KEY,API-SECRET
}
@case ('tencent') {
腾讯混元填写 APP-ID,API-KEY,API-SECRET
}
@case ('ali') {
阿里百炼(通义千问)填写 APP-ID,AGENT-KEY,ACCESS_KEY_ID,ACCESS_KEY_SECRET
}
@default {
请填写从服务商获取的 API-KEY
}
}
{{aiModels[formdata.provider].keystyle || '请填写从服务商获取的 API-KEY'}}
</div>
</div>
<div class="col-12">
<label class="form-label">接入点</label>
<input type="text" name="endpoint" class="form-control" [(ngModel)]="formdata.endpoint" />
<div class="form-text">
自定义接口地址,留空则使用官方接口
自定义接口地址,留空则使用官方接口:{{aiModels[formdata.provider].endpoint}}
</div>
</div>
<div class="col-12">
Expand Down
3 changes: 2 additions & 1 deletion webview/src/apps/llmodel/update.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';

import { UserLevels } from '../../openapi/const';
import { AiModels, UserLevels } from '../../openapi/const';
import { RobotApi, LlmodelUpdateParam } from '../../openapi/wrobot';


Expand All @@ -11,6 +11,7 @@ import { RobotApi, LlmodelUpdateParam } from '../../openapi/wrobot';
})
export class LLModelUpdateComponent implements OnInit {

public aiModels = AiModels;
public userLevels = UserLevels;

public formdata: LlmodelUpdateParam = {} as LlmodelUpdateParam;
Expand Down
Loading

0 comments on commit 9033dec

Please sign in to comment.