Browse Source

Merge branch 'app-permission' of https://git.zyuas.com/LLM/chat-client-web into app-permission

* 'app-permission' of https://git.zyuas.com/LLM/chat-client-web:
  聊天请求带token
Ryuiso 3 months ago
parent
commit
77b15ea1a7
2 changed files with 7 additions and 1 deletions
  1. 4 1
      app/client/platforms/bigModel.ts
  2. 3 0
      app/client/platforms/deepSeek.ts

+ 4 - 1
app/client/platforms/bigModel.ts

@@ -63,6 +63,8 @@ export class BigModelApi implements LLMApi {
     options.onController?.(controller);
 
     try {
+      const userInfo = localStorage.getItem('userInfo');
+      const token = userInfo ? JSON.parse(userInfo).token : "";
       const chatPath = this.apiPath;
       const chatPayload = {
         method: "POST",
@@ -70,6 +72,7 @@ export class BigModelApi implements LLMApi {
         signal: controller.signal,
         headers: {
           'Content-Type': 'application/json',
+          'Authorization': token
         },
       };
 
@@ -258,4 +261,4 @@ export class BigModelApi implements LLMApi {
   async models(): Promise<LLMModel[]> {
     return [];
   }
-}
+}

+ 3 - 0
app/client/platforms/deepSeek.ts

@@ -78,6 +78,8 @@ export class DeepSeekApi implements LLMApi {
     options.onController?.(controller);
 
     try {
+      const userInfo = localStorage.getItem('userInfo');
+      const token = userInfo ? JSON.parse(userInfo).token : "";
       const chatPath = this.apiPath;
       const chatPayload = {
         method: "POST",
@@ -85,6 +87,7 @@ export class DeepSeekApi implements LLMApi {
         signal: controller.signal,
         headers: {
           'Content-Type': 'application/json',
+          'Authorization': token
         },
       };