Update app.py
Browse files
app.py
CHANGED
@@ -2,21 +2,18 @@ import streamlit as st
|
|
2 |
import openai
|
3 |
|
4 |
# Initializing Streamlit app
|
5 |
-
st.title("
|
6 |
|
7 |
-
#
|
8 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
9 |
|
10 |
-
# Function to call OpenAI API
|
11 |
def call_openai_api(prompt):
|
12 |
try:
|
13 |
response = openai.ChatCompletion.create(
|
14 |
-
model="gpt-4o",
|
15 |
messages=[
|
16 |
-
{
|
17 |
-
"role": "system",
|
18 |
-
"content": prompt['system']
|
19 |
-
},
|
20 |
{"role": "user", "content": prompt['user']}
|
21 |
]
|
22 |
)
|
@@ -26,38 +23,26 @@ def call_openai_api(prompt):
|
|
26 |
return None
|
27 |
|
28 |
# Streamlit UI for input
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
name_to_include = st.text_input("List any names (your name or business name) you want to include in the video.", placeholder="e.g., 123 Custom Blinds or Mary Smith")
|
34 |
-
call_to_action = st.text_input("How do you want to be contacted? (Provide one call to action)", placeholder="e.g., Visit our bakery on Main Street.")
|
35 |
-
script_length = st.number_input("Desired script length (maximum word count):", min_value=50, max_value=250, value=150, step=10)
|
36 |
|
37 |
-
generate_button = st.button('Generate
|
38 |
|
39 |
-
# Handling button click
|
40 |
if generate_button:
|
41 |
-
# Creating the prompt as a dictionary
|
42 |
user_prompt = {
|
43 |
"system": """
|
44 |
-
|
45 |
-
loud into the camera. The scripts you create do not include shot directions, references to who is speaking, or any other extraneous notes that are not the actual
|
46 |
-
words that should be read out loud. As a small business video marketing expert, you have studied the most effective marketing and social media videos made by small
|
47 |
-
businesses. The video scripts are short, always coming in under the specified maximum word count. They always begin with engaging opening lines that tease what the
|
48 |
-
rest of the video is about and they end with a single strong call to action.""",
|
49 |
"user": f"""
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
Unique Aspects: {unique_aspects}
|
54 |
-
Names to Include: {name_to_include}
|
55 |
-
Call to Action: {call_to_action}
|
56 |
-
Script Length: {script_length} words maximum."""
|
57 |
}
|
58 |
-
|
59 |
-
if
|
60 |
-
st.markdown("###
|
61 |
-
st.write(
|
62 |
else:
|
63 |
-
st.write("An error occurred while generating the
|
|
|
2 |
import openai
|
3 |
|
4 |
# Initializing Streamlit app
|
5 |
+
st.title("AI Integration Assessment for Businesses")
|
6 |
|
7 |
+
# Securely accessing the OpenAI API key
|
8 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
9 |
|
10 |
+
# Function to call OpenAI API using GPT-4o
|
11 |
def call_openai_api(prompt):
|
12 |
try:
|
13 |
response = openai.ChatCompletion.create(
|
14 |
+
model="gpt-4o", # Specify GPT-4o as the model
|
15 |
messages=[
|
16 |
+
{"role": "system", "content": prompt['system']},
|
|
|
|
|
|
|
17 |
{"role": "user", "content": prompt['user']}
|
18 |
]
|
19 |
)
|
|
|
23 |
return None
|
24 |
|
25 |
# Streamlit UI for input
|
26 |
+
business_type = st.text_input("Describe your business type and main activities:", "e.g., Manufacturing")
|
27 |
+
current_tech_usage = st.text_input("Describe current technology usage in your business:", "e.g., Mostly manual processes with some Excel usage")
|
28 |
+
ai_interest_areas = st.multiselect("Select potential areas for AI integration:",
|
29 |
+
["Customer Service", "Operations", "Marketing", "Risk Management", "Product Development"])
|
|
|
|
|
|
|
30 |
|
31 |
+
generate_button = st.button('Generate AI Integration Report')
|
32 |
|
33 |
+
# Handling the button click
|
34 |
if generate_button:
|
|
|
35 |
user_prompt = {
|
36 |
"system": """
|
37 |
+
You are an AI consultant tasked with evaluating a business to determine where AI can be effectively integrated. Provide a detailed report that assesses the current technology usage and recommends areas for AI implementation based on the business type and interests.""",
|
|
|
|
|
|
|
|
|
38 |
"user": f"""
|
39 |
+
Business Type: {business_type}
|
40 |
+
Current Technology Usage: {current_tech_usage}
|
41 |
+
Interest Areas: {', '.join(ai_interest_areas)}"""
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
+
report = call_openai_api(user_prompt)
|
44 |
+
if report:
|
45 |
+
st.markdown("### AI Integration Report")
|
46 |
+
st.write(report)
|
47 |
else:
|
48 |
+
st.write("An error occurred while generating the report. Please try again.")
|