Skip to content

Commit 4950b02

Browse files
committed
main_summ
1 parent c11c5f3 commit 4950b02

File tree

6 files changed

+114
-23
lines changed

6 files changed

+114
-23
lines changed
800 Bytes
Binary file not shown.

Backend/summariser.py

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,40 @@
44
import shutil
55
import os
66
import asyncio
7+
import boto3
8+
from botocore.exceptions import NoCredentialsError
9+
10+
11+
s3_access_key = "AKIAZTHHIOR4CN6UXO6N"
12+
s3_secret_access_key = "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"
13+
s3_bucket_name = "learnmateai"
14+
15+
def save_file_to_s3(filename, content):
16+
try:
17+
# Connect to Amazon S3
18+
s3 = boto3.client(
19+
"s3",
20+
aws_access_key_id=s3_access_key,
21+
aws_secret_access_key=s3_secret_access_key
22+
)
23+
24+
# Set the desired S3 key
25+
s3_key = f"Generated_Files/Summarised_Notes/summarised_{filename}"
26+
27+
# Save the file content to Amazon S3
28+
s3.put_object(Body=content.encode('utf-8'), Bucket=s3_bucket_name, Key=s3_key)
29+
30+
return {"message": "File uploaded successfully"}
31+
except NoCredentialsError:
32+
return {"message": "AWS credentials not found"}
33+
34+
35+
36+
737

838
progress = None # just for tracking progress
939

10-
def summary(text):
40+
def summary(text,filename):
1141
# Load the summarization pipeline
1242
summarizer = pipeline("summarization")
1343
# Split the text into smaller chunks
@@ -44,33 +74,44 @@ def summary(text):
4474
# Print and return the combined summary
4575
print("Combined Summary:")
4676
print(combined_summary)
47-
print("Deleting the saved file.......")
48-
os.remove("dat.txt")
49-
print("deleted....")
50-
return{"summary" : combined_summary,"exceptions" : exceptions}
77+
with open(f'Local_Storage\Generated_Files\Summarised_Notes\summarised_{filename}', 'w', encoding='utf-8') as file:
78+
file.write(combined_summary)
79+
response = save_file_to_s3(filename, combined_summary)
80+
print(response)
81+
5182

5283

53-
async def gen_summary(file):
54-
try:
55-
with open("dat.txt", "wb") as buffer: # saving file
56-
shutil.copyfileobj(file.file, buffer)
57-
finally:
58-
file.file.close()
84+
async def gen_summary():
85+
# reading file
86+
folder_path = 'Local_Storage\\notes_txt'
87+
# Get the list of files in the folder
88+
file_list = os.listdir(folder_path)
89+
90+
# Iterate over each file in the folder
91+
for file_name in file_list:
92+
# Construct the full file path
93+
file_path = os.path.join(folder_path, file_name)
94+
95+
# Check if the path is a file (not a directory)
96+
if os.path.isfile(file_path):
97+
98+
with open(file_path, 'r', encoding='utf-8') as file:
99+
text = file.read()
100+
101+
loop = asyncio.get_running_loop() # making it to run in background
102+
await loop.run_in_executor(None, summary, text,file_name)
59103

60-
with open("dat.txt", "r", encoding='utf-8') as file:
61-
text = file.read() # reading file
62104

63-
loop = asyncio.get_running_loop() # making it to run in background
64-
return await loop.run_in_executor(None, summary, text)
105+
65106

66107

67108
router_summariser = APIRouter()
68109

69110

70111
@router_summariser.post("/get-summary")
71-
async def get_summary(file: UploadFile = File(...)):
72-
data = await gen_summary(file)
73-
return data
112+
async def get_summary():
113+
await gen_summary()
114+
return {"status" : 1}
74115

