Skip to content

Commit

Permalink
2.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Dooy committed Dec 20, 2023
1 parent e0a4a50 commit 4172cce
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
| API_UPLOADER | 支持上传 | 关闭 || x|
| HIDE_SERVER | 前端ui隐藏服务端| || x|
| CUSTOM_MODELS | 自定义可选模型 ||||
| TJ_BAIDU_ID | 百度统计ID ||||
| TJ_GOOGLE_ID | 谷歌统计ID ||||

## docker 部署
**假设**:
Expand Down
4 changes: 3 additions & 1 deletion api/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ 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??''
,cmodels : process.env.CUSTOM_MODELS??''
,baiduId : process.env.TJ_BAIDU_ID?? ""
,googleId: process.env.TJ_GOOGLE_ID?? ""
}
}
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,4 +1,11 @@
# 功能升级日志

## 2.13.1
- 🐞 修复: gpts 加载排序
- 😄 新建: google、百度统计
- 😄 新建: 文件支持拖拽上传 #39


## 2.12.11
- 🐞 紧急修复: gpt-4-vision-preview 格式错误

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.11",
"version": "2.13.1",
"private": false,
"description": "ChatGPT Web Midjourney Proxy",
"author": "Dooy <[email protected]>",
Expand Down
8 changes: 7 additions & 1 deletion service/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ API_UPLOADER=
HIDE_SERVER=

#自定义模型 CUSTOM_MODELS=-gpt-3.5-turbo-0301,gpt-4.5 不显示 gpt-3.5-turbo-0301 新增加 gpt-4.5
CUSTOM_MODELS=
CUSTOM_MODELS=

#TJ_BAIDU_ID 百度统计ID
TJ_BAIDU_ID=

