Skip to content

Commit

Permalink
2.12.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Dooy committed Dec 17, 2023
1 parent 669e9d8 commit 0af8479
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
| AUTH_SECRET_KEY | 验证密码 ||||
| API_UPLOADER | 支持上传 | 关闭 || x|
| HIDE_SERVER | 前端ui隐藏服务端| || x|
| CUSTOM_MODELS | 自定义可选模型 ||||

## docker 部署
**假设**:
Expand Down
1 change: 1 addition & 0 deletions api/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = (req, res) => {
"model": "ChatGPTAPI",
"amodel": process.env.OPENAI_API_MODEL?? "gpt-3.5-turbo"
,isApiGallery: process.env.MJ_API_GALLERY ? true : false
,cmodels : process.env.CUSTOM_MODELS??''
}
}
res.writeHead(200).end(
Expand Down
7 changes: 7 additions & 0 deletions changlog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# 功能升级日志

## 2.12.10
- 🐞 修复:希望实现左侧绘画功能区固定,不随对话界面上下滚动 #29
- 🐞 修复:当服务端有错误,ui错误显示为空bug
- 🔨 优化:新增 `CUSTOM_MODELS` 环境变量 可自定义可选模型 #32



## 2.12.9
- 🐞 修复:按住回车不放,会一直触发提交刷新页面 #24
- 🔨 优化:我的画廊 支持来之服务端的数据(适合自建服务器)
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.12.9",
"version": "2.12.10",
"private": false,
"description": "ChatGPT Web Midjourney Proxy",
"author": "Dooy <[email protected]>",
Expand Down
3 changes: 3 additions & 0 deletions service/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ API_UPLOADER=

#HIDE_SERVER 隐藏服务端 1
HIDE_SERVER=

#自定义模型 CUSTOM_MODELS=-gpt-3.5-turbo-0301,gpt-4.5 不显示 gpt-3.5-turbo-0301 新增加 gpt-4.5
CUSTOM_MODELS=
3 changes: 2 additions & 1 deletion service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ router.post('/session', async (req, res) => {
const isHideServer= isNotEmptyString( process.env.HIDE_SERVER );
const amodel= process.env.OPENAI_API_MODEL?? "gpt-3.5-turbo" ;
const isApiGallery= isNotEmptyString( process.env.MJ_API_GALLERY );
res.send({ status: 'Success', message: '', data: {isHideServer,isUpload, auth: hasAuth, model: currentModel(),amodel,isApiGallery } })
const cmodels = process.env.CUSTOM_MODELS??'' ;
res.send({ status: 'Success', message: '', data: {isHideServer,isUpload, auth: hasAuth, model: currentModel(),amodel,isApiGallery,cmodels } })
}
catch (error) {
res.send({ status: 'Fail', message: error.message, data: null })
Expand Down
7 changes: 6 additions & 1 deletion src/api/sse/fetchsse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export async function fetchSSE(
fetch: types.FetchFn = globalFetch
) {
const { onMessage, onError, ...fetchOptions } = options
const res = await fetch(url, fetchOptions)
let res ;
try{
res = await fetch(url, fetchOptions)
}catch(e :any ){
throw {reason: JSON.stringify({message:'fetch error, pleace check url',url ,code:'fetch_error'}) }
}
if (!res.ok) {
let reason: string

Expand Down
2 changes: 1 addition & 1 deletion src/views/chat/components/Header/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const st = ref({isShow:false});
<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">
<SvgIcon icon="ri:apps-fill" />
<span>{{ gptConfigStore.myData.gpts.name }}</span>
<span class="line-clamp-1 overflow-hidden">{{ gptConfigStore.myData.gpts.name }}</span>
</template>
<template v-else >
<SvgIcon icon="heroicons:sparkles" />
Expand Down
4 changes: 3 additions & 1 deletion src/views/mj/aiGpt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ watch(()=>homeStore.myData.act, async (n)=>{
}
,onError:(e:any)=>{
mlog('onError',e)
const emsg = (JSON.stringify( e.reason? JSON.parse( e.reason ):e,null,2));
let emsg = (JSON.stringify( e.reason? JSON.parse( e.reason ):e,null,2));
//if(emsg=='{}' ) emsg= JSON.stringify(e );
if(e.message!='canceled' && emsg.indexOf('aborted')==-1 ) textRz.value.push("\n错误:\n```\n"+emsg+"\n```\n");
goFinish();
}
Expand Down
18 changes: 17 additions & 1 deletion src/views/mj/aiModel.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script setup lang="ts">
import {NSelect, NInput,NSlider, NButton, useMessage} from "naive-ui"
import { ref ,computed,watch} from "vue";
import {gptConfigStore} from '@/store'
import {gptConfigStore, homeStore} from '@/store'
import { mlog } from "@/api";
const emit = defineEmits(['close']);
const config = ref({
Expand All @@ -24,6 +25,21 @@ const modellist = computed(() => { //
rz.push({label:o,value:o})
}
}
//服务端的 CUSTOM_MODELS 设置
if( homeStore.myData.session.cmodels ){
let delModel:string[] = [];
let addModel:string[]=[];
homeStore.myData.session.cmodels.split(/[ ,]+/ig).map( (v:string)=>{
if(v.indexOf('-')==0){
delModel.push(v.substring(1))
}else{
addModel.push(v);
}
});
mlog('cmodels',delModel,addModel);
rz= rz.filter(v=> delModel.indexOf(v.value)==-1 );
addModel.map(o=>rz.push({label:o,value:o}) )
}
let uniqueArray: { label: string, value: string }[] = Array.from(
new Map(rz.map(item => [JSON.stringify(item), item]))
Expand Down

0 comments on commit 0af8479

Please sign in to comment.