bizvideoschool commited on
Commit
0a99cb6
1 Parent(s): f23c1ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
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["OPENAI_API_KEY"]
6
 
7
  st.title("Holiday Video Script Generator for Real Estate Agents")
8
 
@@ -20,15 +20,17 @@ if generate_script_button:
20
  Create a festive and engaging one-minute holiday video script for a real estate agent named {agent_name}. The script should focus on the neighborhood of {neighborhood}, incorporate unique selling points: {unique_selling_points}, and include the personal message: {personal_message}. The script should be warm, welcoming, and build a sense of community. Keep it professional yet personal.
21
  """
22
 
23
- # Call the OpenAI API
24
- response = openai.Completion.create(
25
  model="gpt-4",
26
- prompt=user_input,
27
- max_tokens=300
 
 
28
  )
29
 
30
  # Display the script
31
- script = response.choices[0].text.strip()
32
  st.write("### Generated Script")
33
  st.write(script)
34
 
 
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("Holiday Video Script Generator for Real Estate Agents")
8
 
 
20
  Create a festive and engaging one-minute holiday video script for a real estate agent named {agent_name}. The script should focus on the neighborhood of {neighborhood}, incorporate unique selling points: {unique_selling_points}, and include the personal message: {personal_message}. The script should be warm, welcoming, and build a sense of community. Keep it professional yet personal.
21
  """
22
 
23
+ # Call the OpenAI API with the correct endpoint for chat models
24
+ response = openai.ChatCompletion.create(
25
  model="gpt-4",
26
+ messages=[
27
+ {"role": "system", "content": "You are a helpful assistant."},
28
+ {"role": "user", "content": user_input}
29
+ ]
30
  )
31
 
32
  # Display the script
33
+ script = response.choices[0].message['content'].strip()
34
  st.write("### Generated Script")
35
  st.write(script)
36