File size: 1,505 Bytes
a7634ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { usePubSub } from "create-pubsub/react";
import {
  promptPubSub,
  responsePubSub,
  searchResultsPubSub,
  urlsDescriptionsPubSub,
} from "../modules/pubSub";
import { SearchForm } from "./SearchForm";
import { Toaster } from "react-hot-toast";
import Markdown from "markdown-to-jsx";
import { getDisableAiResponseSetting } from "../modules/pubSub";
import { SearchResultsList } from "./SearchResultsList";
import { useEffect } from "react";
import { prepareTextGeneration } from "../modules/textGeneration";

export function App() {
  const [query, updateQuery] = usePubSub(promptPubSub);
  const [response] = usePubSub(responsePubSub);
  const [searchResults] = usePubSub(searchResultsPubSub);
  const [urlsDescriptions] = usePubSub(urlsDescriptionsPubSub);

  useEffect(() => {
    prepareTextGeneration();
  }, []);

  return (
    <>

      <SearchForm query={query} updateQuery={updateQuery} />

      {!getDisableAiResponseSetting() && response.length > 0 && (

        <div

          style={{

            backgroundColor: "var(--background)",

            borderRadius: "6px",

            padding: "10px 25px",

          }}

        >

          <Markdown>{response}</Markdown>

        </div>

      )}

      {searchResults.length > 0 && (

        <div>

          <SearchResultsList

            searchResults={searchResults}

            urlsDescriptions={urlsDescriptions}

          />

        </div>

      )}

      <Toaster />

    </>
  );
}