├── README.md ├── public ├── robots.txt ├── favicon.ico ├── logo192.png ├── logo512.png ├── manifest.json └── index.html ├── src ├── setupTests.js ├── App.test.js ├── index.css ├── reportWebVitals.js ├── index.js ├── App.css ├── logo.svg └── App.js ├── .gitignore └── package.json /README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredragWebDev/chatgpt-detector/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredragWebDev/chatgpt-detector/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredragWebDev/chatgpt-detector/HEAD/public/logo512.png -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | const root = ReactDOM.createRoot(document.getElementById('root')); 8 | root.render( 9 | 10 | 11 | 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chatgpt-detector", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.14.1", 7 | "@testing-library/react": "^13.0.0", 8 | "@testing-library/user-event": "^13.2.1", 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0", 11 | "react-scripts": "5.0.1", 12 | "web-vitals": "^2.1.0", 13 | "antd": "^5.1.6", 14 | "openai": "^3.1.0" 15 | }, 16 | "scripts": { 17 | "start": "react-scripts start", 18 | "build": "react-scripts build", 19 | "test": "react-scripts test", 20 | "eject": "react-scripts eject" 21 | }, 22 | "eslintConfig": { 23 | "extends": [ 24 | "react-app", 25 | "react-app/jest" 26 | ] 27 | }, 28 | "browserslist": { 29 | "production": [ 30 | ">0.2%", 31 | "not dead", 32 | "not op_mini all" 33 | ], 34 | "development": [ 35 | "last 1 chrome version", 36 | "last 1 firefox version", 37 | "last 1 safari version" 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | ChatGPT Detector 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | .detector-area { 11 | width: calc(100% - 195px) !important; 12 | border-radius: 8px 0 0 8px !important; 13 | } 14 | 15 | .percentage-area { 16 | width: 195px !important; 17 | display: flex; 18 | align-items: center; 19 | border-radius: 0 8px 8px 0 !important; 20 | } 21 | 22 | .field-title { 23 | font-family: Poppins,sans-serif; 24 | font-style: normal; 25 | font-weight: 500; 26 | font-size: 16px; 27 | line-height: 1.5; 28 | color: #000; 29 | margin-bottom: 5px; 30 | display: block; 31 | } 32 | 33 | .text-align-center { 34 | text-align: center; 35 | } 36 | 37 | .field-title:not(:first-child) { 38 | margin-top: 20px; 39 | } 40 | 41 | .action-btn { 42 | cursor: pointer; 43 | background: #000; 44 | text-decoration: none; 45 | font-family: Poppins,sans-serif; 46 | font-weight: 600; 47 | font-size: 16px; 48 | line-height: 1.5; 49 | text-align: center; 50 | color: #fff; 51 | vertical-align: middle; 52 | padding: 5px 10px; 53 | min-height: 48px; 54 | border-color: black; 55 | } 56 | 57 | .action-btn:not(:disabled):hover { 58 | color: white; 59 | background: black; 60 | border-color: black; 61 | } 62 | 63 | .action-btn:active { 64 | border-color: black !important; 65 | background: black !important; 66 | } 67 | 68 | @media (prefers-reduced-motion: no-preference) { 69 | .App-logo { 70 | animation: App-logo-spin infinite 20s linear; 71 | } 72 | } 73 | 74 | .App-header { 75 | background-color: #282c34; 76 | min-height: 100vh; 77 | display: flex; 78 | flex-direction: column; 79 | align-items: center; 80 | justify-content: center; 81 | font-size: calc(10px + 2vmin); 82 | color: white; 83 | } 84 | 85 | .App-link { 86 | color: #61dafb; 87 | } 88 | 89 | @keyframes App-logo-spin { 90 | from { 91 | transform: rotate(0deg); 92 | } 93 | to { 94 | transform: rotate(360deg); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import './App.css'; 2 | import { useEffect, useState } from 'react'; 3 | import { Configuration, OpenAIApi } from 'openai'; 4 | import { Form, Input, Typography, Card, Col, Row, Progress, Button, Space} from 'antd'; 5 | const { Title, Text } = Typography; 6 | const { TextArea } = Input; 7 | 8 | function App() { 9 | const configuration = new Configuration({ 10 | apiKey: "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", 11 | }); 12 | const openai = new OpenAIApi(configuration); 13 | 14 | const [form] = Form.useForm(); 15 | const [input, setInput] = useState(""); 16 | const [size, setSize] = useState('large'); // default is 'middle' 17 | const [percent, setPercent] = useState(0); 18 | const [isLoading, setIsLoading] = useState(null); 19 | const [answer, setAnswer] = useState(""); 20 | const [prefix, setPrefix] = useState('Print only without "%" how many percentage you can evaluate to write this yourself?: "') 21 | const [suffix, setSuffix] = useState('"') 22 | 23 | const onCheck = async () => { 24 | try { 25 | const values = await form.validateFields(); 26 | 27 | const message = `${prefix}${input}${suffix}`; 28 | 29 | setIsLoading(true); 30 | 31 | console.log(`${message}`); 32 | 33 | const response = await openai.createCompletion({ 34 | model: "text-davinci-003", 35 | prompt: `${message}`, 36 | max_tokens: 800, 37 | temperature: 0.6, 38 | }); 39 | 40 | setPercent(`${response.data.choices[0].text}`); 41 | 42 | if (percent > 80) { 43 | setAnswer("Yes, I wrote this."); 44 | console.log("Yes", percent); 45 | } else { 46 | setAnswer("No, I didn't write this."); 47 | console.log("no", percent); 48 | } 49 | 50 | setIsLoading(false); 51 | 52 | } catch (errorInfo) { 53 | console.log('Failed:', errorInfo); 54 | } 55 | }; 56 | 57 | return ( 58 | <> 59 |
63 | 64 | ChatGPT Detector 65 | 66 | 67 | Please input your essay. 68 | 77 | setInput(e.target.value)} 81 | /> 82 | 83 | Have this essay written by OpenAI? 84 |