Skip to content

Commit

Permalink
2.12.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Dooy committed Dec 8, 2023
1 parent 42c6211 commit e165fce
Show file tree
Hide file tree
Showing 18 changed files with 167 additions and 22 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
- ✅ chatgpt 支持图片上传图片 供gpt-4-vision-preview使用
- ✅ chatgpt 支持文件后端上传(供给gpt-4-all gpt-4-gizmo-xxx 模型)! 默认是关闭的 打开需要环境变量 API_UPLOADER=1
- ✅ chatgpt 支持逆向模型 gpt-4-all gpt-4-v gpt-4-gizmo-(gizmo_id)
- ✅ chatgpt 支持超链模型切换 http://ip:6013/#/m/gpt-4-all http://ip:6013/#/m/gpt-4-gizmo-1234
- ✅ chatgpt 支持 GPTs 多模态

## 待开发
- ⏰ 支持 GPTs 多模态

Expand Down
3 changes: 3 additions & 0 deletions changlog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 功能升级日志
## 2.12.3
- 😄 新增 支持超链模型切换 http://ip:6013/#/m/gpt-4-all http://ip:6013/#/m/gpt-4-gizmo-1234
- 😄 新增 支持 GPTs 多模态
## 2.12.2
- 😄 新增:支持文件后端上传(供给gpt-4-all gpt-4-gizmo-xxx 模型)! 默认是关闭的 打开需要环境变量 API_UPLOADER=1
- 😄 新增:支持逆向模型 gpt-4-all gpt-4-v gpt-4-gizmo-(gizmo_id)
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.2",
"version": "2.12.3",
"private": false,
"description": "ChatGPT Web Midjourney Proxy",
"author": "Dooy <[email protected]>",
Expand Down
7 changes: 6 additions & 1 deletion src/api/mjapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import { gptConfigStore, gptServerStore, homeStore } from "@/store";
import { copyToClip } from "@/utils/copy";
//import { useMessage } from "naive-ui";

export interface gptsType{
gid:string
name:string
logo:string
info:string
}
//const { addChat, updateChat, updateChatSome, getChatByUuidAndIndex } = useChat()
export function upImg(file:any ):Promise<any>
{
Expand Down
26 changes: 26 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ const routes: RouteRecordRaw[] = [
},
],
},
{
path: '/g',
name: 'g',
component: ChatLayout,
redirect: '/g/g-2fkFE8rbu',
children: [
{
path: '/g/:gid',
name: 'GPTs',
component: () => import('@/views/chat/index.vue'),
},
],
},
{
path: '/m',
name: 'm',
component: ChatLayout,
redirect: '/m/gpt-3.5-turbo',
children: [
{
path: '/m/:gid',
name: 'Model',
component: () => import('@/views/chat/index.vue'),
},
],
},

