diff --git a/package.json b/package.json index 59b8e18f..cfea9908 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", "cmdk": "^0.2.0", - "drizzle-orm": "0.26.5", + "drizzle-orm": "0.30.9", "drizzle-zod": "0.4.2", "encoding": "^0.1.13", "eslint": "8.37.0", diff --git a/src/app/api/chats/[chatid]/route.tsx b/src/app/api/chats/[chatid]/route.tsx index f05f96c7..4057b9e1 100644 --- a/src/app/api/chats/[chatid]/route.tsx +++ b/src/app/api/chats/[chatid]/route.tsx @@ -18,6 +18,6 @@ export async function GET( const msg = fetchedChat[0].messages; const chatlog = JSON.parse(msg as string) as ChatLog; - console.log("fetchedChat route", chatlog); + // console.log("fetchedChat route", chatlog); return NextResponse.json({ chats: chatlog ? chatlog : [] }); } diff --git a/src/app/api/patentsearch/route.ts b/src/app/api/patentsearch/route.ts index 95fa8c30..390b1c95 100644 --- a/src/app/api/patentsearch/route.ts +++ b/src/app/api/patentsearch/route.ts @@ -55,8 +55,6 @@ export async function POST(request: Request) { chatlog.log.length, ); - console.log("prevChatData", nextChatData); - const res = await axios.get(`${baseUrl}/search/102`, { params: { q: query, @@ -70,6 +68,9 @@ export async function POST(request: Request) { console.log("data", data); + if (data?.length === 0) { + return NextResponse.json({ data: null }, { status: 404 }); + } const patentMessage = { role: "assistant", subRole: "patent-search", @@ -89,7 +90,5 @@ export async function POST(request: Request) { .where(eq(chats.id, Number(chatId))) .run(); - // console.log(data) - return NextResponse.json({ data: updatedChatLog }); } diff --git a/src/components/chat.tsx b/src/components/chat.tsx index a940d291..2171708a 100644 --- a/src/components/chat.tsx +++ b/src/components/chat.tsx @@ -322,7 +322,7 @@ export default function Chat(props: ChatProps) { )}
- {scrollToBottom()} + {/* {scrollToBottom()} */}
); } diff --git a/src/components/chatmessagecombinator.tsx b/src/components/chatmessagecombinator.tsx index f5e3cbec..d160c7d2 100644 --- a/src/components/chatmessagecombinator.tsx +++ b/src/components/chatmessagecombinator.tsx @@ -60,24 +60,29 @@ const ChatMessageCombinator = ({ const queryClient = useQueryClient(); const sheetContentRef = useRef(null); // Specify the type as HTMLDivElement - const mutation = useMutation( - async (data: { id: string; msgs: Message[]; lastMessageIndex: number }) => { + const mutation = useMutation< + Message[] | null, + unknown, + { msgs: Message[]; id: string; lastMessageIndex: number } + >({ + mutationFn: async (data) => { const res = await axios.post(`/api/patentsearch`, { msgs: data.msgs, orgId: orgId, chatId: chatId, lastMessageIndex: data.lastMessageIndex, }); - const result = res.data; - console.log("patentresult", result); + console.log("patentresult", res.data); + return res.data; }, - { - onSuccess: () => { - // Invalidate and refetch - queryClient.invalidateQueries(["chats", chatId]); - }, + onSuccess: (data, variables) => { + if (!data) { + console.log("no patients found"); + } + queryClient.invalidateQueries({ queryKey: ["chats", chatId] }); }, - ); + onError: (_error: any) => {}, + }); const titleSplit = chatTitle?.replaceAll('"', "").split(":"); const chat_title = titleSplit?.[0]; @@ -236,6 +241,14 @@ const ChatMessageCombinator = ({ preferences.showSubRoll ? ( patentMessage ? ( + ) : mutation.isLoading && + mutation.variables?.id === msg.id ? ( +
+
+ +
+ +
) : ( ) ) : null diff --git a/src/components/patentdata.tsx b/src/components/patentdata.tsx index 3bbcca89..f31fec56 100644 --- a/src/components/patentdata.tsx +++ b/src/components/patentdata.tsx @@ -42,7 +42,6 @@ const PatentData = ({ "item", parseAsInteger, ); - console.log(parsedInput); const [open, setOpen] = React.useState( isOpen && dialogIndex === dialogNumber ? isOpen : false, ); diff --git a/src/components/search.tsx b/src/components/search.tsx index 27f81399..234fa869 100644 --- a/src/components/search.tsx +++ b/src/components/search.tsx @@ -62,16 +62,14 @@ const Search = (props: Props) => { filters: `orgSlug: "${props.orgSlug}"`, }) .then((response) => { - console.log(response); return setResults(response.hits); }); - }, [throttledValue]); + }, [throttledValue, props?.orgSlug]); return ( { - console.log("got the input value"); setValue(val); }} value={value}