Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #6 from gt732/react
Browse files Browse the repository at this point in the history
code formatting fix, title fix
  • Loading branch information
gt732 authored Mar 24, 2023
2 parents 1b4422e + b54499e commit 5cc6dd4
Show file tree
Hide file tree
Showing 17 changed files with 1,103 additions and 981 deletions.
28 changes: 2 additions & 26 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,14 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
name="FortiGPT"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>🤖 FortiGPT</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
43 changes: 12 additions & 31 deletions client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,24 @@
import React, { useState } from 'react';
import {
ChakraProvider,
Grid,
GridItem,
} from '@chakra-ui/react';
import { ChakraProvider, Grid, GridItem } from '@chakra-ui/react';
import Sidebar from './components/main/Sidebar';
import Main from './components/main/Main';
import { AppContext } from './AppContext';



export default function App() {

const [appData, setAppData] = useState({});

return (
<ChakraProvider>
<AppContext.Provider value={{ appData, setAppData }}>
<Grid templateColumns='repeat(7, 1fr)' overflow='auto' >
<GridItem
colSpan='1'
bg='#202324'
minHeight='100vh'
p='30px'

>
<Sidebar />
</GridItem>
<GridItem
colSpan='6'
p='30px'
bg='#0B0E12'
minHeight='100vh'
>
<Main />
</GridItem>

</Grid>
</AppContext.Provider>
<Grid templateColumns="repeat(7, 1fr)" overflow="auto">
<GridItem colSpan="1" bg="#202324" minHeight="100vh" p="30px">
<Sidebar />
</GridItem>
<GridItem colSpan="6" p="30px" bg="#0B0E12" minHeight="100vh">
<Main />
</GridItem>
</Grid>
</AppContext.Provider>
</ChakraProvider>
);
};
}
2 changes: 1 addition & 1 deletion client/src/AppContext.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createContext } from 'react';

export const AppContext = createContext();
export const AppContext = createContext();
89 changes: 47 additions & 42 deletions client/src/components/chatgpt/Chatgpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,64 @@ import React, { useState } from 'react';
import { Button, HStack, Text } from '@chakra-ui/react';
import { Textarea } from '@chakra-ui/react';




export default function Chatgpt(props) {
const [chatGptResponse, setChatGptResponse] = useState("");
const [loading, setLoading] = useState(false);

function fetchChatGptResponse() {
// Fetch the chatgpt response from the API
setLoading(true);
const options = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'gpt-3.5-turbo',
messages: [
{ role: 'system', content: props.chatGptPrompt },
{ role: 'user', content: props.debugOutput },
],
}),
};

fetch('/chatgpt', options)
.then((response) => response.json())
.then((data) => {
setChatGptResponse(data.content);
setLoading(false);
})
.catch((error) => {
console.error(error);
setLoading(false);
});
const [chatGptResponse, setChatGptResponse] = useState('');
const [loading, setLoading] = useState(false);

}
function fetchChatGptResponse() {
// Fetch the chatgpt response from the API
setLoading(true);
const options = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'gpt-3.5-turbo',
messages: [
{ role: 'system', content: props.chatGptPrompt },
{ role: 'user', content: props.debugOutput },
],
}),
};

fetch('/chatgpt', options)
.then(response => response.json())
.then(data => {
setChatGptResponse(data.content);
setLoading(false);
})
.catch(error => {
console.error(error);
setLoading(false);
});
}

return (
<>
<HStack pl='10px'>
<Text ml={2} color="white" fontWeight="bold">🤖 FortiGPT RESPONSE 🤖</Text>
<Button
borderRadius="full"
colorScheme="blue"
size="md"
ml={4}
isLoading={loading}
loadingText='Run FortiGPT'
<HStack pl="10px">
<Text ml={2} color="white" fontWeight="bold">
🤖 FortiGPT RESPONSE 🤖
</Text>
<Button
borderRadius="full"
colorScheme="blue"
size="md"
ml={4}
isLoading={loading}
loadingText="Run FortiGPT"
onClick={fetchChatGptResponse}
>
Run FortiGPT
</Button>
</HStack>
<Textarea color='white' bg='gray.800' defaultValue={chatGptResponse} my={4} size="md" maxWidth='2xl' maxLength='100px'/>
<Textarea
color="white"
bg="gray.800"
defaultValue={chatGptResponse}
my={4}
size="md"
maxWidth="2xl"
maxLength="100px"
/>
</>
);
}
Loading

0 comments on commit 5cc6dd4

Please sign in to comment.