瀏覽代碼

联网搜索

S0025136190 6 月之前
父節點
當前提交
cb4d05e0db
共有 4 個文件被更改,包括 33 次插入10 次删除
  1. 1 0
      app/client/api.ts
  2. 1 0
      app/client/platforms/deepSeek.ts
  3. 26 10
      app/components/DeepSeekChat.tsx
  4. 5 0
      app/store/chat.ts

+ 1 - 0
app/client/api.ts

@@ -51,6 +51,7 @@ export interface LLMConfig {
   presence_penalty?: number;
   frequency_penalty?: number;
   size?: DalleRequestPayload["size"];
+  web_search?: boolean;
 }
 
 export interface ChatOptions {

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

@@ -69,6 +69,7 @@ export class DeepSeekApi implements LLMApi {
       // 进阶配置
       max_tokens: undefined,
       temperature: undefined,
+      web_search: options.config.web_search,
     };
 
     const controller = new AbortController();

+ 26 - 10
app/components/DeepSeekChat.tsx

@@ -1366,6 +1366,13 @@ function _Chat() {
   const couldStop = ChatControllerPool.hasPending();
   const stopAll = () => ChatControllerPool.stopAll();
 
+  // 切换聊天窗口后清理上传文件信息
+  useEffect(() => {
+    setWebSearch(false);
+  }, [chatStore.currentSession()])
+
+  const [webSearch, setWebSearch] = useState<boolean>(chatStore.web_search);
+
   return (
     <div className={styles.chat} key={session.id}>
       {
@@ -1660,16 +1667,25 @@ function _Chat() {
               </div>
             </Tooltip>
             {/*联网搜索按钮*/}
-            <div
-              style={{
-                padding: '0 12px',
-                height: 28,
-                borderRadius: 18,
-                fontSize: 12,
-                background: '#f3f4f6',
-                display: 'flex',
-                justifyContent: 'center',
-                alignItems: 'center'
+            <div style={{
+              padding: '0 12px',
+              height: 28,
+              borderRadius: 18,
+              fontSize: 12,
+              display: 'flex',
+              justifyContent: 'center',
+              alignItems: 'center',
+              marginRight: 10,
+              cursor: 'pointer',
+              background: webSearch ? '#dee9fc' : '#f3f4f6',
+              color: webSearch ? '#3875f6' : '#000000',
+              border: `1px solid ${webSearch ? '#3875f6' : 'transparent'}`,
+              transition: 'all 0.2s ease',
+              userSelect: 'none'
+            }}
+              onClick={() => {
+                setWebSearch(!webSearch);
+                chatStore.setWebSearch(!webSearch);
               }}
             >
               <img

+ 5 - 0
app/store/chat.ts

@@ -177,6 +177,7 @@ function fillTemplateWith(input: string, modelConfig: ModelConfig) {
 
 const DEFAULT_CHAT_STATE = {
   model: 'BigModel' as 'BigModel' | 'DeepSeek',
+  web_search: false,
   chatMode: 'ONLINE' as 'ONLINE' | 'LOCAL',
   isDeepThink: true,
   sessions: [createEmptySession()],
@@ -200,6 +201,9 @@ export const useChatStore = createPersistStore(
       setModel(model: 'BigModel' | 'DeepSeek') {
         set({ model: model });
       },
+      setWebSearch(status: boolean) {
+        set({ web_search: status });
+      },
       setChatMode(mode: 'ONLINE' | 'LOCAL') {
         set({ chatMode: mode });
       },
@@ -417,6 +421,7 @@ export const useChatStore = createPersistStore(
             ...modelConfig,
             appId: session.appId,
             stream: true,
+            web_search: get().web_search,
           },
           onUpdate(message) {
             botMessage.streaming = true;