fadliaulawi's picture
Update new agentic flow
2739fae
raw
history blame
5.4 kB
import streamlit as st
import os
from groq import Groq
from dotenv import load_dotenv
from openai import OpenAI
load_dotenv()
st.title("AI-powered Mindfulness App")
st.write("""
The application is designed to assist you in making informed decisions by providing a structured platform for consultation.
Embedded with Panca Sradha values, this application will ensure that all guidance aligns with the core principles upheld by Kalbe Group, promoting consistency and integrity in decision-making.
You can input the background context of the decision you are considering and articulate the specific questions for which you need guidance.
The application will generate two outputs: a detailed recommendation and a corresponding risk assessment with suggested mitigation strategies.
""")
# Input text boxes
background = st.text_area("Background", height=200)
question = st.text_area("Question", height=50)
client = Groq(
api_key=os.environ['GROQ_API_KEY'],
)
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"),
)
promptRecommendation = """
### CONTEXT
You are a company consultant in Kalbe Group with a deep understanding of the company's core values, known as Panca Sradha.
You are presented with this specific situation:
Background: {}
Question: {}
### OBJECTIVE
Based on these inputs, your task is to give a recommendation, a detailed suggestion that aligns with Kalbe Group's strategic objectives.
IMPORTANT: Your recommendations must align with the Panca Sradha values:
1. Trust is the glue of life.
2. Mindfulness is the foundation of our action.
3. Innovation is the key to our success.
4. Strive to be the best.
5. Interconnectedness is a universal way of life.
### RESPONSE
Ensure your response is connected to the Panca Sradha values by emphasizing them in italics whenever mentioned.
"""
promptRoles = """
### CONTEXT
As the Head of Risk Management Consultant at Kalbe Group, you oversee various department specializations including:
- Legal
- Human Resources
- Research and Development
- Production
- Sales and Marketing
- Information Technology
- Finance and Accounting
- Business Development
- Compliance and Regulatory
- External Communications
You are presented with this specific situation:
Background: {}
Question: {}
### OBJECTIVE
Your objective is to carefully assess the situation described and identify the three departments from the provided list that are most closely related to the current conditions. Determine which departments are significantly impacted by the scenario and would benefit from a targeted risk management strategy.
### RESPONSE
Please respond by only listing the three selected departments separated by commas.
Example: A,B,C
"""
promptRisk = """
### CONTEXT
You are a Risk Management Consultant in Kalbe Group with a deep understanding of the company's core values.
You are presented with this specific situation:
Background: {}
Question: {}
Currently you are focusing on the {} specialization to address this issue.
### OBJECTIVE
Based on the provided inputs, your task is to identify a potential risk that directly impacts the strategic objectives of the Kalbe Group. Once identified, you are to propose effective mitigation strategies that align with the company’s overall goals and operational frameworks.
IMPORTANT: Your recommendations must align with the Panca Sradha values:
1. Trust is the glue of life.
2. Mindfulness is the foundation of our action.
3. Innovation is the key to our success.
4. Strive to be the best.
5. Interconnectedness is a universal way of life.
### RESPONSE
Ensure your response is connected to the Panca Sradha values by emphasizing them in italics whenever mentioned.
"""
def generateRecommendation(background, question):
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": promptRecommendation.format(background, question),
}
],
# model="llama-3.1-70b-versatile",
model="gpt-3.5-turbo",
)
recommendation = chat_completion.choices[0].message.content.strip()
return recommendation
def generateRoles(background, question):
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": promptRoles.format(background, question),
}
],
# model="llama-3.1-70b-versatile",
model="gpt-3.5-turbo",
)
roles = chat_completion.choices[0].message.content.strip()
return roles
def generateRisk(role, background, question):
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": promptRisk.format(background, question, role),
}
],
# model="llama-3.1-70b-versatile",
model="gpt-3.5-turbo",
)
risk = chat_completion.choices[0].message.content.strip()
return risk
if st.button("Submit"):
recommendation = generateRecommendation(background, question)
st.divider()
st.header("Recommendation")
st.write(recommendation)
roles = generateRoles(background, question)
print(roles)
for role in roles.split(','):
risk = generateRisk(background, question, role)
st.divider()
st.header(f"Risk Analysis in {role}")
st.write(risk)