allow thread prompt suggestions (#3442)

Co-authored-by: Jonathan Griffin <jonathangriffin@Jonathans-MacBook-Air.local>
This commit is contained in:
jonathan-caleb-griffin 2025-05-27 17:11:46 +02:00 committed by GitHub
parent 7217517a11
commit 517fe6c99e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 4 deletions

View file

@ -126,8 +126,10 @@ export default class KaiService extends AiService {
getPromptSuggestions = async (
projectId: string,
threadId?: string | null,
): Promise<string[]> => {
const r = await this.client.get(`/kai/${projectId}/prompt-suggestions`);
const endpoint = (threadId) ? `/kai/${projectId}/chats/${threadId}/prompt-suggestions` : `/kai/${projectId}/prompt-suggestions`;
const r = await this.client.get(endpoint);
if (!r.ok) {
throw new Error('Failed to fetch prompt suggestions');
}

View file

@ -1,6 +1,7 @@
import React from 'react';
import ChatInput from './ChatInput';
import ChatMsg, { ChatNotice } from './ChatMsg';
import Ideas from "./Ideas";
import { Loader } from 'UI';
import { kaiStore } from '../KaiStore';
import { observer } from 'mobx-react-lite';
@ -81,6 +82,7 @@ function ChatLog({
duration={processingStage.duration}
/>
) : null}
{(!processingStage && lastHumanMsgInd && messages.length == lastHumanMsgInd + 2) ? <Ideas onClick={(query) => onSubmit(query)} projectId={projectId} threadId={threadId}/> : null}
</div>
<div className={'sticky bottom-0 pt-6 w-2/3'}>
<ChatInput onSubmit={onSubmit} threadId={threadId} />

View file

@ -4,14 +4,14 @@ import { useQuery } from '@tanstack/react-query';
import { kaiService } from 'App/services';
import { useTranslation } from 'react-i18next';
function Ideas({ onClick, projectId }: { onClick: (query: string) => void, projectId: string }) {
function Ideas({ onClick, projectId, threadId = null }: { onClick: (query: string) => void, projectId: string, threadId?: string | null }) {
const { t } = useTranslation();
const {
data: suggestedPromptIdeas = [],
isPending,
} = useQuery({
queryKey: ['kai', 'prompt-suggestions', projectId],
queryFn: () => kaiService.getPromptSuggestions(projectId),
queryKey: ['kai', projectId, 'chats', threadId, 'prompt-suggestions'],
queryFn: () => kaiService.getPromptSuggestions(projectId, threadId),
staleTime: 1000 * 60,
});
const ideas = React.useMemo(() => {