Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import streamlit as st
|
|
| 2 |
import openai
|
| 3 |
|
| 4 |
# Access the OpenAI API key from Hugging Face Spaces secrets
|
| 5 |
-
openai.api_key = st.secrets["
|
| 6 |
|
| 7 |
st.title("Investment Property Finder in Breckenridge and Blue River, CO")
|
| 8 |
|
|
@@ -17,12 +17,14 @@ if st.button('Find Property'):
|
|
| 17 |
# Process the inputs and call the OpenAI API
|
| 18 |
user_input = f"I'm considering buying an investment property in Breckenridge and Blue River, CO. My maximum price is {max_price}. I'm looking for these amenities: {', '.join(amenities)}. Bedrooms: {bedrooms}, Bathrooms: {bathrooms}, Square Footage: {square_footage}."
|
| 19 |
|
| 20 |
-
# Call the OpenAI API
|
| 21 |
-
response = openai.
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
# Display the response from the API
|
| 28 |
-
st.write(response.choices[0].
|
|
|
|
| 2 |
import openai
|
| 3 |
|
| 4 |
# Access the OpenAI API key from Hugging Face Spaces secrets
|
| 5 |
+
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
| 6 |
|
| 7 |
st.title("Investment Property Finder in Breckenridge and Blue River, CO")
|
| 8 |
|
|
|
|
| 17 |
# Process the inputs and call the OpenAI API
|
| 18 |
user_input = f"I'm considering buying an investment property in Breckenridge and Blue River, CO. My maximum price is {max_price}. I'm looking for these amenities: {', '.join(amenities)}. Bedrooms: {bedrooms}, Bathrooms: {bathrooms}, Square Footage: {square_footage}."
|
| 19 |
|
| 20 |
+
# Call the OpenAI API with the chat model
|
| 21 |
+
response = openai.ChatCompletion.create(
|
| 22 |
+
model="gpt-4.0", # Replace with the GPT-4 model you are using
|
| 23 |
+
messages=[
|
| 24 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 25 |
+
{"role": "user", "content": user_input}
|
| 26 |
+
]
|
| 27 |
)
|
| 28 |
|
| 29 |
# Display the response from the API
|
| 30 |
+
st.write(response.choices[0].message['content'])
|