Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -387,7 +387,7 @@ def style_metric_container(label, value):
|
|
| 387 |
""", unsafe_allow_html=True)
|
| 388 |
|
| 389 |
# --- OpenAI GPT-3 Assistant ---
|
| 390 |
-
def generate_gpt_response(prompt):
|
| 391 |
"""
|
| 392 |
First look up the dataset for relevant information. If no matches are found,
|
| 393 |
generate a GPT response.
|
|
@@ -444,7 +444,7 @@ def generate_gpt_response(prompt):
|
|
| 444 |
|
| 445 |
return assistant_reply
|
| 446 |
|
| 447 |
-
def create_assistant_section():
|
| 448 |
st.markdown("""
|
| 449 |
<div style='background-color: #f8f9fa; padding: 1.5rem; border-radius: 10px; margin-bottom: 1rem;'>
|
| 450 |
<h2 style='color: #1E1E1E; margin-top: 0;'>🤖 Car Shopping Assistant</h2>
|
|
@@ -461,7 +461,7 @@ def create_assistant_section():
|
|
| 461 |
if prompt:
|
| 462 |
try:
|
| 463 |
# Use OpenAI API to generate response
|
| 464 |
-
response = generate_gpt_response(prompt)
|
| 465 |
st.session_state.assistant_responses.append(response)
|
| 466 |
except Exception as e:
|
| 467 |
response = f"Sorry, I encountered an error: {str(e)}"
|
|
@@ -632,7 +632,7 @@ def predict_with_ranges(inputs, model, label_encoders):
|
|
| 632 |
'max_price': max_price
|
| 633 |
}
|
| 634 |
# --- Main Application ---
|
| 635 |
-
def main(model, label_encoders):
|
| 636 |
col1, col2 = st.columns([2, 1])
|
| 637 |
|
| 638 |
with col1:
|
|
@@ -684,7 +684,7 @@ def main(model, label_encoders):
|
|
| 684 |
st.warning("No graph generated. Please check your data or selection.")
|
| 685 |
|
| 686 |
with col2:
|
| 687 |
-
create_assistant_section()
|
| 688 |
|
| 689 |
if __name__ == "__main__":
|
| 690 |
try:
|
|
@@ -696,7 +696,7 @@ if __name__ == "__main__":
|
|
| 696 |
inspect_model_features(model)
|
| 697 |
|
| 698 |
# Call the main function
|
| 699 |
-
main(model, label_encoders)
|
| 700 |
except Exception as e:
|
| 701 |
st.error(f"Error loading data or models: {str(e)}")
|
| 702 |
st.stop()
|
|
|
|
| 387 |
""", unsafe_allow_html=True)
|
| 388 |
|
| 389 |
# --- OpenAI GPT-3 Assistant ---
|
| 390 |
+
def generate_gpt_response(prompt, dataset):
|
| 391 |
"""
|
| 392 |
First look up the dataset for relevant information. If no matches are found,
|
| 393 |
generate a GPT response.
|
|
|
|
| 444 |
|
| 445 |
return assistant_reply
|
| 446 |
|
| 447 |
+
def create_assistant_section(dataset):
|
| 448 |
st.markdown("""
|
| 449 |
<div style='background-color: #f8f9fa; padding: 1.5rem; border-radius: 10px; margin-bottom: 1rem;'>
|
| 450 |
<h2 style='color: #1E1E1E; margin-top: 0;'>🤖 Car Shopping Assistant</h2>
|
|
|
|
| 461 |
if prompt:
|
| 462 |
try:
|
| 463 |
# Use OpenAI API to generate response
|
| 464 |
+
response = generate_gpt_response(prompt, dataset)
|
| 465 |
st.session_state.assistant_responses.append(response)
|
| 466 |
except Exception as e:
|
| 467 |
response = f"Sorry, I encountered an error: {str(e)}"
|
|
|
|
| 632 |
'max_price': max_price
|
| 633 |
}
|
| 634 |
# --- Main Application ---
|
| 635 |
+
def main(model, label_encoders, dataset):
|
| 636 |
col1, col2 = st.columns([2, 1])
|
| 637 |
|
| 638 |
with col1:
|
|
|
|
| 684 |
st.warning("No graph generated. Please check your data or selection.")
|
| 685 |
|
| 686 |
with col2:
|
| 687 |
+
create_assistant_section(dataset)
|
| 688 |
|
| 689 |
if __name__ == "__main__":
|
| 690 |
try:
|
|
|
|
| 696 |
inspect_model_features(model)
|
| 697 |
|
| 698 |
# Call the main function
|
| 699 |
+
main(model, label_encoders, original_data)
|
| 700 |
except Exception as e:
|
| 701 |
st.error(f"Error loading data or models: {str(e)}")
|
| 702 |
st.stop()
|