{
path: '/draw',
Expand Down
8 changes: 7 additions & 1 deletion src/store/homeStore.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { gptsType, mlog } from '@/api';
import { reactive } from 'vue'
export const homeStore = reactive({
myData:{
act:'',//动作
actData:{} //动作类别
,local:'' //当前所处的版本
,session:{} as any

}

,setMyData( v:object){
Expand All @@ -25,7 +27,7 @@ export interface gptConfigType{
userModel?:string //自定义
talkCount:number //联系对话
systemMessage:string //自定义系统提示语

gpts?:gptsType
}
const getGptInt= ():gptConfigType =>{
let v:gptConfigType=getDefault();
Expand All @@ -50,7 +52,11 @@ let v:gptConfigType={
export const gptConfigStore= reactive({
myData:getGptInt(),
setMyData(v: Partial<gptConfigType>){

this.myData={...this.myData,...v};
//mlog('gptConfigStore', v )
if(v.model && !v.gpts) this.myData.gpts=undefined;

localStorage.setItem('gptConfigStore', JSON.stringify( this.myData));
}
,setInit(){
Expand Down
1 change: 1 addition & 0 deletions src/typings/chat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ declare namespace Chat {
uuid?:number
index?:number
myid?:string //唯一随机
logo?:string

//progress?:string
}
Expand Down
14 changes: 10 additions & 4 deletions src/views/chat/components/Header/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,16 @@ const st = ref({isShow:false});
</div>
</div>

<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'">
<SvgIcon icon="heroicons:sparkles" />
<span>{{ gptConfigStore.myData.model }}</span>
<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">
<SvgIcon icon="ri:apps-fill" />
<span>{{ gptConfigStore.myData.gpts.name }}</span>
</template>
<template v-else >
<SvgIcon icon="heroicons:sparkles" />
<span >{{ gptConfigStore.myData.model }}</span>
</template>
<SvgIcon icon="icon-park-outline:right" />
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/views/chat/components/Message/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import defaultAvatar from '@/assets/avatar.jpg'
interface Props {
image?: boolean
logo?:string
}
defineProps<Props>()
Expand All @@ -16,7 +17,9 @@ const avatar = computed(() => userStore.userInfo.avatar)
</script>

<template>
<template v-if="image">

<NAvatar v-if="logo" :src="logo" />
<template v-else-if="image">
<NAvatar v-if="isString(avatar) && avatar.length > 0" :src="avatar" :fallback-src="defaultAvatar" />
<NAvatar v-else round :src="defaultAvatar" />
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/views/chat/components/Message/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const sendReload = () => {
class="flex items-center justify-center flex-shrink-0 h-8 overflow-hidden rounded-full basis-8"
:class="[inversion ? 'ml-2' : 'mr-2']"
>
<AvatarComponent :image="inversion" />
<AvatarComponent :image="inversion" :logo="chat.logo"/>
</div>
<div class="overflow-hidden text-sm " :class="[inversion ? 'items-end' : 'items-start']">
<p class="text-xs text-[#b4bbc4] flex justify-start items-center space-x-2 " :class="[inversion ? 'text-right' : 'text-left']">
Expand Down
23 changes: 19 additions & 4 deletions src/views/chat/layout/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
<script setup lang='ts'>
import { computed } from 'vue'
import { NLayout, NLayoutContent } from 'naive-ui'
import { useRouter } from 'vue-router'
import { NLayout, NLayoutContent,useMessage } from 'naive-ui'
import { useRouter ,useRoute } from 'vue-router'
import Sider from './sider/index.vue'
import Permission from './Permission.vue'
import { useBasicLayout } from '@/hooks/useBasicLayout'
import { homeStore, useAppStore, useAuthStore, useChatStore } from '@/store'
import { aiSider } from '@/views/mj'
import { gptConfigStore, homeStore, useAppStore, useAuthStore, useChatStore } from '@/store'
import { aiSider,aiGpts } from '@/views/mj'
const router = useRouter()
const appStore = useAppStore()
const chatStore = useChatStore()
const authStore = useAuthStore()
const rt = useRoute();
if(rt.name =='GPTs'){
const ms = useMessage();
let model= `gpt-4-gizmo-${rt.params.gid.toString()}` ;
gptConfigStore.setMyData({model:model});
ms.success(`GPTs 模型加载成功`);
}else if(rt.name=='Model'){
const ms = useMessage();
let model= `${rt.params.gid.toString()}` ;
gptConfigStore.setMyData({model:model});
ms.success(`模型加载成功`);
}
router.replace({ name: 'Chat', params: { uuid: chatStore.active } })
homeStore.setMyData({local:'Chat'});
const { isMobile } = useBasicLayout()
const collapsed = computed(() => appStore.siderCollapsed)
const needPermission = computed(() => !!authStore.session?.auth && !authStore.token)
Expand Down Expand Up @@ -50,4 +64,5 @@ const getContainerClass = computed(() => {
</div>
<Permission :visible="needPermission" />
</div>
<aiGpts/>
</template>
5 changes: 4 additions & 1 deletion 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 { useChat } from '../chat/hooks/useChat'
import { gptConfigStore, homeStore, useChatStore } from '@/store'
import { getInitChat, mlog, subModel,getSystemMessage , localSaveAny, canVisionModel } from '@/api'
import { isString } from '@/utils/is';
const emit = defineEmits(['finished']);
const { addChat , updateChatSome } = useChat()
Expand Down Expand Up @@ -90,6 +90,9 @@ watch(()=>homeStore.myData.act, async (n)=>{
model ,
myid: `${Date.now()}`
}
if(gptConfigStore.myData.gpts){
outMsg.logo= gptConfigStore.myData.gpts.logo ;
}
addChat( +uuid, outMsg )
if(textRz.value.length>=0) textRz.value = [ ];
Expand Down
20 changes: 20 additions & 0 deletions src/views/mj/aiGpts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script setup lang="ts">
import { NDrawer,NDrawerContent } from "naive-ui";
import { ref, watch } from "vue";
import { useBasicLayout } from '@/hooks/useBasicLayout'
import { homeStore } from "@/store";
import AiGptsCom from "./aiGptsCom.vue";
const { isMobile } = useBasicLayout()
const st =ref({showImg:false});
watch(()=>homeStore.myData.act, (n)=>{
if(n=='showgpts') st.value.showImg=true;
})
</script>
<template>
<n-drawer v-model:show="st.showImg" :placement="isMobile?'bottom':'right'" :class="isMobile?['!h-[90vh]']: ['!w-[80vw]']" style="--n-body-padding:0">
<n-drawer-content title="GPT store" closable>
<AiGptsCom @close="st.showImg=false" />
</n-drawer-content>
</n-drawer>
</template>
37 changes: 37 additions & 0 deletions src/views/mj/aiGptsCom.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script setup lang="ts">
import { myFetch, gptsType } from '@/api';
import { homeStore,gptConfigStore } from '@/store';
import { ref } from 'vue';
import { useMessage } from 'naive-ui';
const ms = useMessage();
const emit = defineEmits(['close']);
const gptsList= ref<gptsType[]>([]);
const load= async ()=>{
const gptUrl= homeStore.myData.session.gptUrl??'https://gpts.ddaiai.com/open/gpts';
let d = await myFetch(gptUrl);
gptsList.value = d.gpts as gptsType[];
}
const go= ( item: gptsType)=>{
gptConfigStore.setMyData({model: `${ item.gid }` ,gpts:item});
ms.success('切换成功!');
emit('close')
}
load();
</script>
<template>
<div class="w-full h-full p-4">
<div class="grid grid-cols-1 gap-5 md:grid-cols-2 lg:grid-cols-3" v-if="gptsList.length>0">
<div @click="go(v)" v-for="v in gptsList" class="group relative flex gap-3 rounded-2xl bg-[#e8eaf1] p-5 dark:bg-neutral-600 cursor-pointer ">

<div class="min-w-0 flex-1">
<h3 class=" transition text-lg font-semibold"> {{ v.name }}</h3>
<div class="mt-0.5 text-zinc-400 text-md line-clamp-2">{{ v.info }}</div>
</div>
<img class="group-hover:scale-[130%] duration-300 shrink-0 overflow-hidden bg-base object-cover rounded-full bc-avatar w-[80px] h-[80px]" :src="v.logo"/>
</div>
</div>
<div class="h-full flex items-center justify-center" v-else>正在载入...</div>
</div>
</template>
3 changes: 2 additions & 1 deletion src/views/mj/aiModel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ const modellist = computed(() => { //
return uniqueArray ;
});
const ms= useMessage();
const save = ()=>{
const save = ()=>{
gptConfigStore.setMyData( gptConfigStore.myData );
ms.success('保存成功');
emit('close');
}
watch(()=>gptConfigStore.myData.model,(n)=>{
gptConfigStore.myData.gpts=undefined;
let max=4096;
if( n.indexOf('vision')>-1){
max=4096;
Expand Down
24 changes: 19 additions & 5 deletions src/views/mj/aiSider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SvgIcon ,HoverButton} from '@/components/common'
import { useBasicLayout } from '@/hooks/useBasicLayout'
const { isMobile } = useBasicLayout()
import { NAvatar,NTooltip } from 'naive-ui'
import { useUserStore } from '@/store'
import { homeStore, useUserStore } from '@/store'
//import gallery from '@/views/gallery/index.vue'
Expand Down Expand Up @@ -51,6 +51,20 @@ const goHome =computed( () => {
AI绘画 Midjourney引擎
</n-tooltip>
</a>


<a @click="homeStore.setMyData({act:'showgpts'}) " class=" router-link-exact-active h-12 w-12 cursor-pointer rounded-xl bg-white duration-300 dark:bg-[#34373c] hover:bg-[#bbb] dark:hover:bg-[#555]">
<n-tooltip placement="right" trigger="hover">
<template #trigger>
<div class="flex h-full justify-center items-center py-1 flex-col" >
<SvgIcon icon="ri:apps-fill" class="text-3xl flex-1"></SvgIcon>
<span class="text-[10px]">GTPs</span>
</div>
</template>
ChatGPT Store
</n-tooltip>
</a>

<!-- <section class=" router-link-exact-active h-12 w-12 cursor-pointer rounded-xl bg-white duration-300 dark:bg-[#34373c] hover:bg-[#bbb] dark:hover:bg-[#555]"
>
<n-tooltip placement="right" trigger="hover">
Expand Down Expand Up @@ -83,11 +97,11 @@ const goHome =computed( () => {
</div>
<Setting v-if="st.show" v-model:visible="st.show" />

<!-- <n-drawer v-model:show="st.showImg" class="!w-[80vw]" style="--n-body-padding:0">
<n-drawer-content title="画廊">
<gallery @close="st.showImg=false"/>
<!-- <n-drawer v-model:show="st.showImg" :placement="isMobile?'bottom':'right'" :class="isMobile?['!h-[90vh]']: ['!w-[80vw]']" style="--n-body-padding:0">
<n-drawer-content title="GPT store" closable>
sdsd
</n-drawer-content>
</n-drawer> -->
</n-drawer> -->
</template>


3 changes: 2 additions & 1 deletion src/views/mj/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import aiSider from "./aiSider.vue"
import aiGpts from "./aiGpts.vue"

export {aiSider }
export {aiSider,aiGpts }
3 changes: 2 additions & 1 deletion src/views/mj/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Sider from '../chat/layout/sider/index.vue'
import Permission from '../chat/layout/Permission.vue'
import { useBasicLayout } from '@/hooks/useBasicLayout'
import { homeStore, useAppStore, useAuthStore, useChatStore } from '@/store'
import { aiSider } from '@/views/mj'
import { aiSider ,aiGpts} from '@/views/mj'
const router = useRouter()
const appStore = useAppStore()
Expand Down Expand Up @@ -51,4 +51,5 @@ const getContainerClass = computed(() => {
</div>
<Permission :visible="needPermission" />
</div>
<aiGpts/>
</template>

0 comments on commit e165fce

Please sign in to comment.