Add question db insert.
This commit is contained in:
3
.idea/ielts-be.iml
generated
3
.idea/ielts-be.iml
generated
@@ -10,6 +10,9 @@
|
||||
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PackageRequirementsSettings">
|
||||
<option name="versionSpecifier" value="Don't specify version" />
|
||||
</component>
|
||||
<component name="TemplatesService">
|
||||
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
|
||||
<option name="TEMPLATE_FOLDERS">
|
||||
|
||||
94
app.py
94
app.py
@@ -5,8 +5,8 @@ import firebase_admin
|
||||
from firebase_admin import credentials
|
||||
from helper.api_messages import QuestionType, get_grading_messages, get_question_gen_messages
|
||||
from helper.file_helper import delete_files_older_than_one_day
|
||||
from helper.firebase_helper import download_firebase_file
|
||||
from helper.speech_to_text_helper import speech_to_text
|
||||
from helper.firebase_helper import download_firebase_file, upload_file_firebase
|
||||
from helper.speech_to_text_helper import speech_to_text, text_to_speech
|
||||
from helper.token_counter import count_tokens
|
||||
from helper.openai_interface import make_openai_call
|
||||
import os
|
||||
@@ -27,11 +27,87 @@ firebase_admin.initialize_app(cred)
|
||||
|
||||
GRADING_TEMPERATURE = 0.1
|
||||
GEN_QUESTION_TEMPERATURE = 0.9
|
||||
GPT_3_5_TURBO = "gpt-3.5-turbo"
|
||||
GPT_3_5_TURBO_16K = "gpt-3.5-turbo-16k"
|
||||
GRADING_FIELDS = ['overall', 'comment', 'task_response']
|
||||
GEN_FIELDS = ['question']
|
||||
LISTENING_GEN_FIELDS = ['transcript', 'exercise']
|
||||
|
||||
FIREBASE_BUCKET = 'mti-ielts.appspot.com'
|
||||
AUDIO_FILES_PATH = 'download-audio/'
|
||||
FIREBASE_LISTENING_AUDIO_FILES_PATH = 'listening_recordings/'
|
||||
|
||||
@app.route('/listening_section_1', methods=['GET'])
|
||||
@jwt_required()
|
||||
def get_listening_section_1_question():
|
||||
try:
|
||||
messages = get_question_gen_messages(QuestionType.LISTENING_SECTION_1)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(GPT_3_5_TURBO_16K, messages, token_count, LISTENING_GEN_FIELDS, GEN_QUESTION_TEMPERATURE)
|
||||
return response
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
@app.route('/listening_section_2', methods=['GET'])
|
||||
@jwt_required()
|
||||
def get_listening_section_2_question():
|
||||
try:
|
||||
delete_files_older_than_one_day(AUDIO_FILES_PATH)
|
||||
messages = get_question_gen_messages(QuestionType.LISTENING_SECTION_2)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(GPT_3_5_TURBO_16K, messages, token_count, LISTENING_GEN_FIELDS, GEN_QUESTION_TEMPERATURE)
|
||||
|
||||
# file_name = str(uuid.uuid4()) + ".mp3"
|
||||
# sound_file_path = AUDIO_FILES_PATH + file_name
|
||||
# firebase_file_path = FIREBASE_LISTENING_AUDIO_FILES_PATH + file_name
|
||||
# text_to_speech(response["transcript"], sound_file_path)
|
||||
# upload_file_firebase(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
||||
# response["audio_file"] = firebase_file_path
|
||||
return response
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
@app.route('/listening_section_3', methods=['GET'])
|
||||
@jwt_required()
|
||||
def get_listening_section_3_question():
|
||||
try:
|
||||
delete_files_older_than_one_day(AUDIO_FILES_PATH)
|
||||
messages = get_question_gen_messages(QuestionType.LISTENING_SECTION_3)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(GPT_3_5_TURBO_16K, messages, token_count, LISTENING_GEN_FIELDS, GEN_QUESTION_TEMPERATURE)
|
||||
|
||||
# file_name = str(uuid.uuid4()) + ".mp3"
|
||||
# sound_file_path = AUDIO_FILES_PATH + file_name
|
||||
# firebase_file_path = FIREBASE_LISTENING_AUDIO_FILES_PATH + file_name
|
||||
# text_to_speech(response["transcript"], sound_file_path)
|
||||
# upload_file_firebase(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
||||
# response["audio_file"] = firebase_file_path
|
||||
return response
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
@app.route('/listening_section_4', methods=['GET'])
|
||||
@jwt_required()
|
||||
def get_listening_section_4_question():
|
||||
try:
|
||||
delete_files_older_than_one_day(AUDIO_FILES_PATH)
|
||||
messages = get_question_gen_messages(QuestionType.LISTENING_SECTION_4)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(GPT_3_5_TURBO_16K, messages, token_count, LISTENING_GEN_FIELDS, GEN_QUESTION_TEMPERATURE)
|
||||
|
||||
# file_name = str(uuid.uuid4()) + ".mp3"
|
||||
# sound_file_path = AUDIO_FILES_PATH + file_name
|
||||
# firebase_file_path = FIREBASE_LISTENING_AUDIO_FILES_PATH + file_name
|
||||
# text_to_speech(response["transcript"], sound_file_path)
|
||||
# upload_file_firebase(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
||||
# response["audio_file"] = firebase_file_path
|
||||
return response
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
@app.route('/writing_task1', methods=['POST'])
|
||||
@jwt_required()
|
||||
@@ -44,7 +120,7 @@ def grade_writing_task_1():
|
||||
messages = get_grading_messages(QuestionType.WRITING_TASK_1, question, answer, context)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(messages, token_count, GRADING_FIELDS, GRADING_TEMPERATURE)
|
||||
response = make_openai_call(GPT_3_5_TURBO, messages, token_count, GRADING_FIELDS, GRADING_TEMPERATURE)
|
||||
return response
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
@@ -59,7 +135,7 @@ def grade_writing_task_2():
|
||||
messages = get_grading_messages(QuestionType.WRITING_TASK_2, question, answer)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(messages, token_count, GRADING_FIELDS, GRADING_TEMPERATURE)
|
||||
response = make_openai_call(GPT_3_5_TURBO, messages, token_count, GRADING_FIELDS, GRADING_TEMPERATURE)
|
||||
return response
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
@@ -72,7 +148,7 @@ def get_writing_task_2_question():
|
||||
messages = get_question_gen_messages(QuestionType.WRITING_TASK_2)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(messages, token_count, GEN_FIELDS, GEN_QUESTION_TEMPERATURE)
|
||||
response = make_openai_call(GPT_3_5_TURBO, messages, token_count, GEN_FIELDS, GEN_QUESTION_TEMPERATURE)
|
||||
return response
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
@@ -93,7 +169,7 @@ def grade_speaking_task_1():
|
||||
messages = get_grading_messages(QuestionType.SPEAKING_1, question, answer)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(messages, token_count, GRADING_FIELDS, GRADING_TEMPERATURE)
|
||||
response = make_openai_call(GPT_3_5_TURBO, messages, token_count, GRADING_FIELDS, GRADING_TEMPERATURE)
|
||||
os.remove(sound_file_name)
|
||||
return response
|
||||
except Exception as e:
|
||||
@@ -107,7 +183,7 @@ def get_speaking_task_1_question():
|
||||
messages = get_question_gen_messages(QuestionType.SPEAKING_1)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(messages, token_count, GEN_FIELDS, GEN_QUESTION_TEMPERATURE)
|
||||
response = make_openai_call(GPT_3_5_TURBO, messages, token_count, GEN_FIELDS, GEN_QUESTION_TEMPERATURE)
|
||||
return response
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
@@ -128,7 +204,7 @@ def grade_speaking_task_2():
|
||||
messages = get_grading_messages(QuestionType.SPEAKING_2, question, answer)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(messages, token_count, GRADING_FIELDS, GRADING_TEMPERATURE)
|
||||
response = make_openai_call(GPT_3_5_TURBO, messages, token_count, GRADING_FIELDS, GRADING_TEMPERATURE)
|
||||
os.remove(sound_file_name)
|
||||
return response
|
||||
except Exception as e:
|
||||
@@ -142,7 +218,7 @@ def get_speaking_task_2_question():
|
||||
messages = get_question_gen_messages(QuestionType.SPEAKING_2)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
response = make_openai_call(messages, token_count, GEN_FIELDS, GEN_QUESTION_TEMPERATURE)
|
||||
response = make_openai_call(GPT_3_5_TURBO, messages, token_count, GEN_FIELDS, GEN_QUESTION_TEMPERATURE)
|
||||
return response
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
@@ -2,6 +2,10 @@ from enum import Enum
|
||||
|
||||
|
||||
class QuestionType(Enum):
|
||||
LISTENING_SECTION_1 = "Listening Section 1"
|
||||
LISTENING_SECTION_2 = "Listening Section 2"
|
||||
LISTENING_SECTION_3 = "Listening Section 3"
|
||||
LISTENING_SECTION_4 = "Listening Section 4"
|
||||
WRITING_TASK_1 = "Writing Task 1"
|
||||
WRITING_TASK_2 = "Writing Task 2"
|
||||
SPEAKING_1 = "Speaking Task Part 1"
|
||||
@@ -172,7 +176,93 @@ def get_grading_messages(question_type: QuestionType, question: str, answer: str
|
||||
|
||||
|
||||
def get_question_gen_messages(question_type: QuestionType):
|
||||
if QuestionType.WRITING_TASK_2 == question_type:
|
||||
if QuestionType.LISTENING_SECTION_1 == question_type:
|
||||
return [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "You are a IELTS program that generates questions for the exams.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Provide me with a transcript similar to the ones in ielts exam Listening Section 1. "
|
||||
"Create an engaging transcript simulating a conversation related to a unique type of service "
|
||||
"that requires getting the customer's details. Make sure to include specific details "
|
||||
"and descriptions to bring"
|
||||
"the scenario to life. After the transcript, please "
|
||||
"generate a 'form like' fill in the blanks exercise with 6 form fields (ex: name, date of birth)"
|
||||
" to fill related to the customer's details. Finally, "
|
||||
"provide the answers for the exercise. The response must be a json following this format: "
|
||||
"{ 'type': '<type of registration (ex: hotel, gym, english course, etc)>', "
|
||||
"'transcript': '<transcript of just the conversation about a registration of some sort, "
|
||||
"identify the person talking in each speech line>', "
|
||||
"'exercise': { 'form field': { '1': '<form field 1>', '2': '<form field 2>', "
|
||||
"'3': '<form field 3>', '4': '<form field 4>', "
|
||||
"'5': '<form field 5>', '6': '<form field 5>' }, "
|
||||
"'answers': {'1': '<answer to fill blank space in form field 1>', '2': '<answer to fill blank "
|
||||
"space in form field 2>', '3': '<answer to fill blank space in form field 3>', "
|
||||
"'4': '<answer to fill blank space in form field 4>', '5': '<answer to fill blank space in form field 5>',"
|
||||
" '6': '<answer to fill blank space in form field 6>'}}}",
|
||||
}
|
||||
]
|
||||
elif QuestionType.LISTENING_SECTION_2 == question_type:
|
||||
return [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "You are a IELTS program that generates questions for the exams.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Provide me with a transcript similar to the ones in ielts exam Listening section 2. After the transcript, please "
|
||||
"generate a fill in the blanks exercise with 6 statements related to the text content. Finally, "
|
||||
"provide the answers for the exercise. The response must be a json following this format: "
|
||||
"{ 'transcript': 'transcript about some subject', 'exercise': { 'statements': { '1': 'statement 1 "
|
||||
"with a blank space to fill', '2': 'statement 2 with a blank space to fill', '3': 'statement 3 with a "
|
||||
"blank space to fill', '4': 'statement 4 with a blank space to fill', '5': 'statement 5 with a blank "
|
||||
"space to fill', '6': 'statement 6 with a blank space to fill' }, "
|
||||
"'answers': {'1': 'answer to fill blank space in statement 1', '2': 'answer to fill blank "
|
||||
"space in statement 2', '3': 'answer to fill blank space in statement 3', "
|
||||
"'4': 'answer to fill blank space in statement 4', '5': 'answer to fill blank space in statement 5',"
|
||||
" '6': 'answer to fill blank space in statement 6'}}}",
|
||||
}
|
||||
]
|
||||
elif QuestionType.LISTENING_SECTION_3 == question_type:
|
||||
return [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "You are a IELTS program that generates questions for the exams.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Provide me with a transcript similar to the ones in ielts exam Listening section 3. After the transcript, please "
|
||||
"generate 4 multiple choice questions related to the text content. Finally, "
|
||||
"provide the answers for the exercise. The response must be a json following this format: "
|
||||
"{ 'transcript': 'generated transcript similar to the ones in ielts exam Listening section 3', "
|
||||
"'exercise': { 'questions': [ { 'question': "
|
||||
"'question 1', 'options': ['option 1', 'option 2', 'option 3', 'option 4'], 'answer': 1}, "
|
||||
"{'question': 'question 2', 'options': ['option 1', 'option 2', 'option 3', 'option 4'], "
|
||||
"'answer': 3}, {'question': 'question 3', 'options': ['option 1', 'option 2', 'option 3', "
|
||||
"'option 4'], 'answer': 0}, {'question': 'question 4', 'options': ['option 1', 'option 2', "
|
||||
"'option 3', 'option 4'], 'answer': 2}]}}",
|
||||
}
|
||||
]
|
||||
elif QuestionType.LISTENING_SECTION_4 == question_type:
|
||||
return [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "You are a IELTS program that generates questions for the exams.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Provide me with a transcript similar to the ones in ielts exam Listening section 4. After the transcript, please "
|
||||
"generate 4 completion-type questions related to the text content to complete with 1 word. Finally, "
|
||||
"provide the answers for the exercise. The response must be a json following this format: "
|
||||
"{ 'transcript': 'generated transcript similar to the ones in ielts exam Listening section 4', "
|
||||
"'exercise': [ { 'question': 'question 1', 'answer': 'answer 1'}, "
|
||||
"{'question': 'question 2', 'answer': 'answer 2'}, {'question': 'question 3', 'answer': 'answer 3'}, "
|
||||
"{'question': 'question 4', 'answer': 'answer 4'}]}",
|
||||
}
|
||||
]
|
||||
elif QuestionType.WRITING_TASK_2 == question_type:
|
||||
return [
|
||||
{
|
||||
"role": "user",
|
||||
|
||||
@@ -9,7 +9,18 @@ def download_firebase_file(bucket_name, source_blob_name, destination_file_name)
|
||||
print(f"File downloaded to {destination_file_name}")
|
||||
return destination_file_name
|
||||
|
||||
|
||||
def upload_file_firebase(bucket_name, destination_blob_name, source_file_name):
|
||||
# Uploads a file to Firebase Storage.
|
||||
storage_client = storage.Client()
|
||||
bucket = storage_client.bucket(bucket_name)
|
||||
try:
|
||||
blob = bucket.blob(destination_blob_name)
|
||||
blob.upload_from_filename(source_file_name)
|
||||
print(f"File uploaded to {destination_blob_name}")
|
||||
return True
|
||||
except Exception as e:
|
||||
print("Error uploading file to Google Cloud Storage:", e)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16,22 +16,25 @@ FREQUENCY_PENALTY = 0.5
|
||||
TRY_LIMIT = 1
|
||||
|
||||
try_count = 0
|
||||
def process_response(input_string):
|
||||
def process_response(input_string, quotation_check_field):
|
||||
if '{' in input_string:
|
||||
try:
|
||||
# Find the index of the first occurrence of '{'
|
||||
index = input_string.index('{')
|
||||
# Extract everything after the first '{' (inclusive)
|
||||
result = input_string[index:]
|
||||
if re.search(r"'" + quotation_check_field + "':\s*'(.*?)'", result):
|
||||
parsed_string = result.replace("\"", "\\\"")
|
||||
pattern = r"(?<!\w)'|'(?!\w)"
|
||||
parsed_string = re.sub(pattern, '"', parsed_string)
|
||||
parsed_string = parsed_string.replace("\\\"", "'")
|
||||
parsed_string = parsed_string.replace("\n\n", " ")
|
||||
|
||||
parsed_string = result.replace("\"", "\\\"")
|
||||
pattern = r"(?<!\w)'|'(?!\w)"
|
||||
parsed_string = re.sub(pattern, '"', parsed_string)
|
||||
parsed_string = parsed_string.replace("\\\"", "'")
|
||||
parsed_string = parsed_string.replace("\n\n", " ")
|
||||
|
||||
json_obj = json.loads(parsed_string)
|
||||
return json_obj
|
||||
json_obj = json.loads(parsed_string)
|
||||
return json_obj
|
||||
else:
|
||||
json_obj = json.loads(result)
|
||||
return json_obj
|
||||
except json.JSONDecodeError:
|
||||
print("Invalid JSON string!")
|
||||
else:
|
||||
@@ -40,20 +43,20 @@ def process_response(input_string):
|
||||
def check_fields(obj, fields):
|
||||
return all(field in obj for field in fields)
|
||||
|
||||
def make_openai_call(messages, token_count, fields_to_check, temperature):
|
||||
def make_openai_call(model, messages, token_count, fields_to_check, temperature):
|
||||
global try_count
|
||||
result = openai.ChatCompletion.create(
|
||||
model="gpt-3.5-turbo",
|
||||
model=model,
|
||||
max_tokens=int(MAX_TOKENS - token_count - 300),
|
||||
temperature=float(temperature),
|
||||
top_p=float(TOP_P),
|
||||
frequency_penalty=float(FREQUENCY_PENALTY),
|
||||
messages=messages
|
||||
)
|
||||
processed_response = process_response(result["choices"][0]["message"]["content"])
|
||||
processed_response = process_response(result["choices"][0]["message"]["content"], fields_to_check[0])
|
||||
if check_fields(processed_response, fields_to_check) is False and try_count < TRY_LIMIT:
|
||||
try_count = try_count + 1
|
||||
return make_openai_call(messages, token_count, fields_to_check, temperature)
|
||||
return make_openai_call(model, messages, token_count, fields_to_check, temperature)
|
||||
elif try_count >= TRY_LIMIT:
|
||||
try_count = 0
|
||||
return result["choices"][0]["message"]["content"]
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import whisper
|
||||
import os
|
||||
import gtts
|
||||
from playsound import playsound
|
||||
|
||||
def speech_to_text(file_path):
|
||||
if os.path.exists(file_path):
|
||||
@@ -9,3 +11,7 @@ def speech_to_text(file_path):
|
||||
else:
|
||||
print("File not found:", file_path)
|
||||
raise Exception("File " + file_path + " not found.")
|
||||
|
||||
def text_to_speech(text: str, file_name: str):
|
||||
tts = gtts.gTTS(text)
|
||||
tts.save(file_name)
|
||||
133
listening_playground.py
Normal file
133
listening_playground.py
Normal file
@@ -0,0 +1,133 @@
|
||||
import streamlit as st
|
||||
import openai
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
openai.api_key = os.getenv("OPENAI_API_KEY")
|
||||
|
||||
|
||||
def generate_summarizer(
|
||||
max_tokens,
|
||||
temperature,
|
||||
top_p,
|
||||
frequency_penalty,
|
||||
question_type,
|
||||
question,
|
||||
answer
|
||||
):
|
||||
res = openai.ChatCompletion.create(
|
||||
model="gpt-3.5-turbo",
|
||||
max_tokens=int(max_tokens),
|
||||
temperature=float(temperature),
|
||||
top_p=float(top_p),
|
||||
frequency_penalty=float(frequency_penalty),
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "You are a IELTS program that generates questions for the exams.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Provide me with a transcript for ielts exam Listening section 2. After the transcript, "
|
||||
"please generate a fill in the blanks exercise with 6 statements related to the text content. "
|
||||
"Finally, provide the answers for the exercise. The response must be a json following this format: "
|
||||
"{ 'transcript': 'Audio Transcript: Good morning, and welcome to today's lecture on the history of "
|
||||
"photography. Today, we will explore the evolution of photography from its early beginnings to the "
|
||||
"digital age. In the early 19th century, the invention of the camera obscura marked the first "
|
||||
"step towards capturing images. This precursor to the modern camera allowed artists and scientists "
|
||||
"to project images onto a surface, tracing their outlines. However, it wasn't until the 1820s that "
|
||||
"the first permanent photograph was produced. Louis Daguerre, a French inventor, introduced the "
|
||||
"daguerreotype process in 1839. This revolutionary technique involved exposing a chemically treated "
|
||||
"metal plate to light, resulting in a unique and highly detailed image. The daguerreotype became "
|
||||
"immensely popular, paving the way for the widespread adoption of photography. In the late 19th "
|
||||
"century, the development of flexible film made photography more accessible. George Eastman's "
|
||||
"introduction of roll film and the Kodak Brownie camera in 1900 revolutionized photography, "
|
||||
"allowing anyone to capture moments without the need for complex equipment.The 20th century "
|
||||
"witnessed significant advancements in photographic technology. The introduction of 35mm film "
|
||||
"and the Leica camera in the 1920s made photography more portable and versatile. This led to "
|
||||
"the emergence of photojournalism as a powerful medium for documenting historical events.With "
|
||||
"the advent of digital technology in the late 20th century, photography underwent a transformative "
|
||||
"shift. Digital cameras eliminated the need for film, enabling instant image capture, storage, "
|
||||
"and manipulation. The accessibility of digital photography has revolutionized the way we take, "
|
||||
"share, and edit photographs. In conclusion, the history of photography is a fascinating journey "
|
||||
"marked by constant innovation and technological advancements. From the camera obscura to digital "
|
||||
"cameras, photography has evolved into a powerful and ubiquitous form of visual communication.",
|
||||
"exercise": {
|
||||
"statements": [
|
||||
"The camera obscura allowed artists and scientists to project images onto a surface, enabling them to trace their __1__.",
|
||||
"Louis Daguerre introduced the __2__ process in 1839, which involved exposing a chemically treated metal plate to __3__.",
|
||||
"The __4__ became popular in the 19th century and played a significant role in the widespread adoption of photography.",
|
||||
"George Eastman's introduction of roll film and the Kodak Brownie camera in 1900 made photography more __5__.",
|
||||
"The __6__ and the Leica camera introduced in the 1920s revolutionized photography and led to the emergence of photojournalism."
|
||||
],
|
||||
"answers": {
|
||||
"1": "outlines",
|
||||
"2": "daguerreotype",
|
||||
"3": "light",
|
||||
"4": "daguerreotype",
|
||||
"5": "accessible",
|
||||
"6": "35mm film"
|
||||
}
|
||||
}
|
||||
}",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Don't give explanations for the grades, just provide the json with the grades.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"Evaluate this answer according to ielts grading system: {answer}",
|
||||
},
|
||||
],
|
||||
)
|
||||
return res["choices"][0]["message"]["content"]
|
||||
|
||||
|
||||
# Set the application title
|
||||
st.title("GPT-3.5 IELTS Examiner")
|
||||
|
||||
# qt_col, q_col = st.columns(2)
|
||||
|
||||
# Selection box to select the question type
|
||||
# with qt_col:
|
||||
question_type = st.selectbox(
|
||||
"What is the question type?",
|
||||
(
|
||||
"Writing Task 2",
|
||||
),
|
||||
)
|
||||
|
||||
# Provide the input area for question to be answered
|
||||
# with q_col:
|
||||
question = st.text_area("Enter the question:", height=100)
|
||||
|
||||
# Provide the input area for text to be summarized
|
||||
answer = st.text_area("Enter the answer:", height=100)
|
||||
|
||||
# Initiate two columns for section to be side-by-side
|
||||
# col1, col2 = st.columns(2)
|
||||
|
||||
# Slider to control the model hyperparameter
|
||||
# with col1:
|
||||
token = st.slider("Token", min_value=0.0,
|
||||
max_value=2000.0, value=1000.0, step=1.0)
|
||||
temp = st.slider("Temperature", min_value=0.0,
|
||||
max_value=1.0, value=0.7, step=0.01)
|
||||
top_p = st.slider("Top_p", min_value=0.0, max_value=1.0, value=0.9, step=0.01)
|
||||
f_pen = st.slider("Frequency Penalty", min_value=-1.0,
|
||||
max_value=1.0, value=0.5, step=0.01)
|
||||
|
||||
# Showing the current parameter used for the model
|
||||
# with col2:
|
||||
with st.expander("Current Parameter"):
|
||||
st.write("Current Token :", token)
|
||||
st.write("Current Temperature :", temp)
|
||||
st.write("Current Nucleus Sampling :", top_p)
|
||||
st.write("Current Frequency Penalty :", f_pen)
|
||||
|
||||
# Creating button for execute the text summarization
|
||||
if st.button("Grade"):
|
||||
st.write(generate_summarizer(token, temp, top_p,
|
||||
f_pen, question_type, question, answer))
|
||||
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
942
testing.py
942
testing.py
@@ -1,37 +1,911 @@
|
||||
from functools import reduce
|
||||
from helper.token_counter import count_tokens
|
||||
import os
|
||||
import uuid
|
||||
|
||||
# model = whisper.load_model("base")
|
||||
# file_path = "audio-samples/mynameisjeff.wav"
|
||||
# audio_file = AudioSegment.from_file(file_path)
|
||||
# if os.path.exists(file_path):
|
||||
# result = model.transcribe(file_path, fp16=False, language='English', verbose=True)
|
||||
# print(result["text"])
|
||||
# else:
|
||||
# print("File not found:", file_path)
|
||||
import firebase_admin
|
||||
from firebase_admin import credentials, firestore
|
||||
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "You are a IELTS examiner.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"The question you have to grade is of type and is the following: ",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Please provide a JSON object response with the overall grade and breakdown grades, "
|
||||
"formatted as follows: {'overall': 7.0, 'task_response': {'Task Achievement': 8.0, "
|
||||
"'Coherence and Cohesion': 6.5, 'Lexical Resource': 7.5, 'Grammatical Range and Accuracy': "
|
||||
"6.0}}",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"Evaluate this answer according to ielts grading system:",
|
||||
},
|
||||
]
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
from dotenv import load_dotenv
|
||||
|
||||
print(token_count)
|
||||
load_dotenv()
|
||||
|
||||
# Initialize Firebase Admin SDK
|
||||
cred = credentials.Certificate(os.getenv("GOOGLE_APPLICATION_CREDENTIALS"))
|
||||
|
||||
firebase_admin.initialize_app(cred)
|
||||
|
||||
reading_to_insert_1 = {
|
||||
"exercises": [
|
||||
{
|
||||
"allowRepetition": True,
|
||||
"id": str(uuid.uuid4()),
|
||||
"prompt": "Complete the summary below. Click a blank to select the corresponding word(s) for it.\\nThere are "
|
||||
"more words than spaces so you will not use them all. You may use any of the words more than once.",
|
||||
"solutions": [
|
||||
{
|
||||
"id": "1",
|
||||
"solution": "clean"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"solution": "fossil"
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
"solution": "sunlight"
|
||||
},
|
||||
{
|
||||
"id": "4",
|
||||
"solution": "alternative"
|
||||
},
|
||||
{
|
||||
"id": "5",
|
||||
"solution": "solar"
|
||||
},
|
||||
{
|
||||
"id": "6",
|
||||
"solution": "wind farms"
|
||||
},
|
||||
{
|
||||
"id": "7",
|
||||
"solution": "source"
|
||||
},
|
||||
{
|
||||
"id": "8",
|
||||
"solution": "flowing water"
|
||||
}
|
||||
],
|
||||
"text": "In recent years, the transition to {{1}} energy sources has surged, driven by growing concerns about "
|
||||
"{{2}} fuels and their impact on climate change. Renewable options, including {{3}}, wind, and water,"
|
||||
" are gaining momentum as a cleaner {{4}} to conventional energy production. Solar panels, harnessing {{5}} "
|
||||
"energy, are becoming more accessible, while wind turbines in {{6}} are providing a scalable and sustainable "
|
||||
"{{7}} of power. Moreover, hydropower, derived from {{8}}, contributes to the renewable energy landscape, "
|
||||
"offering a multifaceted approach to combat environmental challenges.",
|
||||
"type": "fillBlanks",
|
||||
"words": ["energy", "fossil", "alternative", "transition", "wind farms", "source",
|
||||
"contributes", "flowing water", "surged", "momentum", "scalable", "solar", "accessible",
|
||||
"climate",
|
||||
"environmental", "renewable", "impact", "clean", "options", "challenges"]
|
||||
|
||||
},
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prompt": "Select the appropriate option.",
|
||||
"questions": [
|
||||
{
|
||||
"id": 1,
|
||||
"options": [
|
||||
{
|
||||
"id": "A",
|
||||
"text": "Economic benefits"
|
||||
},
|
||||
{
|
||||
"id": "B",
|
||||
"text": "Government regulations"
|
||||
},
|
||||
{
|
||||
"id": "C",
|
||||
"text": "Concerns about climate change"
|
||||
},
|
||||
{
|
||||
"id": "D",
|
||||
"text": "Technological advancement"
|
||||
}
|
||||
],
|
||||
"prompt": "What is the main reason for the shift towards renewable energy sources?",
|
||||
"solution": "C",
|
||||
"variant": "text",
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"options": [
|
||||
{
|
||||
"id": "A",
|
||||
"text": "Wind"
|
||||
},
|
||||
{
|
||||
"id": "B",
|
||||
"text": "Coal"
|
||||
},
|
||||
{
|
||||
"id": "C",
|
||||
"text": "Sunlight"
|
||||
},
|
||||
{
|
||||
"id": "D",
|
||||
"text": "Water"
|
||||
}
|
||||
],
|
||||
"prompt": "Which of the following sources is NOT mentioned as a renewable energy source?",
|
||||
"solution": "B",
|
||||
"variant": "text",
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"options": [
|
||||
{
|
||||
"id": "A",
|
||||
"text": "It generates a lot of waste"
|
||||
},
|
||||
{
|
||||
"id": "B",
|
||||
"text": "It produces greenhouse gases"
|
||||
},
|
||||
{
|
||||
"id": "C",
|
||||
"text": "It has no emissions"
|
||||
},
|
||||
{
|
||||
"id": "D",
|
||||
"text": "It requires large land areas"
|
||||
}
|
||||
],
|
||||
"prompt": "What advantage does solar energy have in terms of environmental impact?",
|
||||
"solution": "C",
|
||||
"variant": "text",
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"options": [
|
||||
{
|
||||
"id": "A",
|
||||
"text": "By burning fossil fuels"
|
||||
},
|
||||
{
|
||||
"id": "B",
|
||||
"text": "By harnessing wind's kinetic energy"
|
||||
},
|
||||
{
|
||||
"id": "C",
|
||||
"text": "By using sunlight"
|
||||
},
|
||||
{
|
||||
"id": "D",
|
||||
"text": "By utilizing underground heat"
|
||||
}
|
||||
],
|
||||
"prompt": "How do wind turbines generate electricity?",
|
||||
"solution": "B",
|
||||
"variant": "text",
|
||||
}
|
||||
],
|
||||
"type": "multipleChoice",
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 20,
|
||||
"text": {
|
||||
"content": "In recent years, there has been a significant shift towards renewable energy sources as societies "
|
||||
"strive to reduce their dependence on fossil fuels and combat the effects of climate change. Renewable "
|
||||
"energy, derived from sources such as sunlight, wind, and water, offers a promising alternative to "
|
||||
"traditional energy generation methods.\\nSolar power, harnessed from the sun's rays, has gained immense "
|
||||
"popularity. Photovoltaic cells, commonly known as solar panels, capture sunlight and convert it into "
|
||||
"electricity. This technology has become more efficient and affordable, contributing to a growing number "
|
||||
"of solar installations on rooftops and solar farms. Solar energy not only reduces greenhouse gas "
|
||||
"emissions but also grants individuals and businesses the ability to generate their own power.\\nSimilarly, "
|
||||
"wind energy has emerged as a reliable and clean source of electricity. Wind turbines, often found in "
|
||||
"wind farms, harness the kinetic energy of moving air to turn blades and generate electricity. These "
|
||||
"structures are strategically placed in areas with consistent wind patterns, contributing to the overall "
|
||||
"energy grid. Wind power has the advantage of scalability, with both small and large installations being "
|
||||
"feasible options.\\nHydropower, generated from flowing water in rivers and dams, is another vital renewable "
|
||||
"energy source. The force of water is used to turn turbines, which then produce electricity. While hydropower "
|
||||
"has a long history, advancements in technology have led to more efficient and environmentally friendly "
|
||||
"designs. However, the construction of dams for hydropower can have significant ecological and social "
|
||||
"impacts, requiring careful consideration.\\nGeothermal energy, originating from the Earth's heat, is "
|
||||
"also gaining attention. This energy source is harnessed through underground steam and hot water reservoirs, "
|
||||
"which are tapped for electricity generation and heating. Geothermal power plants have a relatively small "
|
||||
"environmental footprint and provide a consistent source of energy, making them a viable option in regions "
|
||||
"with suitable geological conditions.\\nIn conclusion, the transition to renewable energy sources marks a "
|
||||
"pivotal step towards sustainable and environmentally conscious energy generation. Solar, wind, hydropower, "
|
||||
"and geothermal energy offer diverse options that can collectively contribute to reducing carbon emissions "
|
||||
"and combating climate change. As technology continues to evolve and economies adapt, the potential for "
|
||||
"widespread adoption of renewable energy remains promising.",
|
||||
"title": "The Rise of Renewable Energy"
|
||||
},
|
||||
"type": "academic"
|
||||
}
|
||||
reading_to_insert_2 = {
|
||||
"exercises": [
|
||||
{
|
||||
"allowRepetition": True,
|
||||
"id": str(uuid.uuid4()),
|
||||
"prompt": "Complete the summary below. Click a blank to select the corresponding word(s) for it.\\nThere are "
|
||||
"more words than spaces so you will not use them all. You may use any of the words more than once.",
|
||||
"solutions": [
|
||||
{
|
||||
"id": "1",
|
||||
"solution": "Earth"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"solution": "ecosystems"
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
"solution": "biodiversity"
|
||||
},
|
||||
{
|
||||
"id": "4",
|
||||
"solution": "pollination"
|
||||
},
|
||||
{
|
||||
"id": "5",
|
||||
"solution": "genetic"
|
||||
},
|
||||
{
|
||||
"id": "6",
|
||||
"solution": "protection"
|
||||
},
|
||||
{
|
||||
"id": "7",
|
||||
"solution": "healthy"
|
||||
},
|
||||
{
|
||||
"id": "8",
|
||||
"solution": "sustainable"
|
||||
}
|
||||
],
|
||||
"text": "Biodiversity, the range of life forms on {{1}}, is essential for ecosystem health and stability. "
|
||||
"Interactions among species in {{2}} support various ecological processes. However, human activities "
|
||||
"like habitat destruction and pollution threaten {{3}}, impacting natural systems and human well-being. "
|
||||
"Ecosystems, with species adapted over time, perform vital functions such as nutrient cycling and {{4}}. "
|
||||
"The loss of biodiversity disrupts these processes, affecting ecosystem stability. Preserving {{5}} diversity "
|
||||
"is crucial for disease resilience and adaptation. Addressing biodiversity decline requires habitat {{6}}, "
|
||||
"sustainable practices, and awareness. In conclusion, safeguarding biodiversity is vital for {{7}} ecosystems "
|
||||
"and human societies, demanding proactive conservation and {{8}} efforts.",
|
||||
"type": "fillBlanks",
|
||||
"words": ["Earth", "fossil", "alternative", "ecosystems", "healthy", "sustainable",
|
||||
"contributes", "genetic", "surged", "pollination", "scalable", "solar", "accessible",
|
||||
"climate", "environmental", "biodiversity", "impact", "protection", "options", "challenges"]
|
||||
|
||||
},
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"maxWords": 3,
|
||||
"prompt": "Answer the questions below.\\nChoose <b>NO MORE THAN THREE WORDS</b> from the passage for each answer.",
|
||||
"solutions": [
|
||||
{
|
||||
"id": 1,
|
||||
"options": ["Variety of life"]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"options": ["Maintains health"]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"options": ["Habitat destruction", "pollution", "climate change"]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"options": ["Deforestation", "overfishing"]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"options": ["Essential functions"]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"options": ["Pollination"]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"options": ["Disrupts relationships", "imbalances"]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"options": ["Unchecked population growth", "effects on vegetation"]
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"options": ["Diseases"]
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"options": ["Supports pollination"]
|
||||
},
|
||||
],
|
||||
"text": "What is biodiversity?{{1}}\\nHow does biodiversity impact ecosystems?{{2}}\\nWhat activities threaten "
|
||||
"biodiversity?{{3}}\\nName a human activity impacting biodiversity.{{4}}\nWhat functions do ecosystems "
|
||||
"perform?{{5}}\\nWhat do bees support?{{6}}\\nHow does biodiversity loss affect ecosystems?{{7}}\\nWhat "
|
||||
"can result from apex predator decline?{{8}}\\nWhat does genetic diversity buffer against?{{9}}\\nWhy "
|
||||
"is genetic diversity important?{{10}}",
|
||||
"type": "writeBlanks"
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 20,
|
||||
"text": {
|
||||
"content": "Biodiversity, the variety of life forms on Earth, plays a critical role in maintaining ecosystem health "
|
||||
"and stability. The interactions between different species within ecosystems create intricate networks "
|
||||
"that support various ecological processes. However, human activities such as habitat destruction, "
|
||||
"pollution, and climate change are placing immense pressure on biodiversity, leading to potential "
|
||||
"consequences for both natural systems and human well-being.\\nEcosystems are composed of a multitude "
|
||||
"of species that have evolved over millions of years, adapting to their environments and developing "
|
||||
"unique roles within their ecosystems. This diversity ensures that ecosystems can perform essential "
|
||||
"functions, such as nutrient cycling, pest control, and pollination. For instance, bees and other "
|
||||
"pollinators contribute to the reproduction of numerous plant species, thereby supporting food production "
|
||||
"for humans and other animals.\\nThe loss of biodiversity can disrupt these intricate relationships, "
|
||||
"leading to imbalances that reverberate throughout ecosystems. As species disappear, the stability of "
|
||||
"ecosystems may be compromised, and the services they provide can be compromised as well. For example, "
|
||||
"the decline of apex predators in a habitat can result in unchecked population growth of their prey, "
|
||||
"causing cascading effects on vegetation and other species.\\nBiodiversity is also vital for preserving "
|
||||
"genetic diversity within species. This diversity acts as a buffer against diseases, allowing some "
|
||||
"individuals to survive and reproduce when others succumb. Moreover, it enables species to adapt to "
|
||||
"changing environmental conditions over time. The genetic diversity of crops is especially crucial for "
|
||||
"ensuring food security and resilience in the face of changing climates and emerging diseases.\\nAddressing "
|
||||
"the decline in biodiversity requires a multifaceted approach. Conservation efforts should focus on "
|
||||
"protecting and restoring habitats, implementing sustainable land-use practices, and reducing pollution. "
|
||||
"In addition, raising public awareness about the value of biodiversity and its role in human well-being "
|
||||
"is essential. International cooperation is also necessary, as many species and ecosystems span multiple "
|
||||
"countries.\\nIn conclusion, biodiversity is a cornerstone of healthy ecosystems and is closely intertwined "
|
||||
"with human societies. As we recognize the intricate connections between species and ecosystems, it becomes "
|
||||
"imperative to take proactive steps to safeguard biodiversity for current and future generations. This "
|
||||
"requires a commitment to sustainable practices and a collective effort to protect the diverse web of "
|
||||
"life on our planet.",
|
||||
"title": "Biodiversity and Ecosystem Health"
|
||||
},
|
||||
"type": "academic"
|
||||
}
|
||||
|
||||
speaking_to_insert_1 = {
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prompts": [],
|
||||
"text": "Do you have any hobbies? If so, what are they?\\nHow did you become interested in your hobbies?\\nWhat"
|
||||
" do you enjoy the most about your hobbies?\\nDo you think hobbies are important for people? Why or"
|
||||
" why not?",
|
||||
"title": "Hobbies",
|
||||
"type": "speaking"
|
||||
},
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prompts": [
|
||||
"Describe the location and setting of the place.",
|
||||
"What natural features or attractions were present?",
|
||||
"How did you feel during your visit to this place?",
|
||||
"Explain why you found this place to be beautiful and memorable."
|
||||
],
|
||||
"text": "Describe a place you visited that has a lot of natural beauty.",
|
||||
"title": "Place with natural beauty",
|
||||
"type": "speaking"
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 5,
|
||||
"module": "speaking"
|
||||
}
|
||||
speaking_to_insert_2 = {
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prompts": [],
|
||||
"text": "What does your typical day look like?\\nAre there any activities you do regularly in the mornings?\\n"
|
||||
"How do you usually spend your evenings after work or school?\\nIs there anything you'd like to change "
|
||||
"about your daily routine? Why?",
|
||||
"title": "Daily Routine",
|
||||
"type": "speaking"
|
||||
},
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prompts": [
|
||||
"Introduce the title and author of the book.",
|
||||
"Describe the plot or content of the book briefly.",
|
||||
"Explain why the book had a significant impact on you.",
|
||||
"Discuss how the book influenced your thoughts or actions."
|
||||
],
|
||||
"text": "Talk about a book that had a significant impact on you.",
|
||||
"title": "Impactful book",
|
||||
"type": "speaking"
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 5,
|
||||
"module": "speaking"
|
||||
}
|
||||
speaking_to_insert_3 = {
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prompts": [],
|
||||
"text": "Have you traveled to any foreign countries? Which ones?\\nWhat do you like about traveling?\\nHow do "
|
||||
"you decide on your travel destinations?\\nCan you share a memorable experience from one of your trips?",
|
||||
"title": "travel",
|
||||
"type": "speaking"
|
||||
},
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prompts": [
|
||||
"Explain the situation or context where you had to make a quick decision.",
|
||||
"What factors influenced your decision-making process?",
|
||||
"How did you feel about making the decision quickly?",
|
||||
"Reflect on the outcome of your decision and what you learned from it."
|
||||
],
|
||||
"text": "Describe a time when you had to make a decision quickly.",
|
||||
"title": "Quick decision",
|
||||
"type": "speaking"
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 5,
|
||||
"module": "speaking"
|
||||
}
|
||||
|
||||
writing_to_insert_1 = {
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prefix": "You should spend about 40 minutes on this task.\nPresent a written argument or case to an educated "
|
||||
"reader with no specialist knowledge of the following topic:",
|
||||
"prompt": "Some people believe that technology has made communication between individuals less personal and "
|
||||
"more impersonal. Others argue that technology has improved communication by making it more accessible. "
|
||||
"Discuss both viewpoints and give your own opinion.",
|
||||
"suffix": "You should write at least 250 words.\nUse your own ideas, knowledge and experience and support "
|
||||
"your arguments with examples and relevant evidence.",
|
||||
"type": "writing",
|
||||
"wordCounter": {
|
||||
"limit": 250,
|
||||
"type": "min"
|
||||
}
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 40,
|
||||
"module": "writing",
|
||||
"task": "2"
|
||||
}
|
||||
writing_to_insert_2 = {
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prefix": "You should spend about 40 minutes on this task.\nPresent a written argument or case to an educated "
|
||||
"reader with no specialist knowledge of the following topic:",
|
||||
"prompt": "Some people think that the best way to reduce crime is to give longer prison sentences. Others, "
|
||||
"however, believe there are better alternatives for reducing crime. Discuss both sides and give "
|
||||
"your own opinion.",
|
||||
"suffix": "You should write at least 250 words.\nUse your own ideas, knowledge and experience and support "
|
||||
"your arguments with examples and relevant evidence.",
|
||||
"type": "writing",
|
||||
"wordCounter": {
|
||||
"limit": 250,
|
||||
"type": "min"
|
||||
}
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 40,
|
||||
"module": "writing",
|
||||
"task": "2"
|
||||
}
|
||||
writing_to_insert_3 = {
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prefix": "You should spend about 40 minutes on this task.\nPresent a written argument or case to an educated "
|
||||
"reader with no specialist knowledge of the following topic:",
|
||||
"prompt": "In many countries, children are engaged in part-time jobs alongside their studies. What are the "
|
||||
"advantages and disadvantages of this trend? Give your opinion and support it with relevant examples.",
|
||||
"suffix": "You should write at least 250 words.\nUse your own ideas, knowledge and experience and support "
|
||||
"your arguments with examples and relevant evidence.",
|
||||
"type": "writing",
|
||||
"wordCounter": {
|
||||
"limit": 250,
|
||||
"type": "min"
|
||||
}
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 40,
|
||||
"module": "writing",
|
||||
"task": "2"
|
||||
}
|
||||
writing_to_insert_4 = {
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prefix": "You should spend about 40 minutes on this task.\nPresent a written argument or case to an educated "
|
||||
"reader with no specialist knowledge of the following topic:",
|
||||
"prompt": "Some people argue that the government should provide free education at all levels. Others believe "
|
||||
"that individuals should be responsible for covering their educational expenses. Discuss both "
|
||||
"perspectives and support your opinion with examples.",
|
||||
"suffix": "You should write at least 250 words.\nUse your own ideas, knowledge and experience and support "
|
||||
"your arguments with examples and relevant evidence.",
|
||||
"type": "writing",
|
||||
"wordCounter": {
|
||||
"limit": 250,
|
||||
"type": "min"
|
||||
}
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 40,
|
||||
"module": "writing",
|
||||
"task": "2"
|
||||
}
|
||||
writing_to_insert_5 = {
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prefix": "You should spend about 40 minutes on this task.\nPresent a written argument or case to an educated "
|
||||
"reader with no specialist knowledge of the following topic:",
|
||||
"prompt": "Gender equality and women's rights have made significant progress in many parts of the world. "
|
||||
"However, some argue that there is still a long way to go in achieving true equality between men "
|
||||
"and women. Discuss both viewpoints and give your",
|
||||
"suffix": "You should write at least 250 words.\nUse your own ideas, knowledge and experience and support "
|
||||
"your arguments with examples and relevant evidence.",
|
||||
"type": "writing",
|
||||
"wordCounter": {
|
||||
"limit": 250,
|
||||
"type": "min"
|
||||
}
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 40,
|
||||
"module": "writing",
|
||||
"task": "2"
|
||||
}
|
||||
|
||||
listening_to_insert_1 = {
|
||||
"audio": {
|
||||
"repeatableTimes": 3,
|
||||
"source": "https://firebasestorage.googleapis.com/v0/b/mti-ielts.appspot.com/o/listening_recordings%2Fhotel_reservation.mp3?alt=media&token=7c6a88f9-b71a-41f4-8581-d9a0574f4d44"
|
||||
},
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"maxWords": 3,
|
||||
"prompt": "You will hear a conversation between a customer and a receptionist at a hotel. Complete the form "
|
||||
"below using no more than three words or a number.",
|
||||
"solutions": [
|
||||
{
|
||||
"id": 1,
|
||||
"solution": ["Johnson", "Mr. Johnson"]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"solution": ["15th of September", "fifteenth of September"]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"solution": ["Deluxe double room"]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"solution": ["Three nights", "3 nights"]
|
||||
},
|
||||
],
|
||||
"text": "Name of Customer:{{1}}\\nDate of Arrival:{{2}}\\nType of Room:{{3}}\\nNumber of Nights:{{4}}",
|
||||
"type": "writeBlanks"
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 7,
|
||||
"module": "listening",
|
||||
"section": 1
|
||||
}
|
||||
listening_to_insert_2 = {
|
||||
"audio": {
|
||||
"repeatableTimes": 3,
|
||||
"source": "https://firebasestorage.googleapis.com/v0/b/mti-ielts.appspot.com/o/listening_recordings%2Forientation_day.mp3?alt=media&token=b6e57cce-dbfa-48e4-a910-6d63726ee694"
|
||||
},
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"prompt": "Select the appropriate option.",
|
||||
"questions": [
|
||||
{
|
||||
"id": 1,
|
||||
"options": [
|
||||
{
|
||||
"id": "A",
|
||||
"text": "To introduce students to their courses."
|
||||
},
|
||||
{
|
||||
"id": "B",
|
||||
"text": "To help students find accommodation."
|
||||
},
|
||||
{
|
||||
"id": "C",
|
||||
"text": "To give students a campus tour."
|
||||
},
|
||||
{
|
||||
"id": "D",
|
||||
"text": "To provide information about extracurricular activities."
|
||||
}
|
||||
],
|
||||
"prompt": "What is the purpose of orientation day?",
|
||||
"solution": "C",
|
||||
"variant": "text",
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"options": [
|
||||
{
|
||||
"id": "A",
|
||||
"text": "Lecture Hall A"
|
||||
},
|
||||
{
|
||||
"id": "B",
|
||||
"text": "Student Union Building"
|
||||
},
|
||||
{
|
||||
"id": "C",
|
||||
"text": "Sports Complex"
|
||||
},
|
||||
{
|
||||
"id": "D",
|
||||
"text": "Library Auditorium"
|
||||
}
|
||||
],
|
||||
"prompt": "Where will the welcome speech take place?",
|
||||
"solution": "D",
|
||||
"variant": "text",
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"options": [
|
||||
{
|
||||
"id": "A",
|
||||
"text": "To introduce students to their courses."
|
||||
},
|
||||
{
|
||||
"id": "B",
|
||||
"text": "To provide information about extracurricular activities."
|
||||
},
|
||||
{
|
||||
"id": "C",
|
||||
"text": "To help students find accommodation."
|
||||
},
|
||||
{
|
||||
"id": "D",
|
||||
"text": "To address university administration concerns."
|
||||
}
|
||||
],
|
||||
"prompt": "What is the main goal of the welcome speech during orientation day?",
|
||||
"solution": "B",
|
||||
"variant": "text",
|
||||
}
|
||||
],
|
||||
"type": "multipleChoice",
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 7,
|
||||
"module": "listening",
|
||||
"section": 1
|
||||
}
|
||||
listening_to_insert_3 = {
|
||||
"audio": {
|
||||
"repeatableTimes": 3,
|
||||
"source": "https://firebasestorage.googleapis.com/v0/b/mti-ielts.appspot.com/o/listening_recordings%2Ftravel_agent.mp3?alt=media&token=e9bb9ba0-9a23-4d25-8e04-ce9b7dbc3021"
|
||||
},
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"allowRepetition": True,
|
||||
"options": [
|
||||
{
|
||||
"id": "A",
|
||||
"sentence": "Offers an opportunity to explore multiple cities at one fixed cost."
|
||||
},
|
||||
{
|
||||
"id": "B",
|
||||
"sentence": "Provides a leisurely way to see scenic landscapes along a river."
|
||||
},
|
||||
{
|
||||
"id": "C",
|
||||
"sentence": "Requires passengers to arrive at the airport well in advance."
|
||||
},
|
||||
{
|
||||
"id": "D",
|
||||
"sentence": "Allows travelers to follow their own route and schedule."
|
||||
},
|
||||
{
|
||||
"id": "E",
|
||||
"sentence": "Includes meals and onboard entertainment during the trip."
|
||||
}
|
||||
],
|
||||
"prompt": "Listen to a conversation between a travel agent and a customer regarding different travel options. "
|
||||
"Match the travel options with the appropriate descriptions.",
|
||||
"sentences": [
|
||||
{
|
||||
"id": "1",
|
||||
"sentence": "Train journey",
|
||||
"solution": "A"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"sentence": "Cruise",
|
||||
"solution": "C"
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
"sentence": "Flight",
|
||||
"solution": "D"
|
||||
},
|
||||
{
|
||||
"id": "4",
|
||||
"sentence": "Self-drive tour",
|
||||
"solution": "E"
|
||||
},
|
||||
{
|
||||
"id": "5",
|
||||
"sentence": "Bus tour",
|
||||
"solution": "B"
|
||||
}
|
||||
],
|
||||
"type": "matchSentences"
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 7,
|
||||
"module": "listening",
|
||||
"section": 1
|
||||
}
|
||||
|
||||
listening_section_2_to_insert_1 = {
|
||||
"audio": {
|
||||
"repeatableTimes": 3,
|
||||
"source": "https://firebasestorage.googleapis.com/v0/b/mti-ielts.appspot.com/o/listening_recordings%2Fmuseum_guide.mp3?alt=media&token=bfb9aea9-4006-4e11-af9a-1594232b4c20"
|
||||
},
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"maxWords": 3,
|
||||
"prompt": "You will hear a guide giving information about a museum exhibition. Complete the sentences using no more than three words or a number.",
|
||||
"solutions": [
|
||||
{
|
||||
"id": 1,
|
||||
"options": ["Art and Culture"]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"options": ["10 AM"]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"options": ["ID", "Card", "student ID", "senior citizen card"]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"options": ["day"]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"options": ["45"]
|
||||
}
|
||||
],
|
||||
"text": "The exhibition is titled \"Exploring the History of {{1}}.\"\\nThe museum opens at {{2}} on weekdays."
|
||||
"\\nVisitors can get a discount with a valid {{3}}.\\nThe museum offers a guided tour every {{4}}."
|
||||
"\\nThe guided tour lasts approximately {{5}} minutes.",
|
||||
"type": "writeBlanks"
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 7,
|
||||
"module": "listening",
|
||||
"section": 2
|
||||
}
|
||||
listening_section_2_to_insert_2 = {
|
||||
"audio": {
|
||||
"repeatableTimes": 3,
|
||||
"source": "https://firebasestorage.googleapis.com/v0/b/mti-ielts.appspot.com/o/listening_recordings%2Flecture_renewable_energy.mp3?alt=media&token=ccf7a033-c2a8-4c02-ae23-1375f6e94abe"
|
||||
},
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"maxWords": 2,
|
||||
"prompt": "Listen to a lecture about renewable energy sources. Answer the following questions in one or two words.",
|
||||
"solutions": [
|
||||
{
|
||||
"id": 1,
|
||||
"options": ["Solar power"]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"options": ["Wind energy"]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"options": ["Water heaters", "electric vehicles"]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"options": ["Low emissions"]
|
||||
}
|
||||
],
|
||||
"text": "What is the most common source of renewable energy worldwide?{{1}}\\nWhat do wind turbines convert "
|
||||
"into electricity?{{3}}\\nWhat can solar panels be used to power in homes?{{4}}"
|
||||
"\\nWhat is the benefit of geothermal energy in terms of emissions?{{5}}",
|
||||
"type": "writeBlanks"
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 7,
|
||||
"module": "listening",
|
||||
"section": 2
|
||||
}
|
||||
listening_section_2_to_insert_3 = {
|
||||
"audio": {
|
||||
"repeatableTimes": 3,
|
||||
"source": "https://firebasestorage.googleapis.com/v0/b/mti-ielts.appspot.com/o/listening_recordings%2Ffestival_presentation.mp3?alt=media&token=1602eebd-b292-49a3-93e5-5c0a003216a1"
|
||||
},
|
||||
"exercises": [
|
||||
{
|
||||
"id": str(uuid.uuid4()),
|
||||
"allowRepetition": True,
|
||||
"options": [
|
||||
{
|
||||
"id": "A",
|
||||
"sentence": "Cultural workshops"
|
||||
},
|
||||
{
|
||||
"id": "B",
|
||||
"sentence": "Street food vendors"
|
||||
},
|
||||
{
|
||||
"id": "C",
|
||||
"sentence": "Live music performances"
|
||||
},
|
||||
{
|
||||
"id": "D",
|
||||
"sentence": "Children's activities"
|
||||
},
|
||||
{
|
||||
"id": "E",
|
||||
"sentence": "Art exhibitions"
|
||||
}
|
||||
],
|
||||
"prompt": " Listen to a presentation about a local festival and match the activities with the appropriate festival days.",
|
||||
"sentences": [
|
||||
{
|
||||
"id": "1",
|
||||
"sentence": "Day One",
|
||||
"solution": "C"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"sentence": "Day Two",
|
||||
"solution": "A"
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
"sentence": "Day Three",
|
||||
"solution": "B"
|
||||
},
|
||||
{
|
||||
"id": "4",
|
||||
"sentence": "Day Four",
|
||||
"solution": "E"
|
||||
},
|
||||
{
|
||||
"id": "5",
|
||||
"sentence": "Day Five",
|
||||
"solution": "D"
|
||||
}
|
||||
],
|
||||
"type": "matchSentences"
|
||||
}
|
||||
],
|
||||
"isDiagnostic": True,
|
||||
"minTimer": 7,
|
||||
"module": "listening",
|
||||
"section": 2
|
||||
}
|
||||
|
||||
|
||||
# Falta section 3 e 4 do listening
|
||||
# writing task 1 com imagens ...
|
||||
# speaking 3 é discussao lol
|
||||
|
||||
# Get a reference to the Firestore database
|
||||
db = firestore.client()
|
||||
|
||||
# JSON data to insert
|
||||
|
||||
# Add the JSON data to Firestore
|
||||
collection_ref = db.collection('listening')
|
||||
document_ref = collection_ref.add(listening_section_2_to_insert_3)
|
||||
|
||||
print(f"Document added with ID: {document_ref}")
|
||||
|
||||
1
text-samples/listening.txt
Normal file
1
text-samples/listening.txt
Normal file
@@ -0,0 +1 @@
|
||||
"Provide me with an transcript similar to the ones in ielts exam Listening Section 1. After the transcript, please generate a 'form like' fill in the blanks exercise with 6 items (ex: name, date of birth) to fill related to the text content. Finally provide the answers for the exercise. The response must be a json following this format: { 'type': '<type of registration (ex: hotel, gym, english course, etc)>', 'transcript': '<transcript of just the conversation about a registration of some sort, identify the person talking in each speech line>', 'exercise': { 'item': { '1': '<item 1>', '2': '<item 2>', '3': '<item 3>', '4': '<item 4>', '5': '<item 5>', '6': '<item 5>' }, 'answers': {'1': '<answer to fill blank space in item 1>', '2': '<answer to fill blank space in item 2>', '3': '<answer to fill blank space in item 3>', '4': '<answer to fill blank space in item 4>', '5': '<answer to fill blank space in item 5>', '6': '<answer to fill blank space in item 6>'}}}
|
||||
@@ -1,6 +1,4 @@
|
||||
Q: It is important for children to learn the difference between right and wrong at an early age. Punishment is necessary to help them learn this distinction.
|
||||
To what extent do you agree or disagree with this opinion?
|
||||
What sort of punishment should parents and teachers be allowed to use to teach good behaviour to children?
|
||||
Q: It is important for children to learn the difference between right and wrong at an early age. Punishment is necessary to help them learn this distinction. To what extent do you agree or disagree with this opinion? What sort of punishment should parents and teachers be allowed to use to teach good behaviour to children?
|
||||
|
||||
|
||||
A: In today's world, moral values and ethics play a vital role in shaping the character of an individual. Children are the building blocks of society, and it is important to inculcate a sense of right and wrong in them from an early age. While punishment can be an effective tool in teaching the difference between right and wrong, it should not be the only approach. In my opinion, punishment should be used in moderation, and parents and teachers should focus on positive reinforcement and guidance to teach good behavior.
|
||||
|
||||
Reference in New Issue
Block a user