#TJ_GOOGLE_ID 谷歌统计ID
TJ_GOOGLE_ID=
4 changes: 3 additions & 1 deletion service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ router.post('/session', async (req, res) => {
const amodel= process.env.OPENAI_API_MODEL?? "gpt-3.5-turbo" ;
const isApiGallery= isNotEmptyString( process.env.MJ_API_GALLERY );
const cmodels = process.env.CUSTOM_MODELS??'' ;
res.send({ status: 'Success', message: '', data: {isHideServer,isUpload, auth: hasAuth, model: currentModel(),amodel,isApiGallery,cmodels } })
const baiduId=process.env.TJ_BAIDU_ID?? "" ;
const googleId=process.env.TJ_GOOGLE_ID?? "" ;
res.send({ status: 'Success', message: '', data: {baiduId, googleId,isHideServer,isUpload, auth: hasAuth, model: currentModel(),amodel,isApiGallery,cmodels } })
}
catch (error) {
res.send({ status: 'Fail', message: error.message, data: null })
Expand Down
42 changes: 40 additions & 2 deletions src/views/mj/aiGallery.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<script lang="ts" setup>
import { ref,watch } from "vue";
import { ref,watch,computed } from "vue";
import gallery from './aiGalleryItem.vue'
import { homeStore } from "@/store";
import { useRoute } from 'vue-router';
import {NDrawerContent, NDrawer} from 'naive-ui'
import { useBasicLayout } from '@/hooks/useBasicLayout'
import { mlog } from "@/api";
//import { copyText3 } from "@/utils/format";
const { isMobile } = useBasicLayout()
const route = useRoute();
const st= ref({'show':false,showImg:false})
const initLoad=()=>{
//gallery
console.log('toGallery', route.query );
mlog('toGallery', route.query );
mlog('toGallery', homeStore.myData.session );
if( homeStore.myData.session.baiduId ) tjBaidu( homeStore.myData.session.baiduId );
if( homeStore.myData.session.googleId ) tjGoogle( homeStore.myData.session.googleId );
// if( _GET('to') =='gallery'){
// homeStore.setMyData({act:'gallery'})
// }
Expand All @@ -21,6 +25,30 @@ watch(() => homeStore.myData.act, (act) =>{
//act=='copy' && copyText3('addd890').then(dd=>console.log('ddd',dd ) );
})
const tjBaidu= (baiduID:string )=>{
window._hmt=window._hmt || [];
let hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?"+baiduID;
let s = document.getElementsByTagName("script")[0] as HTMLScriptElement;
s.parentNode && s.parentNode.insertBefore(hm, s);
mlog('tjBaidu', hm.src );
}
const tjGoogle= ( googleId:string )=>{
window.dataLayer = window.dataLayer || [];
let hm = document.createElement("script");
hm.src = "https://www.googletagmanager.com/gtag/js?id="+googleId;
let s = document.getElementsByTagName("script")[0] as HTMLScriptElement;
s.parentNode && s.parentNode.insertBefore(hm, s);
function gtag(...arg:any ){ window.dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', googleId );
}
//const baiduID= computed(()=>homeStore.myData.session.baiduID );
watch( ()=>homeStore.myData.session, (session:any )=>{
mlog('session', session )
},{deep:true});
initLoad();
</script>

Expand All @@ -30,4 +58,14 @@ initLoad();
<gallery @close="st.showImg=false" v-if="st.showImg"/>
</n-drawer-content>
</n-drawer>

<!-- <template v-if="baiduID">
<script>
window._hmt=window._hmt || [];
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?"+baiduID;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
</script>
</template> -->
</template>
60 changes: 49 additions & 11 deletions src/views/mj/aiGptInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const mvalue = computed({
set(value) { emit('update:modelValue', value) }
})
function selectFile(input:any){
const file = input.target.files[0];
upFile( file );
/*
if( !canVisionModel(gptConfigStore.myData.model ) ) {
upImg(input.target.files[0]).then(d=>{
fsRef.value.value='';
Expand All @@ -67,18 +71,41 @@ function selectFile(input:any){
}else if(r.error) ms.error(r.error);
}).catch(e=>ms.error('上传失败:'+ ( e.message?? JSON.stringify(e)) ));
}
// let url= gptGetUrl('/test/2023/upload');
// axios.post( url , formData, {
// headers: {
// 'Content-Type': 'multipart/form-data'
// }
// }).then(response => {
// console.log('上传成功', response.data);
// }).catch(error => {
// console.error('上传失败', error);
// });
*/
}
const upFile= (file:any )=>{
if( !canVisionModel(gptConfigStore.myData.model ) ) {
upImg( file).then(d=>{
fsRef.value.value='';
if(st.value.fileBase64.findIndex(v=>v==d)>-1) {
ms.error('不能重复上传')
return ;
}
st.value.fileBase64.push(d)
} ).catch(e=>ms.error(e));
}else{
const formData = new FormData( );
//const file = input.target.files[0];
formData.append('file', file);
ms.info('上传中...');
GptUploader('/v1/upload',formData).then(r=>{
//mlog('上传成功', r);
if(r.url ){
ms.info('上传成功');
if(r.url.indexOf('http')>-1) {
st.value.fileBase64.push(r.url)
}else{
st.value.fileBase64.push(location.origin +r.url)
}
}else if(r.error) ms.error(r.error);
}).catch(e=>ms.error('上传失败:'+ ( e.message?? JSON.stringify(e)) ));
}
}
function handleEnter(event: KeyboardEvent) {
Expand All @@ -100,9 +127,18 @@ const acceptData = computed(() => {
if( canVisionModel(gptConfigStore.myData.model) ) return "*/*";
return "image/jpeg, image/jpg, image/png, image/gif"
})
const drop = (e: DragEvent) => {
e.preventDefault();
e.stopPropagation();
if( !e.dataTransfer || e.dataTransfer.files.length==0 ) return;
const files = e.dataTransfer.files;
upFile(files[0]);
//mlog('drop', files);
}
</script>
<template>
<div class=" myinputs" >
<div class=" myinputs" @drop="drop" >

<input type="file" id="fileInput" @change="selectFile" class="hidden" ref="fsRef" :accept="acceptData"/>

Expand Down Expand Up @@ -134,9 +170,11 @@ const acceptData = computed(() => {
</template>
<div v-if="canVisionModel(gptConfigStore.myData.model)">
<span>上传图片、附件<br/>能上传图片、PDF、EXCEL等文档</span>
<p>支持拖拽</p>
</div>
<div v-else>
<span>上传图片<br/>会自动调用 gpt-4-vision-preview 模型<br>注意:会有额外的图片费用</span>
<p>支持拖拽</p>
</div>
</n-tooltip>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/views/mj/aiGptsCom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const pageLoad= async ()=>{
st.value.loadPage= false;
let rz = d.data.list as gptsType[];
gptsPageList.value = rz.concat( gptsPageList.value )
gptsPageList.value = gptsPageList.value.concat(rz) //rz.concat( gptsPageList.value )
}
const gptsList = computed(()=>{
let rz:gptsType[]=[];
Expand Down

0 comments on commit 4172cce

Please sign in to comment.