Spaces:
Sleeping
Sleeping
File size: 5,402 Bytes
1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae 1eb54c9 2739fae |
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
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)
|