File size: 1,168 Bytes
84b6fb2
 
f3a906c
84b6fb2
 
b490ff9
84b6fb2
 
 
175a2b7
f3a906c
84b6fb2
f3a906c
84b6fb2
 
e5bbfe7
f3a906c
 
84b6fb2
 
 
 
 
f3a906c
84b6fb2
 
 
 
 
 
 
f3a906c
84b6fb2
 
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
# components/decision_engine.py

import streamlit as st
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import Runnable
from langchain_groq import ChatGroq
from utils.session import get_canvas_data
from utils.prompts import DECISION_ENGINE_PROMPT


def run_decision_engine():
    st.header("🎯 Strategy Suggestions")

    canvas = get_canvas_data()
    if not canvas:
        st.warning("Please complete the Canvas Assistant first.")
        return

    # Show canvas summary
    st.subheader("📋 Canvas Overview")
    for section, content in canvas.items():
        st.markdown(f"**{section}**")
        st.info(content)

    with st.spinner("Analyzing canvas for strategic insights..."):
        prompt = ChatPromptTemplate.from_template(
            DECISION_ENGINE_PROMPT + "\n\nCanvas Data:\n{input}"
        )
        chain: Runnable = prompt | ChatGroq(model="llama3-8b-8192", temperature=0.3)
        full_canvas_text = "\n".join([f"{k}: {v}" for k, v in canvas.items()])
        result = chain.invoke({"input": full_canvas_text})

        st.subheader("🧠 AI Strategy Suggestions")
        st.success(result.content)