From eaf17cfba0529e1d76e00a3869467d328def1ec8 Mon Sep 17 00:00:00 2001 From: Fraser Date: Fri, 24 Mar 2023 22:27:04 -0400 Subject: [PATCH] clean up index.tsx --- web/src/pages/index.tsx | 23 +++++++++++------------ web/src/styles/globals.css | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/web/src/pages/index.tsx b/web/src/pages/index.tsx index 85fa319..37a1617 100644 --- a/web/src/pages/index.tsx +++ b/web/src/pages/index.tsx @@ -26,25 +26,23 @@ const Home: NextPage = () => { so if anyone else is considering this, you can message us to coordinate sharing the embeddings to avoid redundancy.

-

Python serverless test:

+ +

Get the most semantic similar results to a query:

); }; -// round trip test. If this works, our heavier usecase probably will (famous last words) +// Round trip test. If this works, our heavier usecase probably will (famous last words) // The one real difference is we'll want to send back a series of results as we get // them back from OpenAI - I think we can just do this with a websocket, which -// shouldn't be too different. - -// a search-box the person can type in, where they then can hit enter to search. -// The query gets sent to api/search, and a list of links is returned, which are -// then displayed below. +// shouldn't be too much harder. const SearchBox: React.FC = () => { - const [query, setQuery] = useState(""); - const [results, setResults] = useState<{title: string, url: string}[]>([]); + + const [query, setQuery] = useState(""); + const [results, setResults] = useState<{title: string, url: string}[]>([]); const [loading, setLoading] = useState(false); const embeddings = async (query: String) => { @@ -71,7 +69,7 @@ const SearchBox: React.FC = () => { return ( <> -
{ + { // store in a form so that submits e.preventDefault(); setResults(await embeddings(query)); }}> @@ -86,10 +84,11 @@ const SearchBox: React.FC = () => { {loading ? "Loading..." : "Search"} - {loading ?

loading...

: ( + + {loading ?

loading...

: ( // display results in list
    {results.map((result) => ( -
  • +
  • {result.title}
  • ))} diff --git a/web/src/styles/globals.css b/web/src/styles/globals.css index 46d0311..c35c1b9 100644 --- a/web/src/styles/globals.css +++ b/web/src/styles/globals.css @@ -3,7 +3,7 @@ @tailwind utilities; h1 { - @apply text-4xl font-bold mb-4; + @apply text-4xl font-bold my-4; } main {