|
@@ -37,7 +37,7 @@ import { QuickMenuList } from '../components/AiAssistant/AiAssistantSidebar/Quic
|
|
|
import { useAiAssistantSidebar } from '../stores/ai-assistant';
|
|
import { useAiAssistantSidebar } from '../stores/ai-assistant';
|
|
|
|
|
|
|
|
interface CreateThread {
|
|
interface CreateThread {
|
|
|
- (aiAssistantId?: string): Promise<IThreadRelationHasId>;
|
|
|
|
|
|
|
+ (): Promise<IThreadRelationHasId>;
|
|
|
}
|
|
}
|
|
|
interface PostMessage {
|
|
interface PostMessage {
|
|
|
(threadId: string, userMessage: string): Promise<Response>;
|
|
(threadId: string, userMessage: string): Promise<Response>;
|
|
@@ -147,13 +147,13 @@ export const useEditorAssistant: UseEditorAssistant = () => {
|
|
|
const { data: aiAssistantSidebarData } = useAiAssistantSidebar();
|
|
const { data: aiAssistantSidebarData } = useAiAssistantSidebar();
|
|
|
|
|
|
|
|
// Functions
|
|
// Functions
|
|
|
- const createThread: CreateThread = useCallback(async(aiAssistantId) => {
|
|
|
|
|
|
|
+ const createThread: CreateThread = useCallback(async() => {
|
|
|
const response = await apiv3Post<IThreadRelationHasId>('/openai/thread', {
|
|
const response = await apiv3Post<IThreadRelationHasId>('/openai/thread', {
|
|
|
type: ThreadType.EDITOR,
|
|
type: ThreadType.EDITOR,
|
|
|
- aiAssistantId,
|
|
|
|
|
|
|
+ aiAssistantId: selectedAiAssistant?._id,
|
|
|
});
|
|
});
|
|
|
return response.data;
|
|
return response.data;
|
|
|
- }, []);
|
|
|
|
|
|
|
+ }, [selectedAiAssistant?._id]);
|
|
|
|
|
|
|
|
const postMessage: PostMessage = useCallback(async(threadId, userMessage) => {
|
|
const postMessage: PostMessage = useCallback(async(threadId, userMessage) => {
|
|
|
const response = await fetch('/_api/v3/openai/edit', {
|
|
const response = await fetch('/_api/v3/openai/edit', {
|
|
@@ -209,7 +209,6 @@ export const useEditorAssistant: UseEditorAssistant = () => {
|
|
|
lineRef.current = selectedTextFirstLineNumber;
|
|
lineRef.current = selectedTextFirstLineNumber;
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
const isActionButtonShown: IsActionButtonShown = useCallback((messageId: string, messageLogs: MessageLog[], generatingAnswerMessage: MessageLog) => {
|
|
const isActionButtonShown: IsActionButtonShown = useCallback((messageId: string, messageLogs: MessageLog[], generatingAnswerMessage: MessageLog) => {
|
|
|
if (!aiAssistantSidebarData?.isEditorAssistant) {
|
|
if (!aiAssistantSidebarData?.isEditorAssistant) {
|
|
|
return false;
|
|
return false;
|