nniehaus commited on
Commit
5d6c2d0
·
1 Parent(s): 656a724

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
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["YOUR_OPENAI_API_KEY"]
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 here with the user_input and get the response
21
- response = openai.Completion.create(
22
- engine="gpt-4", # Replace with your preferred model
23
- prompt=user_input,
24
- max_tokens=5000
 
 
25
  )
26
 
27
  # Display the response from the API
28
- st.write(response.choices[0].text.strip())
 
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'])