Skip to content

Commit da593a5

Browse files
committed
test
1 parent f529d41 commit da593a5

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

Backend/test.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import openai
2+
3+
# Set up your OpenAI API credentials
4+
openai.api_key = ""
5+
6+
7+
# Define your input parameters
8+
with open('#define path sorted questions here', 'r') as file:
9+
sorted_questions = str(file.read())
10+
with open('#define path notebook questions here', 'r') as file:
11+
notebook_questions = str(file.read())
12+
with open('#define path for important topics here', 'r') as file:
13+
important_topics = str(file.read())
14+
with open('#define path for reference paper here', 'r', encoding='latin-1') as file:
15+
reference_paper = str(file.read())
16+
17+
18+
# Construct the prompt for question generation
19+
prompt = f"generate 10 questions that are not in reference paper but similar \nSorted Previous Year Questions:\n{sorted_questions}\n\nNotebook Question List:\n{notebook_questions}\n\nImportant Topics:\n{important_topics}\n\nReference Paper:\n{reference_paper}\n\n"
20+
21+
22+
# Generate questions using OpenAI API
23+
response = openai.Completion.create(
24+
engine="davinci",
25+
prompt=prompt,
26+
max_tokens=1000, # Adjust the max_tokens value as per your requirement
27+
temperature=0.4, # Adjust the temperature value to control the creativity of the generated questions
28+
top_p=1.0,
29+
frequency_penalty=0.0,
30+
presence_penalty=0.0,
31+
n=5 # Adjust the 'n' value to generate more or fewer questions
32+
)
33+
34+
# Extract the generated questions from the API response
35+
generated_questions = [choice['text'].strip() for choice in response.choices]
36+
37+
# Print the generated questions
38+
for i, question in enumerate(generated_questions):
39+
print(f"Question {i+1}: {question}")

Python_Code/Generate_qns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import openai
22

33
# Set up your OpenAI API credentials
4-
openai.api_key = "##"
4+
openai.api_key = "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"
55

66

77
# Define your input parameters

0 commit comments

Comments
 (0)