Spaces:
Sleeping
Sleeping
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 | |
Begin your answer with a comprehensive overview of the recommendation in one paragraph. After that, provide five specific recommendations, each based on one of the Panca Sradha values. There is no need to include a conclusion at the end. | |
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 five 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 five NAMES of SELECTED DEPARTMENTS separated by commas. | |
Example: AAA, BBB, CCC | |
""" | |
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 have five departments, each with its own specialization in risk-based assessment. The departments are: {}. | |
### OBJECTIVE | |
Based on the provided inputs, your task is to identify a potential risk that directly impacts the strategic objectives of the Kalbe Group for each department. | |
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 one or more of 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 | |
Please provide your response in bullet points, outlining the key points for each department. Each keypoints should include a paragraph description. | |
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-4o", | |
) | |
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-4o", | |
) | |
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-4o", | |
) | |
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) | |
risk = generateRisk(background, question, roles) | |
st.divider() | |
st.header(f"Risk Analysis") | |
st.write(risk) | |
# for role in roles.split(','): | |
# risk = generateRisk(background, question, role) | |
# st.divider() | |
# st.header(f"Risk Analysis in {role}") | |
# st.write(risk) | |