Spaces:
Runtime error
Runtime error
Kunaal Naik
commited on
Commit
·
8795cbf
1
Parent(s):
b70736e
app2
Browse files- app.py +14 -18
- app2.py → app1.py +25 -17
app.py
CHANGED
|
@@ -41,30 +41,26 @@ if st.sidebar.button("Get response"):
|
|
| 41 |
st.info(prompt.template)
|
| 42 |
answer = chain.run({"target_audience": target_audience, "target_course": target_course})
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
# Extract titles for tabs
|
| 50 |
-
titles = [section.split('\n')[0] for section in sections]
|
| 51 |
-
|
| 52 |
-
# Extract content for each section, removing the title
|
| 53 |
-
contents = [section.split('\n')[1:] for section in sections]
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
for i, tab in enumerate(tabs):
|
| 59 |
-
with tab:
|
| 60 |
-
st.header(titles[i])
|
| 61 |
-
for content in contents[i]:
|
| 62 |
-
st.markdown(content)
|
| 63 |
-
else:
|
| 64 |
-
st.error("The answer format does not match the expected structure.")
|
| 65 |
elif target_audience:
|
| 66 |
st.error("Enter your course/service name")
|
| 67 |
elif my_course:
|
| 68 |
st.error("Enter your target audience")
|
| 69 |
else:
|
| 70 |
st.error("No input detected, Please provide the desired information.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
st.info(prompt.template)
|
| 42 |
answer = chain.run({"target_audience": target_audience, "target_course": target_course})
|
| 43 |
|
| 44 |
+
# Create a tab bar with 3 tabs
|
| 45 |
+
tab1, tab2, tab3 = st.tabs(["Customer Pain Points", "LinkedIn Profile", "Customer Persona"])
|
| 46 |
|
| 47 |
+
with tab1:
|
| 48 |
+
st.write(answer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
with tab2:
|
| 51 |
+
st.write(answer)
|
| 52 |
+
|
| 53 |
+
with tab3:
|
| 54 |
+
st.write(answer)
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
elif target_audience:
|
| 57 |
st.error("Enter your course/service name")
|
| 58 |
elif my_course:
|
| 59 |
st.error("Enter your target audience")
|
| 60 |
else:
|
| 61 |
st.error("No input detected, Please provide the desired information.")
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
app2.py → app1.py
RENAMED
|
@@ -27,36 +27,44 @@ prompt = PromptTemplate(
|
|
| 27 |
|
| 28 |
chain = LLMChain(llm=OpenAI(), prompt=prompt)
|
| 29 |
|
| 30 |
-
#target_audience =
|
| 31 |
-
#
|
| 32 |
|
|
|
|
| 33 |
target_audience = st.sidebar.text_input('Enter your target audience', value = 'professionals looking for course on Power BI')
|
| 34 |
target_course = st.sidebar.text_input('Enter your course name', value = 'Zero to Hero in PowerBI')
|
| 35 |
|
| 36 |
if st.sidebar.button("Get response"):
|
| 37 |
if target_audience and target_course:
|
| 38 |
with st.spinner("Generating response..."):
|
| 39 |
-
|
|
|
|
| 40 |
answer = chain.run({"target_audience": target_audience, "target_course": target_course})
|
| 41 |
-
|
| 42 |
-
# Create a tab bar with 3 tabs
|
| 43 |
-
tab1, tab2, tab3 = st.tabs(["Customer Pain Points", "LinkedIn Profile", "Customer Persona"])
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
st.info(prompt.template)
|
| 48 |
-
st.write(answer)
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
elif target_audience:
|
| 57 |
-
st.error("Enter your course name
|
| 58 |
elif my_course:
|
| 59 |
-
st.error("Enter your target audience
|
| 60 |
-
|
| 61 |
else:
|
| 62 |
st.error("No input detected, Please provide the desired information.")
|
|
|
|
| 27 |
|
| 28 |
chain = LLMChain(llm=OpenAI(), prompt=prompt)
|
| 29 |
|
| 30 |
+
#target_audience = "professionals looking for course on Power BI"
|
| 31 |
+
#my_course = "Zero to Hero in PowerBI"
|
| 32 |
|
| 33 |
+
# Use the sidebar for input
|
| 34 |
target_audience = st.sidebar.text_input('Enter your target audience', value = 'professionals looking for course on Power BI')
|
| 35 |
target_course = st.sidebar.text_input('Enter your course name', value = 'Zero to Hero in PowerBI')
|
| 36 |
|
| 37 |
if st.sidebar.button("Get response"):
|
| 38 |
if target_audience and target_course:
|
| 39 |
with st.spinner("Generating response..."):
|
| 40 |
+
with st.expander("Show prompt", expanded=False):
|
| 41 |
+
st.info(prompt.template)
|
| 42 |
answer = chain.run({"target_audience": target_audience, "target_course": target_course})
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
# Split the 'answer' into sections based on the questions
|
| 45 |
+
sections = [section.strip() for section in answer.split("\n\n") if section.strip() != ""]
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
# Assuming there are exactly three sections based on your output structure
|
| 48 |
+
if len(sections) == 3:
|
| 49 |
+
# Extract titles for tabs
|
| 50 |
+
titles = [section.split('\n')[0] for section in sections]
|
| 51 |
+
|
| 52 |
+
# Extract content for each section, removing the title
|
| 53 |
+
contents = [section.split('\n')[1:] for section in sections]
|
| 54 |
|
| 55 |
+
# Create tabs for each category
|
| 56 |
+
tabs = st.tabs(titles)
|
| 57 |
|
| 58 |
+
for i, tab in enumerate(tabs):
|
| 59 |
+
with tab:
|
| 60 |
+
st.header(titles[i])
|
| 61 |
+
for content in contents[i]:
|
| 62 |
+
st.markdown(content)
|
| 63 |
+
else:
|
| 64 |
+
st.error("The answer format does not match the expected structure.")
|
| 65 |
elif target_audience:
|
| 66 |
+
st.error("Enter your course/service name")
|
| 67 |
elif my_course:
|
| 68 |
+
st.error("Enter your target audience")
|
|
|
|
| 69 |
else:
|
| 70 |
st.error("No input detected, Please provide the desired information.")
|