From 748daca3b7934ce428fcfe8567ceb6e8d1077433 Mon Sep 17 00:00:00 2001 From: Daniel O'Connell Date: Sun, 1 Oct 2023 10:58:27 +0200 Subject: [PATCH] pr fixes --- web/src/components/citations.tsx | 2 +- web/src/pages/index.tsx | 47 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/web/src/components/citations.tsx b/web/src/components/citations.tsx index 3aaaafa..8aa44e7 100644 --- a/web/src/components/citations.tsx +++ b/web/src/components/citations.tsx @@ -73,7 +73,7 @@ export const ShowCitation: React.FC<{citation: Citation}> = ({citation}) => { // if we don't have a url, link to a duckduckgo search for the title instead const url = citation.url && citation.url !== "" ? citation.url - : `https://duckduckgo.com/?q=${encodeURIComponent(ndecitation.title)}`; + : `https://duckduckgo.com/?q=${encodeURIComponent(citation.title)}`; return ( { const [entries, setEntries] = useState([]); const [current, setCurrent] = useState(); const [sessionId, setSessionId] = useState() - const [citations, setCitations] = useState([]) + const [citations, setCitations] = useState([]) // [state, ready to save to localstorage] const [mode, setMode] = useState<[Mode, boolean]>(["default", false]); @@ -71,13 +71,12 @@ const Home: NextPage = () => { }, []); const updateCurrent = (current: CurrentSearch) => { - setCurrent(current); - if (current?.phase === "streaming") { - scroll30(); - } + setCurrent(current); + if (current?.phase === "streaming") { + scroll30(); + } }; - const updateCitations = (allCitations: Citation[], current: CurrentSearch) => { const entryCitations = Array.from(current.citationsMap.values()); if (!entryCitations.some(c => !c.index)) { @@ -111,26 +110,26 @@ const Home: NextPage = () => { ) => { // clear the query box, append to entries - const userEntry: Entry = { - role: "user", - content: query_source === "search" ? query : query.split("\n", 2)[1]!, - }; - setEntries((prev) => [...prev, userEntry]); - disable(); + const userEntry: Entry = { + role: "user", + content: query_source === "search" ? query : query.split("\n", 2)[1]!, + }; + setEntries((prev) => [...prev, userEntry]); + disable(); - const { result, followups } = await runSearch( - query, - query_source, - mode[0], - entries, - updateCurrent, - sessionId, - ); - setCurrent(undefined); + const { result, followups } = await runSearch( + query, + query_source, + mode[0], + entries, + updateCurrent, + sessionId, + ); + setCurrent(undefined); - setEntries((prev) => [...prev, result]); - enable(followups || []); - scroll30(); + setEntries((prev) => [...prev, result]); + enable(followups || []); + scroll30(); }; var last_entry = <>;