File size: 968 Bytes
12bd0e7
 
61b0941
 
 
12bd0e7
390d888
12bd0e7
 
61b0941
 
12bd0e7
 
61b0941
 
12bd0e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f182217
 
 
 
 
 
 
 
61b0941
 
 
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
import { useEffect} from "react";
import { ChainlitAPI, sessionState, useChatSession } from "@chainlit/react-client";
import { Playground } from "./components/playground";
import { useRecoilValue } from "recoil";


const CHAINLIT_SERVER ="https://bentebbutt-langroid-custom-front-end.hf.space";


const userEnv = {};

const apiClient = new ChainlitAPI(CHAINLIT_SERVER);


function App() {
    const { connect } = useChatSession();
    const session = useRecoilValue(sessionState);

    useEffect(() => {
        if (session?.socket.connected) {
            return
        }
        fetch(apiClient
            .buildEndpoint("/custom-auth")).then((res) => {
                return res.json();
            }
        ).then((data) => {
                connect({ client: apiClient, userEnv, accessToken: `Bearer: ${data.token}` });
            }
        )
    }, []);


  return (
    <>
      <div>
        <Playground />
      </div>
    </>
  );
}

export default App;