Skip to content

Commit

Permalink
v2.14.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Dooy committed Jan 23, 2024
1 parent e8e6e8f commit 911595e
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 52 deletions.
7 changes: 6 additions & 1 deletion changlog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# 功能升级日志

# 计划
- 😄 新增: `temperature``top_p` 补回设置


# 2.14.7
- 😄 新增: 补回`temperature``top_p` `presence_penalty` `frequency_penalty`设置 #86
- 😄 优化: 切换模型中 所有设置能随着对话框保存
- 🐞 修复: 默认画图打开 #99

# 2.14.6
- 😄 新增: 语言版本`法语` `土耳其语` 感谢 @M4K4R PR
Expand Down
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.6",
"version": "2.14.7",
"private": false,
"description": "ChatGPT Web Midjourney Proxy",
"author": "Dooy <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class chatSetting{
if(!obj) return [];
return obj;
}
private findIndex(){
public findIndex(){
return this.getObjs().findIndex(v=>v.uuid && v.uuid==this.uuid )
}
public save( obj : Partial<gptConfigType>){
Expand Down
20 changes: 17 additions & 3 deletions src/api/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ interface subModelType{
onError?:(d?:any)=>void
signal?:AbortSignal
model?:string
uuid?:string|number
}
function getHeaderAuthorization(){
if(!gptServerStore.myData.OPENAI_API_KEY){
Expand Down Expand Up @@ -185,13 +186,26 @@ export const subModel= async (opt: subModelType)=>{
//
const model= opt.model?? ( gptConfigStore.myData.model?gptConfigStore.myData.model: "gpt-3.5-turbo");
let max_tokens= gptConfigStore.myData.max_tokens;
let temperature= 0.5;
let top_p= 1;
let presence_penalty= 0 , frequency_penalty=0;
if(opt.uuid){
const chatSet= new chatSetting( +opt.uuid);
const gStore= chatSet.getGptConfig();
temperature= gStore.temperature??temperature;
top_p = gStore.top_p??top_p;
presence_penalty = gStore.presence_penalty??presence_penalty;
frequency_penalty = gStore.frequency_penalty??frequency_penalty;
max_tokens= gStore.max_tokens;
}
if(model=='gpt-4-vision-preview' && max_tokens>2048) max_tokens=2048;

let body ={
max_tokens ,
model ,
"temperature": 0.5,
"top_p": 1,
"presence_penalty":0,
temperature,
top_p,
presence_penalty ,frequency_penalty,
"messages": opt.message
,stream:true
}
Expand Down
2 changes: 1 addition & 1 deletion src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default {
,myModle:'自定义模型'
,historyCnt:'上下文数量'
,historyToken:'更多的上下文会使记忆更精确,但会消耗更多的额度'
,historyTCnt:'回复数'
,historyTCnt:'回复数(max_tokens)'
,historyTCntInfo:'回复数越大 ,越有可能消耗更多的额度'
,role:'角色设定'
,rolePlaceholder:'给你的会话设置一个专属的角色,不是必须'
Expand Down
10 changes: 9 additions & 1 deletion src/store/homeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export interface gptConfigType{
systemMessage:string //自定义系统提示语
gpts?:gptsType
uuid?:number
temperature?:number // 随机性 : 值越大,回复越随机
top_p?:number // 核采样 : 与随机性类似,但不要和随机性一起更改
frequency_penalty?:number
presence_penalty?:number
}
const getGptInt= ():gptConfigType =>{
let v:gptConfigType=getDefault();
Expand All @@ -48,7 +52,11 @@ let v:gptConfigType={
max_tokens:1024,
userModel:'',
talkCount:10,
systemMessage:''
systemMessage:'',
temperature:0.5,
top_p:1,
presence_penalty:0,
frequency_penalty:0,
}
return v ;
}
Expand Down
17 changes: 11 additions & 6 deletions src/views/chat/components/Header/index.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script lang="ts" setup>
import { computed, nextTick,ref } from 'vue'
import { computed, nextTick,ref,watch } from 'vue'
import { HoverButton, SvgIcon } from '@/components/common'
import { gptConfigStore, homeStore, useAppStore, useChatStore } from '@/store'
import { gptConfigStore, homeStore, useAppStore, useChatStore } from '@/store'
import { useBasicLayout } from '@/hooks/useBasicLayout'
import {NModal} from "naive-ui"
import aiModel from "@/views/mj/aiModel.vue"
import { chatSetting } from '@/api'
const { isMobile } = useBasicLayout()
Expand Down Expand Up @@ -44,8 +45,12 @@ function handleExport() {
function handleClear() {
emit('handleClear')
}
const uuid = chatStore.active;
const chatSet = new chatSetting( uuid==null?1002:uuid);
const nGptStore = ref( chatSet.getGptConfig()) ;
const st = ref({isShow:false});
watch(()=>gptConfigStore.myData,()=>nGptStore.value= chatSet.getGptConfig() , {deep:true})
watch(()=>homeStore.myData.act,(n)=> n=='saveChat' && (nGptStore.value= chatSet.getGptConfig() ), {deep:true})
</script>

<template>
Expand Down Expand Up @@ -84,13 +89,13 @@ const st = ref({isShow:false});

<div @click="st.isShow=true" class="absolute left-1/2 top-full -translate-x-1/2 cursor-pointer select-none rounded-b-md border bg-white px-2 dark:border-neutral-800 dark:bg-[#111114]">
<div class="flex items-center justify-center space-x-1 cursor-pointer hover:text-[#4b9e5f]" v-if="homeStore.myData.local!='draw'">
<template v-if="gptConfigStore.myData.gpts">
<template v-if="nGptStore.gpts">
<SvgIcon icon="ri:apps-fill" />
<span class="line-clamp-1 overflow-hidden">{{ gptConfigStore.myData.gpts.name }}</span>
<span class="line-clamp-1 overflow-hidden">{{ nGptStore.gpts.name }}</span>
</template>
<template v-else >
<SvgIcon icon="heroicons:sparkles" />
<span >{{ gptConfigStore.myData.model }}</span>
<span >{{ nGptStore.model }}</span>
</template>
<SvgIcon icon="icon-park-outline:right" />
</div>
Expand Down
34 changes: 23 additions & 11 deletions src/views/mj/aiGpt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { computed, ref,watch } from 'vue'
import { useRoute } from 'vue-router'
import { useChat } from '../chat/hooks/useChat'
import { gptConfigStore, homeStore, useChatStore } from '@/store'
import { getInitChat, mlog, subModel,getSystemMessage , localSaveAny, canVisionModel, isTTS, subTTS, file2blob, whisperUpload, getHistoryMessage, localGet, checkDisableGpt4 } from '@/api'
import { getInitChat, mlog, subModel,getSystemMessage , localSaveAny, canVisionModel, isTTS, subTTS, file2blob, whisperUpload, getHistoryMessage, localGet, checkDisableGpt4, chatSetting } from '@/api'
//import { isNumber } from '@/utils/is'
import { useMessage } from "naive-ui";
import { t } from "@/locales";
Expand Down Expand Up @@ -45,15 +45,19 @@ watch( ()=>textRz.value, (n)=>{
const { uuid } = useRoute().params as { uuid: string }
watch(()=>homeStore.myData.act, async (n)=>{
if(n=='gpt.submit' || n=='gpt.whisper' ){
if(checkDisableGpt4(gptConfigStore.myData.model)){
ms.error( t('mj.disableGpt4') );
return false;
}
const dd:any = homeStore.myData.actData;
mlog('gpt.submit', dd , dd.uuid) ;
let uuid2 = dd.uuid?? uuid;
st.value.uuid = uuid2 ;
let model = gptConfigStore.myData.model
const chatSet = new chatSetting( +st.value.uuid );
const nGptStore = chatSet.getGptConfig() ;
let model = nGptStore.model ;//gptConfigStore.myData.model
if(checkDisableGpt4( model )){
ms.error( t('mj.disableGpt4') );
return false;
}
let promptMsg = getInitChat(dd.prompt );
if( dd.fileBase64 && dd.fileBase64.length>0 ){
Expand Down Expand Up @@ -171,14 +175,17 @@ watch(()=>homeStore.myData.act, async (n)=>{
}else if(n=='abort'){
controller.value && controller.value.abort();
}else if(n=='gpt.resubmit'){
if(checkDisableGpt4(gptConfigStore.myData.model)){
ms.error( t('mj.disableGpt4') );
return false;
}
// if(checkDisableGpt4(gptConfigStore.myData.model)){
// ms.error( t('mj.disableGpt4') );
// return false;
// }
const dd:any = homeStore.myData.actData;
let uuid2 = dd.uuid?? uuid;
st.value.uuid = uuid2 ;
st.value.index = +dd.index;
mlog('gpt.resubmit', dd ) ;
let historyMesg= await getMessage( (+dd.index)-1,1 ); //
Expand All @@ -187,14 +194,18 @@ watch(()=>homeStore.myData.act, async (n)=>{
//mlog('gpt.resubmit model', nobj.model );
let model = nobj.model
if(!model) model= 'gpt-3.5-turbo';
if(checkDisableGpt4( model )){
ms.error( t('mj.disableGpt4') );
return false;
}
//return ;
if(['whisper-1','midjourney'].indexOf(model)>-1){
ms.error( t('mj.noSuppertModel') );
return;
}
controller.value = new AbortController();
let message= [ { "role": "system", "content": getSystemMessage() },
let message= [ { "role": "system", "content": getSystemMessage(+st.value.uuid ) },
...historyMesg ];
textRz.value=[];
submit(model, message );
Expand Down Expand Up @@ -278,6 +289,7 @@ const submit= (model:string, message:any[] , opt?:any )=>{
}else{
//controller.signal
subModel( {message,model
,uuid:st.value.uuid //当前会话
,onMessage:(d)=>{
mlog('🐞消息',d);
textRz.value.push(d.text);
Expand Down
9 changes: 7 additions & 2 deletions src/views/mj/aiGptsCom.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { myFetch, gptsType, mlog } from '@/api';
import { myFetch, gptsType, mlog, chatSetting } from '@/api';
import { homeStore,gptConfigStore,useChatStore } from '@/store';
import { ref,computed ,watch } from 'vue';
import { useMessage ,NButton,NImage,NTag} from 'naive-ui';
Expand All @@ -26,7 +26,12 @@ const load= async ()=>{
tag.value= d.tag as string[];
}
const go= async ( item: gptsType)=>{
gptConfigStore.setMyData({model: `${ item.gid }` ,gpts:item});
const saveObj= {model: `${ item.gid }` ,gpts:item}
gptConfigStore.setMyData(saveObj);
if(chatStore.active){ //保存到对话框
const chatSet = new chatSetting( chatStore.active );
if( chatSet.findIndex()>-1 ) chatSet.save( saveObj )
}
ms.success(t('mjchat.success2'));
const gptUrl= `https://gpts.ddaiai.com/open/gptsapi/use`;
myFetch(gptUrl,item );
Expand Down
11 changes: 5 additions & 6 deletions src/views/mj/aiMobileMenu.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<script setup lang="ts">
import { SvgIcon } from '@/components/common';
import { homeStore,useChatStore} from '@/store'
import { homeStore } from '@/store'
import { computed,watch ,ref } from 'vue'
import { router } from '@/router'
import aiDrawInput from './aiDrawInput.vue';
import {NDrawerContent,NDrawer} from "naive-ui";
const chatStore = useChatStore()
const st= ref({show:false})
const st= ref({show:true})
const goHome =computed( () => {
//router.push('/')
Expand All @@ -21,10 +20,10 @@ function drawSent(e:any){
watch(()=>homeStore.myData.act, (n:string)=>{
if('showChat'==n){
router.push('/chat/'+ chatStore.active??'1002')
router.push('/chat')
}
if('showDraw'==n){
router.push('/draw/'+ chatStore.active??'1002')
router.push('/draw')
st.value.show=true;
}
});
Expand All @@ -51,7 +50,7 @@ watch(()=>homeStore.myData.act, (n:string)=>{
</div>
</div>

<n-drawer v-model:show="st.show" :height="650" placement="bottom">
<n-drawer v-model:show="st.show" :height="650" placement="bottom" v-if="goHome=='draw'">
<n-drawer-content style="--n-body-padding:0" class="h-full">
<aiDrawInput @draw-sent="drawSent" />
</n-drawer-content>
Expand Down
Loading

0 comments on commit 911595e

Please sign in to comment.