Browse Source

对接提取文件

李富豪 3 months ago
parent
commit
ef8b7c2020

+ 24 - 2
app/client/platforms/deepSeek.ts

@@ -48,8 +48,7 @@ export class DeepSeekApi implements LLMApi {
 
     // 参数
     const params = {
-      // model: 'DeepSeek-R1-Distill-Qwen-14B',
-      model: 'Qwen3-30B',
+      model: 'qwen2.5:14b',
       enable_think: isDeepThink,
       messages: userMessages,
       stream: true,
@@ -152,6 +151,28 @@ export class DeepSeekApi implements LLMApi {
         onmessage: (msg) => {
           const info = JSON.parse(msg.data);
           if (info.event === 'finish') {
+            if (info.file_url) {
+              // 直接创建一个 Promise,而不是函数
+              networkInfoPromise = new Promise<void>((resolve) => {
+                setTimeout(() => {
+                  useChatStore.getState().updateCurrentSession((session) => {
+                    session.messages = session.messages.map((item, index) => {
+                      if (index === session.messages.length - 1 && item.role !== 'user') {
+                        return {
+                          ...item,
+                          downloadUrl: info.file_url,
+                        };
+                      } else {
+                        return {
+                          ...item,
+                        }
+                      }
+                    });
+                  });
+                  resolve();
+                }, 100);
+              });
+            }
             const isNetwork = useChatStore.getState().web_search;
             if (isNetwork) {// 联网搜索结果
               networkInfoPromise = (async () => {
@@ -214,6 +235,7 @@ export class DeepSeekApi implements LLMApi {
               role: item.role,
               content: item.content,
               documents: item.documents,
+              downloadUrl: item.downloadUrl || undefined,
             })),
           };
           await api.post('deepseek/api/dialog/save', data);

+ 5 - 0
app/components/DeekSeekHome.tsx

@@ -62,6 +62,11 @@ const DeekSeek: React.FC = () => {
         setFileList([]);
     }, []);
 
+    React.useEffect(() => {
+        globalStore.setDocuments([]);
+        setFileList([]);
+    }, [globalStore.isChatActive]);
+
     const [fileList, setFileList] = React.useState<any[]>([]);
 
     const props: UploadProps = {

+ 16 - 0
app/components/DeepSeekChat.tsx

@@ -1590,6 +1590,22 @@ function _Chat() {
                         正在输入…
                       </div>
                     )} */ }
+                    {
+                      message.downloadUrl &&
+                      <a style={{
+                        marginTop: 10,
+                        textDecoration: 'none',
+                        color: 'rgb(56, 117, 246)',
+                        display: 'flex',
+                        alignItems: 'center',
+                        fontSize: 12,
+                      }}
+                        href={message.downloadUrl}
+                        target="_blank"
+                      >
+                        下载文件提取结果
+                      </a>
+                    }
                     {
                       message.networkInfo && message.networkInfo.list.length > 0 &&
                       <div style={{ marginTop: 10 }}>

+ 1 - 0
app/components/sidebar.tsx

@@ -592,6 +592,7 @@ export const SideBar = (props: { className?: string }) => {
                   date: item.create_time,
                   content: item.content,
                   documents: item.documents ? item.documents : undefined,
+                  downloadUrl: item.downloadUrl || undefined,
                 }
               }))
               const session = {

+ 1 - 0
app/store/chat.ts

@@ -39,6 +39,7 @@ export type ChatMessage = RequestMessage & {
     name: string,
     url: string,
   }[],
+  downloadUrl?: string,
   sliceInfo?: {
     knowledge_id: string,
     doc: any[],

+ 1 - 0
next.config.mjs

@@ -31,6 +31,7 @@ const nextConfig = {
   experimental: {
     forceSwcTransforms: true,
   },
+  reactStrictMode: false,// 关闭模式
 };
 
 const CorsHeaders = [