allow thread prompt suggestions (#3442)
Co-authored-by: Jonathan Griffin <jonathangriffin@Jonathans-MacBook-Air.local>
This commit is contained in:
parent
7217517a11
commit
517fe6c99e
3 changed files with 8 additions and 4 deletions
|
|
@ -126,8 +126,10 @@ export default class KaiService extends AiService {
|
||||||
|
|
||||||
getPromptSuggestions = async (
|
getPromptSuggestions = async (
|
||||||
projectId: string,
|
projectId: string,
|
||||||
|
threadId?: string | null,
|
||||||
): Promise<string[]> => {
|
): 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) {
|
if (!r.ok) {
|
||||||
throw new Error('Failed to fetch prompt suggestions');
|
throw new Error('Failed to fetch prompt suggestions');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ChatInput from './ChatInput';
|
import ChatInput from './ChatInput';
|
||||||
import ChatMsg, { ChatNotice } from './ChatMsg';
|
import ChatMsg, { ChatNotice } from './ChatMsg';
|
||||||
|
import Ideas from "./Ideas";
|
||||||
import { Loader } from 'UI';
|
import { Loader } from 'UI';
|
||||||
import { kaiStore } from '../KaiStore';
|
import { kaiStore } from '../KaiStore';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
@ -81,6 +82,7 @@ function ChatLog({
|
||||||
duration={processingStage.duration}
|
duration={processingStage.duration}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
{(!processingStage && lastHumanMsgInd && messages.length == lastHumanMsgInd + 2) ? <Ideas onClick={(query) => onSubmit(query)} projectId={projectId} threadId={threadId}/> : null}
|
||||||
</div>
|
</div>
|
||||||
<div className={'sticky bottom-0 pt-6 w-2/3'}>
|
<div className={'sticky bottom-0 pt-6 w-2/3'}>
|
||||||
<ChatInput onSubmit={onSubmit} threadId={threadId} />
|
<ChatInput onSubmit={onSubmit} threadId={threadId} />
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,14 @@ import { useQuery } from '@tanstack/react-query';
|
||||||
import { kaiService } from 'App/services';
|
import { kaiService } from 'App/services';
|
||||||
import { useTranslation } from 'react-i18next';
|
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 { t } = useTranslation();
|
||||||
const {
|
const {
|
||||||
data: suggestedPromptIdeas = [],
|
data: suggestedPromptIdeas = [],
|
||||||
isPending,
|
isPending,
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ['kai', 'prompt-suggestions', projectId],
|
queryKey: ['kai', projectId, 'chats', threadId, 'prompt-suggestions'],
|
||||||
queryFn: () => kaiService.getPromptSuggestions(projectId),
|
queryFn: () => kaiService.getPromptSuggestions(projectId, threadId),
|
||||||
staleTime: 1000 * 60,
|
staleTime: 1000 * 60,
|
||||||
});
|
});
|
||||||
const ideas = React.useMemo(() => {
|
const ideas = React.useMemo(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue