Skip to content

Commit 1845696

Browse files
committed
test
1 parent 2a8ef13 commit 1845696

File tree

2 files changed

+18
-39
lines changed

2 files changed

+18
-39
lines changed

Backend/summariser.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,22 @@ async def gen_summary(file):
6464
return await loop.run_in_executor(None, summary, text)
6565

6666

67-
router_summariser = APIRouter()
67+
# router_summariser = APIRouter()
6868

6969

70-
@router_summariser.post("/get-summary")
71-
async def get_summary(file: UploadFile = File(...)):
72-
data = await gen_summary(file)
73-
return data
70+
# @router_summariser.post("/get-summary")
71+
# async def get_summary(file: UploadFile = File(...)):
72+
# data = await gen_summary(file)
73+
# return data
7474

75-
@router_summariser.get("/summary-gen-progress") # route to track progress of summarization
76-
def get_summary_progress():
77-
global progress
78-
if progress is None :
79-
return {"status" : "No summarisation process in progress" }
80-
elif progress == 100 :
81-
return {"status" : "Completed" , "value" : progress}
82-
elif progress in range(0,101) :
83-
return {"status" : progress}
84-
else :
85-
return {"invalid data detected"}
75+
# @router_summariser.get("/summary-gen-progress") # route to track progress of summarization
76+
# def get_summary_progress():
77+
# global progress
78+
# if progress is None :
79+
# return {"status" : "No summarisation process in progress" }
80+
# elif progress == 100 :
81+
# return {"status" : "Completed" , "value" : progress}
82+
# elif progress in range(0,101) :
83+
# return {"status" : progress}
84+
# else :
85+
# return {"invalid data detected"}

Backend/test.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import openai
2-
import shutil
3-
import os
42
import chardet
53
from fastapi import FastAPI,UploadFile,File
64
from fastapi import APIRouter
75

6+
openai.api_key = "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" # Replace with your API key
87

98
def detect_encoding(data):
109
result = chardet.detect(data)
@@ -29,27 +28,7 @@ async def gen_questions(sorted_q: UploadFile = File(...),notebook_q: UploadFile
2928
decoded_reference_paper = reference_paper.decode(detect_encoding(reference_paper))
3029

3130

32-
prompt = f"generate 10 questions that are not in reference paper but similar \nSorted Previous Year Questions:\n{decoded_sorted_questions}\n\nNotebook Question List:\n{decoded_notebook_questions}\n\nImportant Topics:\n{decoded_important_topics}\n\nReference Paper:\n{decoded_reference_paper}\n\n"
33-
34-
35-
# Generate questions using OpenAI API
36-
response = openai.Completion.create(
37-
engine="davinci",
38-
prompt=prompt,
39-
max_tokens=1000, # Adjust the max_tokens value as per your requirement
40-
temperature=0.4, # Adjust the temperature value to control the creativity of the generated questions
41-
top_p=1.0,
42-
frequency_penalty=0.0,
43-
presence_penalty=0.0,
44-
n=5 # Adjust the 'n' value to generate more or fewer questions
45-
)
46-
47-
# Extract the generated questions from the API response
48-
generated_questions = [choice['text'].strip() for choice in response.choices]
49-
50-
# Print the generated questions
51-
for i, question in enumerate(generated_questions):
52-
print(f"Question {i+1}: {question}")
31+
5332

5433

5534

0 commit comments

Comments
 (0)