Update app.py
Browse files
app.py
CHANGED
|
@@ -492,8 +492,8 @@ def generate_gpt_response(prompt, dataset):
|
|
| 492 |
st.dataframe(dataset_response) # Show results to the user
|
| 493 |
return f"I found some information in our dataset about {make.title()} {model.title() if model else ''}. Please see the details above."
|
| 494 |
|
| 495 |
-
|
| 496 |
-
openai.api_key = "
|
| 497 |
system_message = {
|
| 498 |
"role": "system",
|
| 499 |
"content": (
|
|
@@ -698,9 +698,7 @@ def predict_with_ranges(inputs, model, label_encoders):
|
|
| 698 |
'min_price': min_price,
|
| 699 |
'max_price': max_price
|
| 700 |
}
|
| 701 |
-
# --- Main Application ---
|
| 702 |
def main():
|
| 703 |
-
# Load necessary data and models
|
| 704 |
try:
|
| 705 |
original_data = load_datasets()
|
| 706 |
model, label_encoders = load_model_and_encodings()
|
|
@@ -713,23 +711,32 @@ def main():
|
|
| 713 |
|
| 714 |
with tab1:
|
| 715 |
st.title("Car Price Prediction")
|
| 716 |
-
# [Previous prediction interface code]
|
| 717 |
-
inputs, predict_button = create_prediction_interface()
|
| 718 |
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
|
|
|
|
|
|
|
|
|
| 722 |
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 733 |
|
| 734 |
with tab2:
|
| 735 |
st.title("Car Image Analysis")
|
|
|
|
| 492 |
st.dataframe(dataset_response) # Show results to the user
|
| 493 |
return f"I found some information in our dataset about {make.title()} {model.title() if model else ''}. Please see the details above."
|
| 494 |
|
| 495 |
+
|
| 496 |
+
openai.api_key = st.secrets["GPT_TOKEN"]
|
| 497 |
system_message = {
|
| 498 |
"role": "system",
|
| 499 |
"content": (
|
|
|
|
| 698 |
'min_price': min_price,
|
| 699 |
'max_price': max_price
|
| 700 |
}
|
|
|
|
| 701 |
def main():
|
|
|
|
| 702 |
try:
|
| 703 |
original_data = load_datasets()
|
| 704 |
model, label_encoders = load_model_and_encodings()
|
|
|
|
| 711 |
|
| 712 |
with tab1:
|
| 713 |
st.title("Car Price Prediction")
|
|
|
|
|
|
|
| 714 |
|
| 715 |
+
# Create two columns
|
| 716 |
+
col1, col2 = st.columns([2, 1])
|
| 717 |
+
|
| 718 |
+
with col1:
|
| 719 |
+
# Prediction interface code
|
| 720 |
+
inputs, predict_button = create_prediction_interface()
|
| 721 |
|
| 722 |
+
if predict_button:
|
| 723 |
+
st.write(f"Analyzing {inputs['year']} {inputs['make'].title()} {inputs['model'].title()}...")
|
| 724 |
+
prediction_results = predict_with_ranges(inputs, model, label_encoders)
|
| 725 |
+
|
| 726 |
+
st.markdown(f"""
|
| 727 |
+
### Price Analysis
|
| 728 |
+
- **Estimated Range**: ${prediction_results['min_price']:,.2f} - ${prediction_results['max_price']:,.2f}
|
| 729 |
+
- **Model Prediction**: ${prediction_results['predicted_price']:,.2f}
|
| 730 |
+
""")
|
| 731 |
+
|
| 732 |
+
# Generate and display the graph
|
| 733 |
+
fig = create_market_trends_plot_with_model(model, inputs["make"], inputs, label_encoders)
|
| 734 |
+
if fig:
|
| 735 |
+
st.pyplot(fig)
|
| 736 |
+
|
| 737 |
+
with col2:
|
| 738 |
+
# Add the chat assistant here
|
| 739 |
+
create_assistant_section(original_data)
|
| 740 |
|
| 741 |
with tab2:
|
| 742 |
st.title("Car Image Analysis")
|