-
Notifications
You must be signed in to change notification settings - Fork 4
/
App.js
executable file
·59 lines (50 loc) · 1.76 KB
/
App.js
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
53
54
55
56
57
58
59
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
import React from "react";
import Amplify, { Auth } from "aws-amplify";
import { AmazonAIPredictionsProvider } from "@aws-amplify/predictions";
import API from "@aws-amplify/api";
import { withAuthenticator, Button } from "@aws-amplify/ui-react";
import MyTimeSeries from "./components/MyTimeSeries.js";
import ToxicText from "./components/ToxicText.js";
import awsconfig from "./aws-exports";
import configSettings from "./toxicity-settings.json";
import "./App.css";
import "@aws-amplify/ui-react/styles.css";
Amplify.configure(awsconfig);
Auth.configure(awsconfig);
Amplify.addPluggable(new AmazonAIPredictionsProvider());
API.configure({
endpoints: [
{
name: "myToxicityAPI",
endpoint: configSettings.API_URL,
service: "lambda",
},
],
});
/**
* Function that orchestrates getting predictions from a list of sentences, and scoring them
* @param {Object} Anonymous Cognito integration
*/
function App({ signOut, user }) {
const tsRef = React.createRef();
return (
<div className="App">
<h2 className="App-header">Detecting Toxicity in near real time</h2>
<ToxicText display={tsRef} />
<div className="tsGraphContainer">
<div className="Graph">
<MyTimeSeries
ref={tsRef}
name="myToxicityGraph"
title="Detecting Toxicity in near real time"
aws={awsconfig}
/>
</div>
</div>
<Button onClick={signOut}>Sign out</Button>
</div>
);
}
export default withAuthenticator(App);