Spaces:
Sleeping
Sleeping
Create components/canvas_chat.py
Browse files- components/canvas_chat.py +46 -23
components/canvas_chat.py
CHANGED
|
@@ -1,33 +1,56 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from langchain_core.prompts import ChatPromptTemplate
|
| 3 |
-
from
|
| 4 |
-
from
|
| 5 |
-
from
|
| 6 |
-
from utils.prompts import STRATEGY_PROMPT
|
| 7 |
-
import time
|
| 8 |
|
| 9 |
def run_canvas_chat():
|
| 10 |
st.title("🧠 Canvas Assistant")
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
st.
|
| 21 |
-
st.session_state.canvas_data["customer_relationships"] = st.text_area("Customer Relationships")
|
| 22 |
-
st.session_state.canvas_data["revenue_streams"] = st.text_area("Revenue Streams")
|
| 23 |
-
st.session_state.canvas_data["key_resources"] = st.text_area("Key Resources")
|
| 24 |
-
st.session_state.canvas_data["key_activities"] = st.text_area("Key Activities")
|
| 25 |
-
st.session_state.canvas_data["key_partnerships"] = st.text_area("Key Partnerships")
|
| 26 |
-
st.session_state.canvas_data["cost_structure"] = st.text_area("Cost Structure")
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
st.success("✅ Canvas
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from langchain_core.messages import AIMessage
|
| 3 |
from langchain_core.prompts import ChatPromptTemplate
|
| 4 |
+
from langchain_community.chat_models import ChatGroq
|
| 5 |
+
from utils.prompts import canvas_prompt
|
| 6 |
+
from utils.session import update_state, get_state_value
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def run_canvas_chat():
|
| 9 |
st.title("🧠 Canvas Assistant")
|
| 10 |
+
st.markdown("Let AI guide you step-by-step through your Business Model Canvas.")
|
| 11 |
|
| 12 |
+
questions = [
|
| 13 |
+
"What’s your business idea?",
|
| 14 |
+
"Who are your target customers?",
|
| 15 |
+
"What problem are you solving?",
|
| 16 |
+
"What’s your unique value proposition?",
|
| 17 |
+
"What are your main revenue streams?",
|
| 18 |
+
"What are your key cost drivers?",
|
| 19 |
+
"What channels will you use to reach your customers?",
|
| 20 |
+
"What key partnerships will you need?",
|
| 21 |
+
"What resources are essential to deliver your solution?",
|
| 22 |
+
"What are your core activities for success?"
|
| 23 |
+
]
|
| 24 |
|
| 25 |
+
responses = get_state_value("canvas_responses", {})
|
| 26 |
+
current_index = get_state_value("canvas_current_index", 0)
|
| 27 |
|
| 28 |
+
if current_index < len(questions):
|
| 29 |
+
question = questions[current_index]
|
| 30 |
+
st.subheader(f"Step {current_index + 1}: {question}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
user_input = st.text_input("Your Answer", key="user_input")
|
| 33 |
+
if st.button("Submit"):
|
| 34 |
+
if user_input.strip() != "":
|
| 35 |
+
responses[str(current_index)] = user_input.strip()
|
| 36 |
+
update_state("canvas_responses", responses)
|
| 37 |
+
update_state("canvas_current_index", current_index + 1)
|
| 38 |
+
st.rerun()
|
| 39 |
+
else:
|
| 40 |
+
st.warning("Please provide a valid answer before proceeding.")
|
| 41 |
|
| 42 |
+
else:
|
| 43 |
+
st.success("✅ All Canvas steps completed!")
|
| 44 |
+
st.markdown("### Here's a summary of your Business Model Canvas:")
|
| 45 |
+
|
| 46 |
+
summary = ""
|
| 47 |
+
for idx, q in enumerate(questions):
|
| 48 |
+
answer = responses.get(str(idx), "Not answered")
|
| 49 |
+
summary += f"**{q}**\n\n{answer}\n\n"
|
| 50 |
+
|
| 51 |
+
st.markdown(summary)
|
| 52 |
+
|
| 53 |
+
if st.button("Reset Canvas"):
|
| 54 |
+
update_state("canvas_responses", {})
|
| 55 |
+
update_state("canvas_current_index", 0)
|
| 56 |
+
st.rerun()
|