Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,10 +11,6 @@ with open("mom_phrases.txt", "r", encoding="utf-8") as file:
|
|
| 11 |
# Read the entire contents of the file and store it in a variable
|
| 12 |
phrases_text = file.read()
|
| 13 |
|
| 14 |
-
# Print the text below
|
| 15 |
-
print(phrases_text)
|
| 16 |
-
|
| 17 |
-
|
| 18 |
# STEP 3 FROM SEMANTIC SEARCH
|
| 19 |
def preprocess_text(text):
|
| 20 |
# Strip extra whitespace from the beginning and the end of the text
|
|
@@ -34,8 +30,6 @@ def preprocess_text(text):
|
|
| 34 |
|
| 35 |
# Print cleaned_chunks
|
| 36 |
print(cleaned_chunks)
|
| 37 |
-
|
| 38 |
-
|
| 39 |
# Print the length of cleaned_chunks
|
| 40 |
print(len(cleaned_chunks))
|
| 41 |
|
|
@@ -118,7 +112,7 @@ def respond(message, history):
|
|
| 118 |
best_chunks = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 119 |
print(best_chunks)
|
| 120 |
str_chunks = "\n".join(best_chunks)
|
| 121 |
-
messages = [{"role": "system", "content": f"You are
|
| 122 |
{"role": "user",
|
| 123 |
"content": (
|
| 124 |
f"Context:\n{str_chunks}\n\n"
|
|
|
|
| 11 |
# Read the entire contents of the file and store it in a variable
|
| 12 |
phrases_text = file.read()
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# STEP 3 FROM SEMANTIC SEARCH
|
| 15 |
def preprocess_text(text):
|
| 16 |
# Strip extra whitespace from the beginning and the end of the text
|
|
|
|
| 30 |
|
| 31 |
# Print cleaned_chunks
|
| 32 |
print(cleaned_chunks)
|
|
|
|
|
|
|
| 33 |
# Print the length of cleaned_chunks
|
| 34 |
print(len(cleaned_chunks))
|
| 35 |
|
|
|
|
| 112 |
best_chunks = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 113 |
print(best_chunks)
|
| 114 |
str_chunks = "\n".join(best_chunks)
|
| 115 |
+
messages = [{"role": "system", "content": f"You are chatbot that plays the role of the user's mom. Base your response on the provided context: {str_chunks}"},
|
| 116 |
{"role": "user",
|
| 117 |
"content": (
|
| 118 |
f"Context:\n{str_chunks}\n\n"
|