Spaces:
Sleeping
Sleeping
fadliaulawi
commited on
Commit
•
2739fae
1
Parent(s):
35ec6fd
Update new agentic flow
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import os
|
|
3 |
|
4 |
from groq import Groq
|
5 |
from dotenv import load_dotenv
|
|
|
6 |
|
7 |
load_dotenv()
|
8 |
|
@@ -15,20 +16,27 @@ The application will generate two outputs: a detailed recommendation and a corre
|
|
15 |
""")
|
16 |
|
17 |
# Input text boxes
|
18 |
-
|
19 |
-
|
20 |
|
21 |
client = Groq(
|
22 |
api_key=os.environ['GROQ_API_KEY'],
|
23 |
)
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
26 |
You are a company consultant in Kalbe Group with a deep understanding of the company's core values, known as Panca Sradha.
|
27 |
-
Your task is to provide strategic recommendations and mitigated risks based on the following inputs:
|
28 |
|
|
|
29 |
Background: {}
|
30 |
Question: {}
|
31 |
|
|
|
|
|
32 |
IMPORTANT: Your recommendations must align with the Panca Sradha values:
|
33 |
|
34 |
1. Trust is the glue of life.
|
@@ -37,30 +45,119 @@ IMPORTANT: Your recommendations must align with the Panca Sradha values:
|
|
37 |
4. Strive to be the best.
|
38 |
5. Interconnectedness is a universal way of life.
|
39 |
|
|
|
|
|
|
|
40 |
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
|
|
46 |
Ensure your response is connected to the Panca Sradha values by emphasizing them in italics whenever mentioned.
|
47 |
"""
|
48 |
|
49 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
chat_completion = client.chat.completions.create(
|
52 |
messages=[
|
53 |
{
|
54 |
"role": "user",
|
55 |
-
"content":
|
56 |
}
|
57 |
],
|
58 |
-
model="llama-3.1-70b-versatile",
|
|
|
59 |
)
|
60 |
-
|
61 |
|
62 |
-
return
|
63 |
|
64 |
if st.button("Submit"):
|
65 |
-
|
66 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
from groq import Groq
|
5 |
from dotenv import load_dotenv
|
6 |
+
from openai import OpenAI
|
7 |
|
8 |
load_dotenv()
|
9 |
|
|
|
16 |
""")
|
17 |
|
18 |
# Input text boxes
|
19 |
+
background = st.text_area("Background", height=200)
|
20 |
+
question = st.text_area("Question", height=50)
|
21 |
|
22 |
client = Groq(
|
23 |
api_key=os.environ['GROQ_API_KEY'],
|
24 |
)
|
25 |
|
26 |
+
client = OpenAI(
|
27 |
+
api_key=os.environ.get("OPENAI_API_KEY"),
|
28 |
+
)
|
29 |
+
|
30 |
+
promptRecommendation = """
|
31 |
+
### CONTEXT
|
32 |
You are a company consultant in Kalbe Group with a deep understanding of the company's core values, known as Panca Sradha.
|
|
|
33 |
|
34 |
+
You are presented with this specific situation:
|
35 |
Background: {}
|
36 |
Question: {}
|
37 |
|
38 |
+
### OBJECTIVE
|
39 |
+
Based on these inputs, your task is to give a recommendation, a detailed suggestion that aligns with Kalbe Group's strategic objectives.
|
40 |
IMPORTANT: Your recommendations must align with the Panca Sradha values:
|
41 |
|
42 |
1. Trust is the glue of life.
|
|
|
45 |
4. Strive to be the best.
|
46 |
5. Interconnectedness is a universal way of life.
|
47 |
|
48 |
+
### RESPONSE
|
49 |
+
Ensure your response is connected to the Panca Sradha values by emphasizing them in italics whenever mentioned.
|
50 |
+
"""
|
51 |
|
52 |
+
promptRoles = """
|
53 |
+
### CONTEXT
|
54 |
+
As the Head of Risk Management Consultant at Kalbe Group, you oversee various department specializations including:
|
55 |
+
|
56 |
+
- Legal
|
57 |
+
- Human Resources
|
58 |
+
- Research and Development
|
59 |
+
- Production
|
60 |
+
- Sales and Marketing
|
61 |
+
- Information Technology
|
62 |
+
- Finance and Accounting
|
63 |
+
- Business Development
|
64 |
+
- Compliance and Regulatory
|
65 |
+
- External Communications
|
66 |
+
|
67 |
+
You are presented with this specific situation:
|
68 |
+
Background: {}
|
69 |
+
Question: {}
|
70 |
|
71 |
+
### OBJECTIVE
|
72 |
+
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.
|
73 |
+
|
74 |
+
### RESPONSE
|
75 |
+
Please respond by only listing the three selected departments separated by commas.
|
76 |
+
Example: A,B,C
|
77 |
+
"""
|
78 |
+
|
79 |
+
promptRisk = """
|
80 |
+
### CONTEXT
|
81 |
+
You are a Risk Management Consultant in Kalbe Group with a deep understanding of the company's core values.
|
82 |
+
|
83 |
+
You are presented with this specific situation:
|
84 |
+
Background: {}
|
85 |
+
Question: {}
|
86 |
+
|
87 |
+
Currently you are focusing on the {} specialization to address this issue.
|
88 |
+
|
89 |
+
### OBJECTIVE
|
90 |
+
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.
|
91 |
+
IMPORTANT: Your recommendations must align with the Panca Sradha values:
|
92 |
+
|
93 |
+
1. Trust is the glue of life.
|
94 |
+
2. Mindfulness is the foundation of our action.
|
95 |
+
3. Innovation is the key to our success.
|
96 |
+
4. Strive to be the best.
|
97 |
+
5. Interconnectedness is a universal way of life.
|
98 |
|
99 |
+
### RESPONSE
|
100 |
Ensure your response is connected to the Panca Sradha values by emphasizing them in italics whenever mentioned.
|
101 |
"""
|
102 |
|
103 |
+
def generateRecommendation(background, question):
|
104 |
+
|
105 |
+
chat_completion = client.chat.completions.create(
|
106 |
+
messages=[
|
107 |
+
{
|
108 |
+
"role": "user",
|
109 |
+
"content": promptRecommendation.format(background, question),
|
110 |
+
}
|
111 |
+
],
|
112 |
+
# model="llama-3.1-70b-versatile",
|
113 |
+
model="gpt-3.5-turbo",
|
114 |
+
)
|
115 |
+
recommendation = chat_completion.choices[0].message.content.strip()
|
116 |
+
|
117 |
+
return recommendation
|
118 |
+
|
119 |
+
def generateRoles(background, question):
|
120 |
+
|
121 |
+
chat_completion = client.chat.completions.create(
|
122 |
+
messages=[
|
123 |
+
{
|
124 |
+
"role": "user",
|
125 |
+
"content": promptRoles.format(background, question),
|
126 |
+
}
|
127 |
+
],
|
128 |
+
# model="llama-3.1-70b-versatile",
|
129 |
+
model="gpt-3.5-turbo",
|
130 |
+
)
|
131 |
+
roles = chat_completion.choices[0].message.content.strip()
|
132 |
+
|
133 |
+
return roles
|
134 |
+
|
135 |
+
def generateRisk(role, background, question):
|
136 |
|
137 |
chat_completion = client.chat.completions.create(
|
138 |
messages=[
|
139 |
{
|
140 |
"role": "user",
|
141 |
+
"content": promptRisk.format(background, question, role),
|
142 |
}
|
143 |
],
|
144 |
+
# model="llama-3.1-70b-versatile",
|
145 |
+
model="gpt-3.5-turbo",
|
146 |
)
|
147 |
+
risk = chat_completion.choices[0].message.content.strip()
|
148 |
|
149 |
+
return risk
|
150 |
|
151 |
if st.button("Submit"):
|
152 |
+
recommendation = generateRecommendation(background, question)
|
153 |
+
st.divider()
|
154 |
+
st.header("Recommendation")
|
155 |
+
st.write(recommendation)
|
156 |
+
|
157 |
+
roles = generateRoles(background, question)
|
158 |
+
print(roles)
|
159 |
+
for role in roles.split(','):
|
160 |
+
risk = generateRisk(background, question, role)
|
161 |
+
st.divider()
|
162 |
+
st.header(f"Risk Analysis in {role}")
|
163 |
+
st.write(risk)
|