Просмотр исходного кода

modal_aichat -> sidebar_aichat

Shun Miyazawa 1 год назад
Родитель
Сommit
a62bff86b7

+ 1 - 1
apps/app/public/static/locales/en_US/translation.json

@@ -488,7 +488,7 @@
     "latest_revision": "theirs",
     "selected_editable_revision": "Selected Page Body (Editable)"
   },
-  "modal_aichat": {
+  "sidebar_aichat": {
     "title": "Knowledge Assistant",
     "title_beta_label": "(Beta)",
     "placeholder": "Ask me anything.",

+ 1 - 1
apps/app/public/static/locales/fr_FR/translation.json

@@ -483,7 +483,7 @@
     "latest_revision": "les autres",
     "selected_editable_revision": "Corps de page sélectionné (Modifiable)"
   },
-  "modal_aichat": {
+  "sidebar_aichat": {
     "title": "Assistant de Connaissance",
     "title_beta_label": "(Bêta)",
     "placeholder": "Demandez-moi n'importe quoi.",

+ 1 - 1
apps/app/public/static/locales/ja_JP/translation.json

@@ -521,7 +521,7 @@
     "latest_revision": "最新の本文",
     "selected_editable_revision": "保存するページ本文(編集可能)"
   },
-  "modal_aichat": {
+  "sidebar_aichat": {
     "title": "ナレッジアシスタント",
     "title_beta_label": "(ベータ)",
     "placeholder": "ききたいことを入力してください",

+ 1 - 1
apps/app/public/static/locales/zh_CN/translation.json

@@ -477,7 +477,7 @@
     "latest_revision": "最新页面正文",
     "selected_editable_revision": "选定的可编辑页面正文"
   },
-  "modal_aichat": {
+  "sidebar_aichat": {
     "title": "知识助手",
     "title_beta_label": "(测试版)",
     "placeholder": "问我任何问题。",

+ 9 - 9
apps/app/src/features/openai/client/components/AiAssistant/AiAssistantChatSidebar/AiAssistantChatSidebar.tsx

@@ -104,7 +104,7 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
       }
       catch (err) {
         logger.error(err.toString());
-        toastError(t('modal_aichat.failed_to_create_or_retrieve_thread'));
+        toastError(t('sidebar_aichat.failed_to_create_or_retrieve_thread'));
       }
     }
 
@@ -125,7 +125,7 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
 
           const hasThreadIdNotSetError = resJson.errors.some(err => err.code === MessageErrorCode.THREAD_ID_IS_NOT_SET);
           if (hasThreadIdNotSetError) {
-            toastError(t('modal_aichat.failed_to_create_or_retrieve_thread'));
+            toastError(t('sidebar_aichat.failed_to_create_or_retrieve_thread'));
           }
         }
         setGeneratingAnswerMessage(undefined);
@@ -166,7 +166,7 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
             form.setError('input', { type: 'manual', message: error.message });
 
             if (error.code === StreamErrorCode.BUDGET_EXCEEDED) {
-              setErrorMessage(growiCloudUri != null ? 'modal_aichat.budget_exceeded_for_growi_cloud' : 'modal_aichat.budget_exceeded');
+              setErrorMessage(growiCloudUri != null ? 'sidebar_aichat.budget_exceeded_for_growi_cloud' : 'sidebar_aichat.budget_exceeded');
             }
           }
         });
@@ -228,7 +228,7 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
                 { messageLogs.length > 0 && (
                   <div className="d-flex justify-content-center">
                     <span className="bg-body-tertiary text-body-secondary rounded-pill px-3 py-1" style={{ fontSize: 'smaller' }}>
-                      {t('modal_aichat.caution_against_hallucination')}
+                      {t('sidebar_aichat.caution_against_hallucination')}
                     </span>
                   </div>
                 )}
@@ -285,7 +285,7 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
                       className="form-control textarea-ask"
                       style={{ resize: 'none' }}
                       rows={1}
-                      placeholder={!form.formState.isSubmitting ? t('modal_aichat.placeholder') : ''}
+                      placeholder={!form.formState.isSubmitting ? t('sidebar_aichat.placeholder') : ''}
                       onKeyDown={keyDownHandler}
                       disabled={form.formState.isSubmitting}
                     />
