Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ with open("cool_mom_phrases.txt", "r", encoding="utf-8") as file:
|
|
| 11 |
# Read the entire contents of the file and store it in a variable
|
| 12 |
cool_mom_text = file.read()
|
| 13 |
|
| 14 |
-
with open("tutor_mom_phrases.txt", "r", encoding="utf-8") as file:
|
| 15 |
# Read the entire contents of the file and store it in a variable
|
| 16 |
tutor_mom_text = file.read()
|
| 17 |
|
|
@@ -22,7 +22,7 @@ with open("strict_mom_phrases.txt", "r", encoding="utf-8") as file:
|
|
| 22 |
with open("study_techniques.txt", "r", encoding="utf-8") as file:
|
| 23 |
# Read the entire contents of the file and store it in a variable
|
| 24 |
study_techniques_text = file.read()
|
| 25 |
-
|
| 26 |
|
| 27 |
# STEP 3 FROM SEMANTIC SEARCH
|
| 28 |
def preprocess_text(text):
|
|
@@ -46,8 +46,8 @@ def preprocess_text(text):
|
|
| 46 |
|
| 47 |
# Call the preprocess_text function and store the result in a cleaned_chunks variable
|
| 48 |
cleaned_cool_chunks = preprocess_text(cool_mom_text) # Complete this line
|
| 49 |
-
cleaned_tutor_chunks = preprocess_text(tutor_mom_text)
|
| 50 |
-
cleaned_strict_chunks = preprocess_text(strict_mom_text)
|
| 51 |
|
| 52 |
#STEP 4 FROM SEMANTIC SEARCH
|
| 53 |
# Load the pre-trained embedding model that converts text to vectors
|
|
@@ -62,8 +62,8 @@ def create_embeddings(text_chunks):
|
|
| 62 |
|
| 63 |
# Call the create_embeddings function and store the result in a new chunk_embeddings variable
|
| 64 |
cool_chunk_embeddings = create_embeddings(cleaned_cool_chunks) # Complete this line
|
| 65 |
-
tutor_chunk_embeddings = create_embeddings(cleaned_tutor_chunks)
|
| 66 |
-
strict_chunk_embeddings = create_embeddings(cleaned_strict_chunks)
|
| 67 |
|
| 68 |
#STEP 5 FROM SEMANTIC SEARCH
|
| 69 |
# Define a function to find the most relevant text chunks for a given query, chunk_embeddings, and text_chunks
|
|
@@ -149,13 +149,7 @@ chatbot = gr.ChatInterface(respond, type="messages")
|
|
| 149 |
|
| 150 |
with gr.Blocks() as chatbot:
|
| 151 |
with gr.Row():
|
| 152 |
-
|
| 153 |
-
tutor_button = gr.Button("Tutor Mom")
|
| 154 |
-
strict_button = gr.Button("Strict Mom")
|
| 155 |
-
|
| 156 |
-
cool_button.click(fn=[], inputs=[], outputs=respond(message, history, "Cool Mom"))
|
| 157 |
-
tutor_button.click(fn=[], inputs=[], outputs=respond(message, history, "Tutor Mom"))
|
| 158 |
-
strict_button.click(fn=[], inputs=[], outputs=respond(message, history, "Strict Mom"))
|
| 159 |
|
| 160 |
gr.ChatInterface(
|
| 161 |
#fn=respond,
|
|
|
|
| 11 |
# Read the entire contents of the file and store it in a variable
|
| 12 |
cool_mom_text = file.read()
|
| 13 |
|
| 14 |
+
'''with open("tutor_mom_phrases.txt", "r", encoding="utf-8") as file:
|
| 15 |
# Read the entire contents of the file and store it in a variable
|
| 16 |
tutor_mom_text = file.read()
|
| 17 |
|
|
|
|
| 22 |
with open("study_techniques.txt", "r", encoding="utf-8") as file:
|
| 23 |
# Read the entire contents of the file and store it in a variable
|
| 24 |
study_techniques_text = file.read()
|
| 25 |
+
'''
|
| 26 |
|
| 27 |
# STEP 3 FROM SEMANTIC SEARCH
|
| 28 |
def preprocess_text(text):
|
|
|
|
| 46 |
|
| 47 |
# Call the preprocess_text function and store the result in a cleaned_chunks variable
|
| 48 |
cleaned_cool_chunks = preprocess_text(cool_mom_text) # Complete this line
|
| 49 |
+
'''cleaned_tutor_chunks = preprocess_text(tutor_mom_text)
|
| 50 |
+
cleaned_strict_chunks = preprocess_text(strict_mom_text)'''
|
| 51 |
|
| 52 |
#STEP 4 FROM SEMANTIC SEARCH
|
| 53 |
# Load the pre-trained embedding model that converts text to vectors
|
|
|
|
| 62 |
|
| 63 |
# Call the create_embeddings function and store the result in a new chunk_embeddings variable
|
| 64 |
cool_chunk_embeddings = create_embeddings(cleaned_cool_chunks) # Complete this line
|
| 65 |
+
'''tutor_chunk_embeddings = create_embeddings(cleaned_tutor_chunks)
|
| 66 |
+
strict_chunk_embeddings = create_embeddings(cleaned_strict_chunks)'''
|
| 67 |
|
| 68 |
#STEP 5 FROM SEMANTIC SEARCH
|
| 69 |
# Define a function to find the most relevant text chunks for a given query, chunk_embeddings, and text_chunks
|
|
|
|
| 149 |
|
| 150 |
with gr.Blocks() as chatbot:
|
| 151 |
with gr.Row():
|
| 152 |
+
mom_type = gr.CheckboxGroup(["Cool Mom", "Tutor Mom", "Strict Mom"],label = "Choose Your Mom")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
gr.ChatInterface(
|
| 155 |
#fn=respond,
|