From ea83fb396ef5f4348aa1ba24d89fc43f0ba16dab Mon Sep 17 00:00:00 2001 From: Dhyan441 Date: Sat, 7 Oct 2023 22:04:47 -0400 Subject: [PATCH] the signin and signup page + api scripts --- client/src/components/Login.jsx | 68 +++++++++++++++++++++++---------- server/aiAPI/fetchFlash.py | 18 +++++++++ server/aiAPI/test.py | 17 +++++++++ 3 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 server/aiAPI/fetchFlash.py create mode 100644 server/aiAPI/test.py diff --git a/client/src/components/Login.jsx b/client/src/components/Login.jsx index 9f87eed..f47bcde 100644 --- a/client/src/components/Login.jsx +++ b/client/src/components/Login.jsx @@ -1,28 +1,56 @@ -import React from 'react' +import React, { useState } from 'react'; const Login = () => { + const [isLogin, setIsLogin] = useState(true); + + const toggleCard = () => { + setIsLogin(!isLogin); + }; + return ( -
login -
-{/* form */} -

Wlcome Back

-

Welcome back! Please sign in.

-
+
+
+
+

Welcome {isLogin ? 'Back' : 'New User'}

+

{isLogin ? 'Welcome back! Please sign in.' : 'Join us today! Create an account.'}

+
+ + +
+
+ + +
+
- - -
-
-
-
-
-
- -
+ +
+ {isLogin ? ( + + ) : null} +
+
+ + +
+
+
+
+
+
- ) -} + ); +}; -export default Login \ No newline at end of file +export default Login; diff --git a/server/aiAPI/fetchFlash.py b/server/aiAPI/fetchFlash.py new file mode 100644 index 0000000..4bdb4ac --- /dev/null +++ b/server/aiAPI/fetchFlash.py @@ -0,0 +1,18 @@ +import openai + + +def flashCards (input) -> list[dict]: + api_key = "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" + + prompt = "Give me an array of 5 objects with fields prompt and answer where prompt has the question and answer has the answer use this input as the material:" + input + + response = openai.Completion.create( + engine="text-davinci-002", + prompt=prompt, + max_tokens=3800, + api_key=api_key + ) + + answer = response.choices[0].text + print(answer) + return answer diff --git a/server/aiAPI/test.py b/server/aiAPI/test.py new file mode 100644 index 0000000..874dacb --- /dev/null +++ b/server/aiAPI/test.py @@ -0,0 +1,17 @@ +import fetchFlash + +input = """ + Optical Disk: an optical disc drive (ODD) is a disk drive that uses laser light as part of the process + of reading or writing data to or from optical discs. Some drives can only read from discs, but recent + drives are commonly both readers and recorders, also called burners or writers. Compact discs, + DVDs, and Blu-ray discs are common types of optical media which can be read and recorded by + such drives. Optical drive is the generic name; drives are usually described as "CD" "DVD", or + "Bluray", followed by "drive", "writer", etc. There are three main types of optical media: CD, + DVD, and Blu-ray disc. CDs can store up to 700 megabytes (MB) of data and DVDs can store up + to 8.4 GB of data. Blu-ray discs, which are the newest type of optical media, can store up to 50 + GB of data. This storage capacity is a clear advantage over the floppy disk storage media (a + magnetic media), which only has a capacity of 1.44 MB. + """ + +fetchFlash.flashCards() +