Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import os
|
|
| 6 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
| 7 |
|
| 8 |
# Initialize paths and model identifiers for easy configuration and maintenance
|
| 9 |
-
filename = "output_topic_details.txt" # Path to the file storing
|
| 10 |
retrieval_model_name = 'output/sentence-transformer-finetuned/'
|
| 11 |
|
| 12 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
|
@@ -64,10 +64,10 @@ def find_relevant_segment(user_query, segments):
|
|
| 64 |
|
| 65 |
def generate_response(user_query, relevant_segment):
|
| 66 |
"""
|
| 67 |
-
Generate a response emphasizing the bot's capability in providing
|
| 68 |
"""
|
| 69 |
try:
|
| 70 |
-
user_message = f"Here's the information on
|
| 71 |
|
| 72 |
# Append user's message to messages list
|
| 73 |
messages.append({"role": "user", "content": user_message})
|
|
@@ -99,7 +99,7 @@ def query_model(question):
|
|
| 99 |
Process a question, find relevant information, and generate a response.
|
| 100 |
"""
|
| 101 |
if question == "":
|
| 102 |
-
return "Welcome to
|
| 103 |
relevant_segment = find_relevant_segment(question, segments)
|
| 104 |
if not relevant_segment:
|
| 105 |
return "Could not find specific information. Please refine your question."
|
|
|
|
| 6 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
| 7 |
|
| 8 |
# Initialize paths and model identifiers for easy configuration and maintenance
|
| 9 |
+
filename = "output_topic_details.txt" # Path to the file storing college-specific details
|
| 10 |
retrieval_model_name = 'output/sentence-transformer-finetuned/'
|
| 11 |
|
| 12 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
|
|
|
| 64 |
|
| 65 |
def generate_response(user_query, relevant_segment):
|
| 66 |
"""
|
| 67 |
+
Generate a response emphasizing the bot's capability in providing college information.
|
| 68 |
"""
|
| 69 |
try:
|
| 70 |
+
user_message = f"Here's the information on college: {relevant_segment}"
|
| 71 |
|
| 72 |
# Append user's message to messages list
|
| 73 |
messages.append({"role": "user", "content": user_message})
|
|
|
|
| 99 |
Process a question, find relevant information, and generate a response.
|
| 100 |
"""
|
| 101 |
if question == "":
|
| 102 |
+
return "Welcome to Collete! Ask me anything about college admissions, college fit or college testing."
|
| 103 |
relevant_segment = find_relevant_segment(question, segments)
|
| 104 |
if not relevant_segment:
|
| 105 |
return "Could not find specific information. Please refine your question."
|