75116
@router_summariser.get("/summary-gen-progress") # route to track progress of summarization
76117
def get_summary_progress():
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This is to certify that Mr./Ms....ofFree/Euphoria secured... Second...... . place during the National Level Intercollegiate Techno-Cultural Fest, held on 12th of August 2022, organized by the Department of Computer Science, Rajagiri College of Social Sciences (Autonomous), Kalamassery, Kochi, Kerala . The Certificate is awarded to "Angelo Antu, School Of Engine, School of Engine" The certificate was awarded to Mr/Ms. Sanjay Murthy, the Higher Education, the Minister of Education of India .
2+
3+
"HackManthan" is a National level Hackathon for security - 13th to 20th June 2022 . The certificate is proudly presented to Cochin University of Science And Technology's Angelo Antu. Dinha and Dr. Pradeep K, Sinha for participating in Smart India Hackathon, 2022 . Anand Deshpande was selected for selection as a finalist in HackManthan's finalist . Anil D. Sahasrabudhe was awarded a Certificate of Appreciation .
4+
5+
Angelo Antu secured second prize for the hackathon conducted as part of DROID 2.0, hosted by IEEE FISAT SB in December 2021 . The prize was awarded to Angelo Antu, 4-ZERO-4IEEERobotics &.AutomationSociety . Ardra Saji and Professor Bejoy Varghese will receive the award in DotSlash 5.0 conducted at the National Institute of Technology, Surat on 7th-9th Jan, 2022 .
6+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The Indian Income-Tax Return of Income was filed in Form ITR-1 (SAHAJ) and Form II (ITR-4(SUGAM) The return of Income is filed and verified . The return is required to be submitted to the Indian National Revenue Service (N.S.T.L.D.T.) The Return of Tax returns are returned to the tax authorities in accordance with the Indian Income Tax Rules, 1962 . The tax returns are subject to an individual’s annual tax bill, which is refundable only, and the amount of tax paid is refunded only once .
2+
3+
The tax return was submitted electronically on 29-11-2020 11:42:01 from IP address 115.96.113.113 . The return was verified by using the electronic Verification Code 6A9ECLA5JI generated through the use of the OTPITR-4 . Do not send the return to CPC, BENGALURU, Bengaluru, India, or CPC, for verification purposes. The return has been verified by the Indian Revenue Service.
4+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Personal Data Protection Act 2010 sets out the policies and procedures of the Group with regard to your personal data . "Genting" means Genting Malaysia Berhad and/or its holding company, subsidiaries, related and associated companies using or may be using the brands of "Genting" and "Resorts World", regardless whether such company(ies) are incorporated in or outside Malaysia . "Personal Data" means personal data as defined under the Act, including without limitation your name, age, identity, gender, date of birth, address, email address, telephone number, occupation, position held, marital status, financial status, physical or mental health or medica .
2+
3+
The source of your Personal Data may come from you through your job application or information which is provided by any third parties, including recruitment agencies or . your referees, your current and previous . and . previous . employers, public records and background check agencies, any forms which you provide . The Group will obtain your personal data when you provide your . Personal Data to the Group in any way or manner in connection with your employment and/or proposed employment with the Group . The group will also obtain your . personal data .
4+
5+
The Group will also receive and store your PersonalData when you enter the Group's websites, social networking sites and/or blogs . The Group may use your Personal Data for the following purposes, namely.-To process your application/form; .To communicate with you;;.To respond to questions and comments from you;. To monitor, assess, assess and evaluate your fitness and properness to be employed by, or remain in employment with, the Group;. to make reference check with any third parties;.
6+
7+
Failure to provide the requested Personal Data or any limitation against the Group may result in the Group being unable to process the relevant application form or continue to employ you . You understand that your Personal Data may be transferred outside of Malaysia to those third parties with the Group share it as described in this PDPS. You're not required to provide any information to the Group. The Group may reasonably deem fit to comply with and/or discharge obligations required under the terms of the PDPS, such as disclosure to third parties.
8+
9+
For purposes as described herein, the Group may share with and/or transfer your Personal Dat to the other entities within the Group; the Group's third party consultants, professional advisors or service providers . The Group may also use the Dat for such other purposes as may be required or permitted by laws within and outside Malaysia, including laws relating to evidence . The Dat is subject to a duty of confidentiality to the Group, and may be subject to the confidentiality of any information provided by the privacy of the Group .
10+
11+
There is automatic collection of some information about your computer such as IP address, web browser software, and referring website . The Group may also share your Personal Data where required by law or where disclosure is necessary to comply with applicable laws, legal processes or queries from the relevant authorities . Such information is only used for the purpose of creating a better user experience and to identify areas for improvement on the Group's websites . You may always choose not to receive a cookie file by enabling your web browser to refuse cookies .
12+
13+
By refusing to accept a cookie, you may not be able to access certain services and tools offered on the website . You may, request to access to and/or to make any correction to your Personal Data by submitting a request in writing to the Group to the address stated in Section 8 below . Notwithstanding that access is granted to you or any correction / updating of your Personal data is performed, this PDPS will remain valid and effective at all times; and this will not be revoked .
14+
15+
You may request for access and/or request for correction of your Personal Data by writing to the following personnel for further assistance . You may not wish to receive any communications relating to job(ies) from the Group; or .wish for the Group to stop processing your personal data for employment purposes; or.wish to change the manner in which the Group is permitted to process your . Personal Data is likely to prejudice proper discharge of those functions by the . Group. ata as permitted under the . Act, including where your Personal . Data is being processed .
16+
17+
The Group reserves the right to revise this PDPS from time to time due to changes in applicable laws and regulations . The English version shall apply and prevail in case of discrepancies between the English version and other translated versions of the PDPS . Failure to sign PDPS may result in the Group being unable to provide adequate support for the Group. The Group may not be able to continue with the Group without any objection(s) The PDPS will be updated to reflect the changes made in applicable law and regulations.
18+
19+
Under such circumstances, the Group reserves its rights to take whatever action it deems fit in accordance with its rights and/or for the protection of its interests . Penyata Pemprosesan Data Peribadi" ertinya Genting Malaysia Berhad yang ditaksirkan di bawah Akta, termasuk tanpa batasan nama, umur, nombor telefon, pekerjaan, jawatan dipegang, statusperkahwinan, status kewangan, mental atau keadaan perubatan/rekod-rekod .
20+
21+
Pemberian Data PeribadiKumpulan akan memperolehi Data Perbadi anda apabila anda memberi Data peribadi . The data pahraman yang dikumpul, disusun, diproses, dikekalkan dari semasa ke semasa. /atau rekod-rekod vaksinasi kepercayaan agama atau kepercean lain yang .
22+
23+
Kumpulan mungkin telah mengambil bahagian atau melakukan pada bila-bila masa . Apa-apa tujuan berkenaan dengan penggajian dan/atau cadangan pengajian anda dengan Kumpuulan . The author-of-the-criticized domain awam. g borang yang dilengkapkan oleh anda, emel-emel .
24+
25+
Pemberian Data Peribadi anda untuk tujuan-tujuan yang disenaraikan dalam dalam, dibenarkan oleh undang-undang di dalam dan di luar. 9 untuk pekerja-pekerja Kumpulan;. (j)                (k)                :                (j)                                                              (k),                (g)                                       ;                                (g),       (j),       ;                                     (c)                         :                             (J)                    )
26+
27+
Andamemahami dan bersetuju bahawa Data Peribadi anda mungkin dipindahkan kepada pihak ketiga di luar Malaysia . Anda. a) memproses permohonan/borang berkenaan; . dan/atau (b) menggaji atau (a) manggaji (b), . anda. The PPDPS/NT/050820213.
28+
29+
The Pengumpulan Informasi Dari Laman Web mungkin berkongsi Data Peribadi anda seperti yang diwajibkan oleh undang-undang atau jika. n dari semasa ke semasa; dan pengawalselia dan pihak berkuasa kerajaan untuk mematuhi keperluan. Atau orang-orang-Orang-particularlyyang diberi kuasa termasuk .
30+
31+
Anda berhak memilih untuk tidak menerima fail cookie dengan membolehkan pelayar web. Anda mungkin diperuntukkan satu fail cookie kekal pada pemacu cakera. Itu hanyadigunakan untuk mewujudkan pengalaman pengguna yang lebih baik . Anda boleh memohon mengakses kepada dan/atau membuat sebarang pembetulan .
32+
33+
PPDP ini hendaklah terus menjadi sah dan berkesan pada setiap masa. menolak permintaan anda untuk mengakses . Menyediakan akses diberikan kepada anda atau sebarang pembetulan/pengemaskinian yang dilakukan . Atau hak untuk membuat sebaranakan pelaksanaan fungsi pengawalseliaan .
34+
35+
Kumpulan berhenti memproses Data Peribadi anda untuk tujuan pekerjaan . Atau akses berhak untuk menyemak semula PPDP ini dari semasa ke semasa atas sebab perubahan. asi berkaitan jawatan-jawatan kosong daripada KumpULan; atau akeses diterangkan di bawah Seksyen 3 di atas .
36+
37+
PPDP ini boleh mengakibatkan Kumpulan tidak dapat memproses                Data Peribadi anda untuk tujuan yang dinyatakan di atas . Anda berlaku percanggahan antara versi Bahasa Inggeris dan versi terjemahan lain untukPPDP, maka  -   - akan dirujuk dan diguna pakai. Anda masih mengekalkan perhubungan .
38+
39+
Syarat bersetuju dengan terma-terma dan syarat-syarat yang ditetapkan dalam Penyata Pemprosesan Data Peribadi . ata mengesahkan bahawa saya telah membaca, memahami dan secara suara sukarela . Ata termasuk apa-apa data-peribadi sensitif (term as ini memberi persetujuan) seperti yang diperuntukkan .
40+

app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from fastapi.middleware.cors import CORSMiddleware
44
from mangum import Mangum
55
#from Backend.pyqsorter import router as api1_router
6-
#from Backend.summariser import router_summariser as summariser
6+
from Backend.summariser import router_summariser as summariser
77
#from Backend.Notes_Analyser import router as api4_router
88
#from Backend.Narrator import router as api5_router
9-
from Backend.NotesToText import router as notestotext
9+
#from Backend.NotesToText import router as notestotext
1010
# import other API routers as needed
1111

1212
origins = ["*"]
@@ -26,16 +26,16 @@
2626

2727
# Mount the API routerss
2828
#app.include_router(api1_router)
29-
#app.include_router(summariser)
29+
app.include_router(summariser)
3030
#app.include_router(api4_router)
3131
#app.include_router(api6_router)
32-
app.include_router(notestotext)
32+
#app.include_router(notestotext)
3333

3434
# include other API routers as needed
3535

3636
#app.include_router(NotesToText_rounter)
3737
#app.include_router(api1_router)
3838

3939
if __name__ == "__main__":
40-
uvicorn.run(app, host="0.0.0.0", port=8000)
40+
uvicorn.run(app, host="127.0.0.1", port=8000)
4141

0 commit comments

Comments
 (0)