Procházet zdrojové kódy

修改应用使用,通过配置的应用的appid modelname字段关联

winkey před 3 týdny
rodič
revize
b3ecf99725

+ 2 - 0
src/api/mjapi.ts

@@ -11,7 +11,9 @@ export interface gptsType{
     logo:string
     info:string
     use_cnt?:string
+    id:string
     bad?:string|number
+    modelName:string
 }
  //const { addChat, updateChat, updateChatSome, getChatByUuidAndIndex } = useChat()
 export function upImg(file:any   ):Promise<any>

+ 6 - 2
src/api/openapi.ts

@@ -192,6 +192,8 @@ interface subModelType{
     signal?:AbortSignal
     model?:string
     uuid?:string|number
+    chatType: number
+    appId: string
 }
 function getHeaderAuthorization(){
     // if(!gptServerStore.myData.OPENAI_API_KEY){
@@ -236,7 +238,6 @@ export const subModel= async (opt: subModelType)=>{
         frequency_penalty = gStore.frequency_penalty??frequency_penalty;
         max_tokens= gStore.max_tokens;
     }
-   
     let body ={
             max_tokens ,
             model ,
@@ -246,6 +247,8 @@ export const subModel= async (opt: subModelType)=>{
             "messages": opt.message
            ,stream:true
            ,kid:gptConfigStore.myData.kid
+           ,chat_type: opt.chatType
+           ,appId: opt.appId
         }
 
         let headers=   {'Content-Type': 'application/json;charset=UTF-8',
@@ -267,8 +270,9 @@ export const subModel= async (opt: subModelType)=>{
                  if(data=='[DONE]') opt.onMessage({text:'',isFinish:true})
                  else {
                     try{
+                        // TODO 思考处理,DeepSeek  API 字段reasoning_content ,本地部署标签<think> 
                         const obj= JSON.parse(data );
-                        opt.onMessage({text:obj.choices[0].delta?.content??'' ,isFinish:obj.choices[0].finish_reason!=null })
+                        opt.onMessage({text:obj.choices[0].delta?.content??obj.choices[0].delta?.reasoning_content??'' ,isFinish:obj.choices[0].finish_reason!=null })
                     }catch{
                         opt.onMessage({
                             text: data,

+ 1 - 1
src/views/chat/index.vue

@@ -460,7 +460,7 @@ const searchOptions = computed(() => {
 })
 
 const goUseGpts= async ( item: gptsType)=>{
-	const saveObj= {model:  `${ item.gid }`   ,gpts:item}
+	const saveObj= {model:  `${ item.modelName }`   ,gpts:item}
 	gptConfigStore.setMyData(saveObj);
 	if(chatStore.active){ //保存到对话框
 		const chatSet = new chatSetting( chatStore.active );

+ 11 - 5
src/views/mj/aiGpt.vue

@@ -12,7 +12,7 @@ import { t } from "@/locales";
 const emit = defineEmits(['finished']);
 const { addChat , updateChatSome } = useChat()
 const chatStore = useChatStore()
-const st=ref({uuid:'1002', index:-1 });
+const st=ref({uuid:'1002', index:-1, chatType:0, appId:'' });
 const controller = ref<AbortController>( );;// new AbortController();
 const dataSources = computed(() => chatStore.getChatByUuid(+st.value.uuid))
 const ms= useMessage();
@@ -52,8 +52,10 @@ watch(()=>homeStore.myData.act, async (n)=>{
 
         let  uuid2 =  dd.uuid?? uuid;
         st.value.uuid =  uuid2 ;
+        st.value.chatType = dd.chatType;
+        st.value.appId = dd.appId??'';
         const chatSet = new chatSetting(   +st.value.uuid  );
-        const nGptStore =   chatSet.getGptConfig()  ;
+        const nGptStore =   chatSet.getGptConfig();
          mlog('gpt.submit', dd , dd.uuid,  nGptStore ) ;
         let model = nGptStore.model ;//gptConfigStore.myData.model
 
@@ -145,8 +147,10 @@ watch(()=>homeStore.myData.act, async (n)=>{
         let historyMesg=  await getMessage();
         mlog('historyMesg', historyMesg );
         //return ;
-        let message= [ {  "role": "system", "content": getSystemMessage(  +uuid2) },
-                ...historyMesg ];
+        // let message= [ {  "role": "system", "content": getSystemMessage(  +uuid2) },
+        //         ...historyMesg ];
+        let message= [...historyMesg ];
+                
         if( dd.fileBase64 && dd.fileBase64.length>0 ){
             if(isCanBase64Model(model)){ 
                 let obj={
@@ -307,7 +311,9 @@ const submit= (model:string, message:any[],opt?:any)=>{
                     goFinish()
                 },
                 signal: controller.value.signal,
-                kid: ''
+                kid: '',
+                chatType: st.value.chatType,
+                appId: st.value.appId
             }).then(()=>goFinish() ).catch(e=>{
                 if(e.message!='canceled')  textRz.value.push("\n"+t('mj.fail')+":\n```\n"+(e.reason??JSON.stringify(e,null,2)) +"\n```\n")
                 goFinish();

+ 23 - 2
src/views/mj/aiGptInput.vue

@@ -39,7 +39,7 @@ const { iconRender } = useIconRender();
 //import FormData from 'form-data'
 const route = useRoute();
 const chatStore = useChatStore();
-const emit = defineEmits(["update:modelValue", "export", "handleClear"]);
+const emit = defineEmits(["update:modelValue", "update:chatType","export", "handleClear"]);
 const props = defineProps<{
 	modelValue: string;
 	disabled?: boolean;
@@ -53,12 +53,14 @@ const st = ref<{
 	isShow: boolean;
 	showMic: boolean;
 	micStart: boolean;
+	chatType: boolean;
 }>({
 	fileBase64: [],
 	isLoad: 0,
 	isShow: false,
 	showMic: false,
 	micStart: false,
+	chatType: false,
 });
 const { isMobile } = useBasicLayout();
 const placeholder = computed(() => {
@@ -94,6 +96,8 @@ const handleSubmit = () => {
 	let obj = {
 		prompt: mvalue.value,
 		fileBase64: st.value.fileBase64,
+		chatType: st.value.chatType? 1 : 0,
+		appId: gptConfigStore.myData.gpts? gptConfigStore.myData.gpts.id : ''
 	};
 	homeStore.setMyData({ act: "gpt.submit", actData: obj });
 	mvalue.value = "";
@@ -109,6 +113,11 @@ const mvalue = computed({
 		emit("update:modelValue", value);
 	},
 });
+const chatTypeBn = computed({
+	get() {
+		return st.value.chatType ? "info" : "";
+	},
+});
 function selectFile(input: any) {
 	const file = input.target.files[0];
 	upFile(file);
@@ -356,7 +365,7 @@ function handleClear() {
 						<template v-else>
 							<SvgIcon icon="heroicons:sparkles" />
 							<span>模型:{{
-									nGptStore.modelLabel ? truncateText(nGptStore.modelLabel,20) : "gpt-4o-mini"
+									nGptStore.modelLabel ? truncateText(nGptStore.modelLabel,20) : "deepseek-r1:1.5b"
 								}} {{nGptStore.kid?'知识库:'+truncateText(nGptStore.kName,10):''}}</span>
 						</template>
 						<SvgIcon icon="icon-park-outline:right" />
@@ -410,6 +419,18 @@ function handleClear() {
 						width="22px"
 						height="22px"
 					></IconSvg>
+					<n-tooltip trigger="hover">
+						<template #trigger>
+							<n-tag :bordered="false" :type="chatTypeBn" :round="true" style="margin-top:-3px;margin-left:-5px">
+								<IconSvg  style="margin:0px 5px"  @click="st.chatType = !st.chatType"
+									icon="search"
+									width="22px"
+									height="22px"
+								></IconSvg>
+							</n-tag>
+						</template>
+						联网搜索
+				</n-tooltip>
 				</div>
 				<IconSvg
 					@click="handleClear"