diff --git a/src/app/(main)/project/[project_id]/chat/[chat_id]/page.tsx b/src/app/(main)/project/[project_id]/chat/[chat_id]/page.tsx index 2225b972..35906081 100644 --- a/src/app/(main)/project/[project_id]/chat/[chat_id]/page.tsx +++ b/src/app/(main)/project/[project_id]/chat/[chat_id]/page.tsx @@ -30,6 +30,16 @@ export default function Chat(params: { refetchOnWindowFocus: false, } ); + + const projectQuery = useQuery( + ["chat", project_id], + () => API.projects.get(project_id), + { + refetchOnWindowFocus: false, + } + ); + const project: Project | undefined = projectQuery.data; + const chat: Chat | undefined = chatQuery.data; const [projectData, setProjectData] = useState(); @@ -85,13 +95,15 @@ export default function Chat(params: { params.formdata, openai_key, streamChatMessage, - 20 + 20, + !project?.assistant_id ), { retry: false, - // onSuccess: async (data, vars) => { - // await chatQuery.refetch(); - // } + onSuccess: async (data, vars) => { + if(!project?.assistant_id) + await chatQuery.refetch(); + }, onError: async (error, vars) => { converseMutation.error = error setIsTyping(false); diff --git a/src/app/(main)/project/[project_id]/page.tsx b/src/app/(main)/project/[project_id]/page.tsx index 084572e2..3348b482 100644 --- a/src/app/(main)/project/[project_id]/page.tsx +++ b/src/app/(main)/project/[project_id]/page.tsx @@ -79,12 +79,15 @@ export default function Chat(params: { params: { project_id: string } }) { params.formdata, openai_key, streamChatMessage, - 20 + 20, + !project?.assistant_id ), { retry: false, onSuccess: async (data, vars) => { + setChatID(data.external_id); await queryClient.invalidateQueries(["chats"]); + setIsTyping(false); }, } ); @@ -132,21 +135,23 @@ export default function Chat(params: { params: { project_id: string } }) { <>

Try asking me -

- {(project?.display_preset_questions ?? []).map((prompt, i) => ( - - ))} + {(project?.display_preset_questions ?? []).map( + (prompt, i) => ( + + ) + )}
)} diff --git a/src/app/admin/tests/[testsuite_id]/runs/[testrun_id]/page.tsx b/src/app/admin/tests/[testsuite_id]/runs/[testrun_id]/page.tsx index 11a55270..8a653359 100644 --- a/src/app/admin/tests/[testsuite_id]/runs/[testrun_id]/page.tsx +++ b/src/app/admin/tests/[testsuite_id]/runs/[testrun_id]/page.tsx @@ -368,8 +368,8 @@ export default function Page({ params }: { params: { testsuite_id: string, testr {document.title} -
- request(`projects/${project_id}/list_assistants`, "GET"), + create: (project_id: string, assistant: Partial) => request(`projects/${project_id}/create_assistant`, "POST", assistant), + }, list: ( filters: { ordering?: string; @@ -289,14 +294,15 @@ export const API = { formdata: FormData, openai_api_key?: string, onMessage: ((event: ChatConverseStream) => void) | null = null, - delay: number | null = null + delay: number | null = null, + stream: boolean = true ) => request( `projects/${project_id}/chats/${chat_id}/converse`, "POST", formdata, { - stream: true, + stream, formdata: true, headers: openai_api_key ? {