Skip to content

Commit

Permalink
v2.24.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Dooy committed Jan 16, 2024
1 parent cb81930 commit ffe5eff
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 28 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- ✅ chatgpt 支持 GPTs 多模态
- ✅ chatgpt 支持 tts whisper
- ✅ 支持超链更换设置,适合 one-api 部署聊天 https://vercel.ddaiai.com/#/s/t?OPENAI_API_BASE_URL=https://abc.com&OPENAI_API_KEY=sk-xxxxx&MJ_SERVER=https://abc.com&MJ_API_SECRET=sk-xxx&UPLOADER_URL=
- ✅ 支持one-api部署聊天 https://vercel.ddaiai.com/#/?settings={%22key%22:%22sk-abc%22,%22url%22:%22https://www.abc.com%22} `(v.2.14.3)`

## 待开发
- ⏰ 支持 GPTs 多模态
Expand Down Expand Up @@ -115,8 +116,8 @@ docker run -d --name mj6013 -p 6013:8080 \
![多模态](./docs/gpts.jpg)
![多模态](./docs/gpts1.jpg)

### tts 和 whisper
![whisper--tts](./docs/tts.jpg)
### 录音 whisper 和 tts
![whisper--tts](./docs/tts-whisper.png)

### 局部重绘:
[![局部重绘](./docs/mj2.jpg)](./docs/mj2.jpg)
Expand Down
4 changes: 4 additions & 0 deletions changlog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 功能升级日志

# 2.14.3
- 😄 新增: 角色自定到会话 #75 #40
- 😄 新增: 支持one-api部署聊天 https://vercel.ddaiai.com/#/?settings={%22key%22:%22sk-abc%22,%22url%22:%22https://www.abc.com%22}

# 2.14.2
- 🐞 修复: gpt-4-1106-preview 模型 128000 #66
- 😄 新增: 录音whisper转文本对话ChatGPT
Expand Down
Binary file added docs/tts-whisper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chatgpt-web-midjourney-proxy",
"version": "2.14.2",
"version": "2.14.3",
"private": false,
"description": "ChatGPT Web Midjourney Proxy",
"author": "Dooy <[email protected]>",
Expand Down
47 changes: 47 additions & 0 deletions src/api/chat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//import { reactive } from 'vue'

import { gptConfigStore, gptConfigType } from "@/store";
import { ss } from '@/utils/storage'

export class chatSetting{
private uuid: number;
private localKey='chat-setting';
//private gptConfig: gptConfigType
// 构造函数
constructor(uuid: number) {
this.uuid = uuid;
//this.gptConfig = gptConfigStore.myData;
//this.init();
}

public setUuid(uuid: number){
this.uuid = uuid;
return this
}
public getGptConfig():gptConfigType {
const index = this.findIndex();
if( index<=-1) return gptConfigStore.myData;
const arr = this.getObjs();
return arr[index];
}
private getObjs():gptConfigType[]{
const obj = ss.get( this.localKey ) as undefined| gptConfigType[];
if(!obj) return [];
return obj;
}
private findIndex(){
return this.getObjs().findIndex(v=>v.uuid && v.uuid==this.uuid )
}
public save( obj : Partial<gptConfigType>){
let sobj ={ ...gptConfigStore.myData , ...obj };
sobj.uuid= this.uuid;
const index = this.findIndex();
let arr = this.getObjs();
if( index>-1 )arr[index]= sobj;
else arr.push( sobj );
ss.set(this.localKey, arr );
return this ;
}


}
1 change: 1 addition & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ export * from "./mjsave"
export * from "./openapi"
export * from "./units"
export * from "./mic"
export * from "./chat"
export * from "./sse/fetchsse"

27 changes: 24 additions & 3 deletions src/api/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { localGet, localSaveAny } from "./mjsave";
import { isNumber, isObject } from "@/utils/is";
import { t } from "@/locales";
import { ChatMessage } from "gpt-tokenizer/esm/GptEncoding";
import { chatSetting } from "./chat";
//import {encode, encodeChat} from "gpt-tokenizer"
//import {encode, encodeChat} from "gpt-tokenizer/cjs/encoding/cl100k_base.js";
//import { get_encoding } from '@dqbd/tiktoken'
Expand Down Expand Up @@ -162,9 +163,14 @@ function getHeaderAuthorization(){
}
}

export const getSystemMessage = ()=>{
export const getSystemMessage = (uuid?:number )=>{
//KnowledgeCutOffDate
if( gptConfigStore.myData.systemMessage) return gptConfigStore.myData.systemMessage
let sysTem= gptConfigStore.myData.systemMessage;
if( uuid ){
const chatS= new chatSetting(uuid);
sysTem= chatS.getGptConfig().systemMessage ;
}
if( sysTem ) return sysTem;
let model= gptConfigStore.myData.model?gptConfigStore.myData.model: "gpt-3.5-turbo";
const DEFAULT_SYSTEM_TEMPLATE = `You are ChatGPT, a large language model trained by OpenAI.
Knowledge cutoff: ${KnowledgeCutOffDate[model]}
Expand Down Expand Up @@ -317,7 +323,22 @@ export const gptUsage=async ()=>{
export const openaiSetting= ( q:any )=>{
//mlog()
mlog('setting', q )
if(isObject(q)){
if(q.settings){
mlog('q.setting', q.settings )
try {
let obj = JSON.parse( q.settings );
const url = obj.url ?? undefined;
const key = obj.key ?? undefined;
//let setQ= { }
gptServerStore.setMyData( {OPENAI_API_BASE_URL:url, MJ_SERVER:url, OPENAI_API_KEY:key,MJ_API_SECRET:key } )
blurClean();
gptServerStore.setMyData( gptServerStore.myData );

} catch (error) {

}
}
else if(isObject(q)){
mlog('setting2', q )
gptServerStore.setMyData( q )
//gptServerStore.setMyData( gptServerStore.myData );
Expand Down
19 changes: 3 additions & 16 deletions src/components/common/Setting/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,11 @@ const isShow = computed(()=>{
<div class="p-4 space-y-4">
<h2 class="text-xl font-bold">
Version - {{ pkg.version }}
<a class="text-red-500" href="https://github.com/Dooy/chatgpt-web-midjourney-proxy" target="_blank" v-if=" isShow "> (发现更新版本 {{ st.lastVersion }})</a>
<a class="text-gray-500" href="https://github.com/Dooy/chatgpt-web-midjourney-proxy" target="_blank" v-else-if="st.lastVersion"> (已是最新版本)</a>
<a class="text-red-500" href="https://github.com/Dooy/chatgpt-web-midjourney-proxy" target="_blank" v-if=" isShow "> ({{ $t('mj.findVersion') }} {{ st.lastVersion }})</a>
<a class="text-gray-500" href="https://github.com/Dooy/chatgpt-web-midjourney-proxy" target="_blank" v-else-if="st.lastVersion"> ({{ $t('mj.yesLastVersion') }})</a>
</h2>
<div class="p-2 space-y-2 rounded-md bg-neutral-100 dark:bg-neutral-700">
<p>
此项目开源于
<a
class="text-blue-600 dark:text-blue-500"
href="https://github.com/Dooy/chatgpt-web-midjourney-proxy"
target="_blank"
>
GitHub
</a>
,免费且基于 MIT 协议,没有任何形式的付费行为!
</p>
<p>
如果你觉得此项目对你有帮助,请在 GitHub 帮我点个 Star,谢谢!
</p>
<p v-html="$t('mj.infoStar')"></p>
</div>
<p>{{ $t("setting.api") }}:{{ config?.apiModel ?? '-' }}</p>
<p v-if="isChatGPTAPI" class=" flex items-center justify-between">
Expand Down
5 changes: 5 additions & 0 deletions src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,10 @@ export default {
,mCanel:'取消'
,mSent:'发送'

,findVersion:'发现更新版本'
,yesLastVersion:'已是最新版本'
,infoStar:'此项目开源于 <a class="text-blue-600 dark:text-blue-500" href="https://github.com/Dooy/chatgpt-web-midjourney-proxy" target="_blank"> GitHub </a>,免费且基于 MIT 协议,没有任何形式的付费行为! </p><p>如果你觉得此项目对你有帮助,请在 GitHub 帮我点个 Star,谢谢!'
,setBtSaveChat:'仅保存会话'
,setBtSaveSys: '保存至系统'
}
}
1 change: 1 addition & 0 deletions src/store/homeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface gptConfigType{
talkCount:number //联系对话
systemMessage:string //自定义系统提示语
gpts?:gptsType
uuid?:number
}
const getGptInt= ():gptConfigType =>{
let v:gptConfigType=getDefault();
Expand Down
2 changes: 2 additions & 0 deletions src/views/chat/layout/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ if(rt.name =='GPTs'){
ms.success( t('mj.modleSuccess') );
}
router.replace({ name: 'Chat', params: { uuid: chatStore.active } })
homeStore.setMyData({local:'Chat'});
const { isMobile } = useBasicLayout()
Expand Down
2 changes: 1 addition & 1 deletion src/views/mj/aiGpt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ watch(()=>homeStore.myData.act, async (n)=>{
let historyMesg= await getMessage();
mlog('historyMesg', historyMesg );
//return ;
let message= [ { "role": "system", "content": getSystemMessage() },
let message= [ { "role": "system", "content": getSystemMessage( +uuid2) },
...historyMesg ];
if( dd.fileBase64 && dd.fileBase64.length>0 ){
if( model=='gpt-4-vision-preview' ){
Expand Down
29 changes: 24 additions & 5 deletions src/views/mj/aiModel.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<script setup lang="ts">
import {NSelect, NInput,NSlider, NButton, useMessage} from "naive-ui"
import { ref ,computed,watch} from "vue";
import {gptConfigStore, homeStore} from '@/store'
import { mlog } from "@/api";
import { ref ,computed,watch, onMounted} from "vue";
import {gptConfigStore, homeStore,useChatStore} from '@/store'
import { mlog,chatSetting } from "@/api";
import { t } from "@/locales";
const emit = defineEmits(['close']);
const chatStore = useChatStore();
const uuid = chatStore.active;
//mlog('uuid', uuid );
const chatSet = new chatSetting( uuid==null?1002:uuid);
const config = ref({
model:[ 'gpt-4','gpt-3.5-turbo',`gpt-4-1106-preview`,`gpt-3.5-turbo-16k`,'gpt-4-0613','gpt-4-32k-0613' ,'gpt-4-32k','gpt-4-32k-0314',`gpt-3.5-turbo-16k-0613`
,`gpt-4-vision-preview`,`gpt-3.5-turbo-1106`
Expand Down Expand Up @@ -50,9 +55,16 @@ const modellist = computed(() => { //
const ms= useMessage();
const save = ()=>{
gptConfigStore.setMyData( gptConfigStore.myData );
ms.success('保存成功');
ms.success( t('common.saveSuccess')); //'保存成功'
emit('close');
}
const saveChat=()=>{
chatSet.save( gptConfigStore.myData );
//gptConfigStore.setInit(); //恢复下默认
gptConfigStore.myData.systemMessage= '';
ms.success( t('common.saveSuccess'));
emit('close');
}
watch(()=>gptConfigStore.myData.model,(n)=>{
gptConfigStore.myData.gpts=undefined;
Expand All @@ -65,6 +77,12 @@ watch(()=>gptConfigStore.myData.model,(n)=>{
config.value.maxToken=max/2;
if(gptConfigStore.myData.max_tokens> config.value.maxToken ) gptConfigStore.myData.max_tokens= config.value.maxToken;
})
onMounted(() => {
gptConfigStore.myData= chatSet.getGptConfig();
});
//
//const f= ref({model:gptConfigStore.myData.model});
</script>
Expand Down Expand Up @@ -109,6 +127,7 @@ watch(()=>gptConfigStore.myData.model,(n)=>{
</section>
<section class=" text-right flex justify-end space-x-2" >
<NButton @click="gptConfigStore.setInit()">{{ $t('mj.setBtBack') }}</NButton>
<NButton type="primary" @click="save">{{ $t('mj.setBtSave') }}</NButton>
<NButton type="primary" @click="saveChat">{{ $t('mj.setBtSaveChat') }}</NButton>
<NButton type="primary" @click="save">{{ $t('mj.setBtSaveSys') }}</NButton>
</section>
</template>

0 comments on commit ffe5eff

Please sign in to comment.