@@ -309,7 +309,7 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
                   disabled={form.formState.isSubmitting || isGenerating}
                 />
                 <label className="form-check-label" htmlFor="swSummaryMode">
-                  {t('modal_aichat.summary_mode_label')}
+                  {t('sidebar_aichat.summary_mode_label')}
                 </label>
 
                 {/* Help */}
@@ -323,7 +323,7 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
                 <UncontrolledTooltip
                   target="tooltipForHelpOfSummaryMode"
                 >
-                  {t('modal_aichat.summary_mode_help')}
+                  {t('sidebar_aichat.summary_mode_help')}
                 </UncontrolledTooltip>
               </div>
             </form>
@@ -332,7 +332,7 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
               <div className="mt-4 bg-danger bg-opacity-10 rounded-3 p-2 w-100">
                 <div>
                   <span className="material-symbols-outlined text-danger me-2">error</span>
-                  <span className="text-danger">{ errorMessage != null ? t(errorMessage) : t('modal_aichat.error_message') }</span>
+                  <span className="text-danger">{ errorMessage != null ? t(errorMessage) : t('sidebar_aichat.error_message') }</span>
                 </div>
 
                 <button
@@ -344,7 +344,7 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
                   <span className={`material-symbols-outlined mt-2 me-1 ${isErrorDetailCollapsed ? 'rotate-90' : ''}`}>
                     chevron_right
                   </span>
-                  <span className="small">{t('modal_aichat.show_error_detail')}</span>
+                  <span className="small">{t('sidebar_aichat.show_error_detail')}</span>
                 </button>
 
                 <Collapse isOpen={isErrorDetailCollapsed}>

+ 1 - 1
apps/app/src/features/openai/client/components/AiAssistant/AiAssistantChatSidebar/MessageCard.tsx

@@ -55,7 +55,7 @@ const AssistantMessageCard = ({ children }: { children: string }): JSX.Element =
             )
             : (
               <span className="text-thinking">
-                {t('modal_aichat.progress_label')} <span className="material-symbols-outlined">more_horiz</span>
+                {t('sidebar_aichat.progress_label')} <span className="material-symbols-outlined">more_horiz</span>
               </span>
             )
           }

+ 2 - 2
apps/app/src/features/openai/server/routes/thread.ts

@@ -40,8 +40,8 @@ export const createThreadHandlersFactory: CreateThreadFactory = (crowi) => {
       try {
         const filterdThreadId = req.body.threadId != null ? filterXSS(req.body.threadId) : undefined;
         // const vectorStore = await openaiService?.getOrCreateVectorStoreForPublicScope();
-        // const thread = await openaiService?.getOrCreateThread(req.user._id, vectorStore?.vectorStoreId, filterdThreadId);
-        return res.apiv3({ });
+        const thread = await openaiService?.getOrCreateThread(req.user._id, 'vs_67b42d73c96881918c3bd6c2db38fb55', filterdThreadId);
+        return res.apiv3({ thread });
       }
       catch (err) {
         logger.error(err);

+ 9 - 2
packages/editor/src/client/stores/codemirror-editor.ts

@@ -1,15 +1,22 @@
 import { useMemo, useRef } from 'react';
 
 import { useSWRStatic } from '@growi/core/dist/swr';
-import { deepEquals } from '@growi/core/dist/utils';
+// import { deepEquals } from '@growi/core/dist/utils';
 import type { ReactCodeMirrorProps, UseCodeMirror } from '@uiw/react-codemirror';
 import type { SWRResponse } from 'swr';
 import deepmerge from 'ts-deepmerge';
 
 import { type UseCodeMirrorEditor, useCodeMirrorEditor } from '../services';
 
-const { isDeepEquals } = deepEquals;
+// const { isDeepEquals } = deepEquals;
 
+// --- revert degradation by https://github.com/weseek/growi/commit/a62f4e5e98dfd089a1bbda1a0291d78978aaabc8 temporarily
+// const { isDeepEquals } = deepEquals;
+const isDeepEquals = <T extends object>(obj1: T, obj2: T): boolean => {
+  const typedKeys = Object.keys(obj1) as (keyof typeof obj1)[];
+  return typedKeys.every(key => obj1[key] === obj2[key]);
+};
+// --
 
 const isValid = (u: UseCodeMirrorEditor) => {
   return u.state != null && u.view != null;