Spaces:
Runtime error
Runtime error
File size: 2,968 Bytes
255687c 970a850 255687c 566dfd9 5169cdc 255687c 566dfd9 6549fa7 e985887 6549fa7 43957f6 6549fa7 8795cbf 6549fa7 8795cbf 566dfd9 6549fa7 566dfd9 5b9ef3f 8795cbf 566dfd9 8795cbf 566dfd9 8795cbf 566dfd9 8795cbf 566dfd9 8795cbf 5b9ef3f 8795cbf 5b9ef3f 8795cbf 3ff38b9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | from langchain.chains import LLMChain
from langchain_community.llms import OpenAI
from langchain_core.prompts import PromptTemplate
import streamlit as st
# Set the page to wide mode
st.set_page_config(layout="wide")
mini_template = "You are an expert researcher. You\'ve talked to hundreds of {target_audience}. \
Each person in the niche of {target_audience} has certain struggles that make it easier to sell {target_course}. \
These are called Pain Points. There's a recipe for getting to the core of the Pain Points of {target_audience}. \
Namely, answer each of these Questions 3 times, each getting deeper in the issues of {target_audience}, \
appealing to their Emotions and uncertainties related to {target_course}. \
The Questions (answer each QUESTION 3 tiems in listicle format according to the instructions):\
1. What keeps them awake at night?\
2. What are they afraid of?\
3. What are they angry about?\
"
st.title("Marketing Technology")
prompt = PromptTemplate(
input_variables = ["target_audience", "target_course"],
template=mini_template,
)
chain = LLMChain(llm=OpenAI(), prompt=prompt)
#target_audience = "professionals looking for course on Power BI"
#my_course = "Zero to Hero in PowerBI"
# Use the sidebar for input
target_audience = st.sidebar.text_input('Enter your target audience', value = 'professionals looking for course on Power BI')
target_course = st.sidebar.text_input('Enter your course name', value = 'Zero to Hero in PowerBI')
if st.sidebar.button("Get response"):
if target_audience and target_course:
with st.spinner("Generating response..."):
with st.expander("Show prompt", expanded=False):
st.info(prompt.template)
answer = chain.run({"target_audience": target_audience, "target_course": target_course})
# Split the 'answer' into sections based on the questions
sections = [section.strip() for section in answer.split("\n\n") if section.strip() != ""]
# Assuming there are exactly three sections based on your output structure
if len(sections) == 3:
# Extract titles for tabs
titles = [section.split('\n')[0] for section in sections]
# Extract content for each section, removing the title
contents = [section.split('\n')[1:] for section in sections]
# Create tabs for each category
tabs = st.tabs(titles)
for i, tab in enumerate(tabs):
with tab:
st.header(titles[i])
for content in contents[i]:
st.markdown(content)
else:
st.error("The answer format does not match the expected structure.")
elif target_audience:
st.error("Enter your course/service name")
elif my_course:
st.error("Enter your target audience")
else:
st.error("No input detected, Please provide the desired information.")
|