This commit is contained in:
Daniel O'Connell
2023-10-01 10:58:27 +02:00
parent 0a5f995855
commit 748daca3b7
2 changed files with 24 additions and 25 deletions
+1 -1
View File
@@ -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 (
<A className={Colours[(citation.index - 1) % Colours.length] + " border-2 flex items-center rounded my-2 text-sm no-underline w-fit"}
+23 -24
View File
@@ -52,7 +52,7 @@ const Home: NextPage = () => {
const [entries, setEntries] = useState<Entry[]>([]);
const [current, setCurrent] = useState<CurrentSearch>();
const [sessionId, setSessionId] = useState()
const [citations, setCitations] = useState<Citation>([])
const [citations, setCitations] = useState<Citation>([])
// [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 = <></>;