|
@@ -53,7 +53,6 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
|
|
|
aiAssistantData, threadData, closeAiAssistantChatSidebar,
|
|
aiAssistantData, threadData, closeAiAssistantChatSidebar,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
- const [isThreadVerified, setIsThreadVerified] = useState<boolean>(false);
|
|
|
|
|
const [currentThreadTitle, setCurrentThreadTitle] = useState<string | undefined>(threadData?.title);
|
|
const [currentThreadTitle, setCurrentThreadTitle] = useState<string | undefined>(threadData?.title);
|
|
|
const [currentThreadId, setCurrentThreadId] = useState<string | undefined>(threadData?.threadId);
|
|
const [currentThreadId, setCurrentThreadId] = useState<string | undefined>(threadData?.threadId);
|
|
|
const [messageLogs, setMessageLogs] = useState<Message[]>([]);
|
|
const [messageLogs, setMessageLogs] = useState<Message[]>([]);
|
|
@@ -124,17 +123,15 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
|
|
|
|
|
|
|
|
// create thread
|
|
// create thread
|
|
|
let currentThreadId_ = currentThreadId;
|
|
let currentThreadId_ = currentThreadId;
|
|
|
- if (!isThreadVerified || currentThreadId_ == null) {
|
|
|
|
|
|
|
+ if (currentThreadId_ == null) {
|
|
|
try {
|
|
try {
|
|
|
const res = await apiv3Post<IThreadRelationHasId>('/openai/thread', {
|
|
const res = await apiv3Post<IThreadRelationHasId>('/openai/thread', {
|
|
|
- threadId: currentThreadId_,
|
|
|
|
|
aiAssistantId: aiAssistantData._id,
|
|
aiAssistantId: aiAssistantData._id,
|
|
|
initialUserMessage: newUserMessage.content,
|
|
initialUserMessage: newUserMessage.content,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const thread = res.data;
|
|
const thread = res.data;
|
|
|
|
|
|
|
|
- setIsThreadVerified(true);
|
|
|
|
|
setCurrentThreadId(thread.threadId);
|
|
setCurrentThreadId(thread.threadId);
|
|
|
setCurrentThreadTitle(thread.title);
|
|
setCurrentThreadTitle(thread.title);
|
|
|
|
|
|
|
@@ -233,7 +230,7 @@ const AiAssistantChatSidebarSubstance: React.FC<AiAssistantChatSidebarSubstanceP
|
|
|
form.setError('input', { type: 'manual', message: err.toString() });
|
|
form.setError('input', { type: 'manual', message: err.toString() });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- }, [isGenerating, messageLogs, form, currentThreadId, isThreadVerified, aiAssistantData._id, mutateThreadData, t, growiCloudUri]);
|
|
|
|
|
|
|
+ }, [isGenerating, messageLogs, form, currentThreadId, aiAssistantData._id, mutateThreadData, t, growiCloudUri]);
|
|
|
|
|
|
|
|
const keyDownHandler = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
const keyDownHandler = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
|
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
|
|
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
|