Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementing frontend | restructuring data backend #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions backend/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def generate_keyphrases(abstract, model_path,tokenizer_path):
input_ids=tokenizer.encode(input_text, truncation=True,padding='max_length',max_length=512,return_tensors='pt').to(device)
output=model.generate(input_ids)
keyphrases= tokenizer.decode(output[0],skip_special_tokens=True).split(',')
# print("keyphrases generated")
return [x.strip() for x in keyphrases if x != '']

def generate_qa(text):
Expand All @@ -65,40 +66,44 @@ def generate_qa(text):
# tokenizerA, tokenizerB= './tokenizers/tokenizerA', './tokenizers/tokenizerB'
tokenizerA, tokenizerB= 't5-base', 't5-base'

answers=generate_keyphrases(text_summary, modelA, tokenizerA)

qa={}
for answer in answers:
question= generate_question(text_summary, answer, modelB, tokenizerB)
qa[question]=answer

return qa
key_phrases = generate_keyphrases(text_summary, modelA, tokenizerA)

data = {
"one_word": []
}
for key_phrase in key_phrases:
question= generate_question(text_summary, key_phrase, modelB, tokenizerB)
answer = key_phrase
entry = {
"question": question,
"answer": answer
}
data["one_word"].append(entry)
# print(data)
return data






class QARequestHandler(http.server.BaseHTTPRequestHandler):

def do_OPTIONS(self):
self.send_response(200)
print("options")
self.send_header("Access-Control-Allow-Methods", "POST, OPTIONS")
self.send_header("Access-Control-Allow-Headers", "Content-type")
self.send_header("Access-Control-Allow-Origin", "*")
self.end_headers()
def do_POST(self):

self.send_response(200)
self.send_header("Content-type", "text/plain")
self.send_header("Access-Control-Allow-Origin", "*")
self.end_headers()

content_length=int(self.headers["Content-Length"])
post_data=self.rfile.read(content_length).decode('utf-8')

# parsed_data=urllib.parse.parse_qs(post_data)
parsed_data = json.loads(post_data)


input_text=parsed_data.get('input_text')

qa=generate_qa(input_text)


# print("qa generated")

self.wfile.write(json.dumps(qa).encode("utf-8"))
self.wfile.flush()
Expand All @@ -109,6 +114,4 @@ def main():
server.serve_forever()

if __name__=="__main__":
main()


main()
1 change: 1 addition & 0 deletions extension/build/dist/assets/index-QilYtehn.css

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions extension/build/dist/assets/index-kttwlvzD.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions extension/build/dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<script type="module" crossorigin src="./assets/index-kttwlvzD.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-QilYtehn.css">
</head>
<body>
<div id="root"></div>
</body>
</html>
1 change: 1 addition & 0 deletions extension/build/dist/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions extension/build/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"manifest_version": 3,
"name": "edu-aid",
"version": "1.0",
"description": "",
"action": {
"default_popup": "./dist/index.html"
},
"permissions": [
"scripting",
"tabs",
"activeTab",
"storage"
],
"host_permissions": [
"https://*/*",
"http://*/*"
],
"icons": {
"16": "./dist/logos/aossie_logo16.png",
"32": "./dist/logos/aossie_logo32.png"
}

}
30 changes: 30 additions & 0 deletions extension/code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
Empty file added extension/code/background.js
Empty file.
17 changes: 17 additions & 0 deletions extension/code/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/index.css",
"baseColor": "zinc",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
13 changes: 13 additions & 0 deletions extension/code/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions extension/code/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"manifest_version": 3,
"name": "edu-aid",
"version": "1.0",
"description": "",
"action": {
"default_popup": "./dist/index.html"
},
"permissions": [
"scripting",
"tabs",
"activeTab",
"storage"
],
"host_permissions": [
"https://*/*",
"http://*/*"
],
"icons": {
"16": "./dist/logos/aossie_logo16.png",
"32": "./dist/logos/aossie_logo32.png"
}

}
Loading