Zekun Wu
commited on
Commit
•
8571ccc
1
Parent(s):
c0df0d4
update
Browse files
app.py
CHANGED
@@ -1,479 +1,3 @@
|
|
1 |
-
# import streamlit as st
|
2 |
-
# import os
|
3 |
-
# import json
|
4 |
-
# from openai import AzureOpenAI
|
5 |
-
# from model import invoke, create_models, configure_settings, load_documents_and_create_index, \
|
6 |
-
# create_chat_prompt_template, execute_query
|
7 |
-
#
|
8 |
-
# client = AzureOpenAI(azure_endpoint = "https://personalityanalysisfinetuning.openai.azure.com/",api_key=os.environ.get("AZURE_OPENAI_KEY"), api_version="2024-02-01")
|
9 |
-
#
|
10 |
-
#
|
11 |
-
# example_profile = {
|
12 |
-
# "Team": [
|
13 |
-
# {
|
14 |
-
# "name": "JAMES ARTHUR",
|
15 |
-
# "main_profile": {
|
16 |
-
# "VISION": {
|
17 |
-
# "score": 76
|
18 |
-
# },
|
19 |
-
# "IDEATION": {
|
20 |
-
# "score": 73
|
21 |
-
# },
|
22 |
-
# "OPPORTUNISM": {
|
23 |
-
# "score": 78
|
24 |
-
# },
|
25 |
-
# "DRIVE": {
|
26 |
-
# "score": 80
|
27 |
-
# },
|
28 |
-
# "RESILIENCE": {
|
29 |
-
# "score": 75
|
30 |
-
# }
|
31 |
-
# },
|
32 |
-
# "red_flag": {
|
33 |
-
# "HUBRIS": {
|
34 |
-
# "score": 80
|
35 |
-
# },
|
36 |
-
# "MERCURIAL": {
|
37 |
-
# "score": 28
|
38 |
-
# },
|
39 |
-
# "DOMINANT": {
|
40 |
-
# "score": 70
|
41 |
-
# },
|
42 |
-
# "MACHIAVELLIAN": {
|
43 |
-
# "score": 50
|
44 |
-
# }
|
45 |
-
# }
|
46 |
-
# },
|
47 |
-
# {
|
48 |
-
# "name": "LOUSIE HART",
|
49 |
-
# "main_profile": {
|
50 |
-
# "VISION": {
|
51 |
-
# "score": 55
|
52 |
-
# },
|
53 |
-
# "IDEATION": {
|
54 |
-
# "score": 60
|
55 |
-
# },
|
56 |
-
# "OPPORTUNISM": {
|
57 |
-
# "score": 65
|
58 |
-
# },
|
59 |
-
# "DRIVE": {
|
60 |
-
# "score": 70
|
61 |
-
# },
|
62 |
-
# "RESILIENCE": {
|
63 |
-
# "score": 72
|
64 |
-
# }
|
65 |
-
# },
|
66 |
-
# "red_flag": {
|
67 |
-
# "HUBRIS": {
|
68 |
-
# "score": 55
|
69 |
-
# },
|
70 |
-
# "MERCURIAL": {
|
71 |
-
# "score": 25
|
72 |
-
# },
|
73 |
-
# "DOMINANT": {
|
74 |
-
# "score": 67
|
75 |
-
# },
|
76 |
-
# "MACHIAVELLIAN": {
|
77 |
-
# "score": 30
|
78 |
-
# }
|
79 |
-
# }
|
80 |
-
# },
|
81 |
-
# {
|
82 |
-
# "name": "SIMONE LEVY",
|
83 |
-
# "main_profile": {
|
84 |
-
# "VISION": {
|
85 |
-
# "score": 30
|
86 |
-
# },
|
87 |
-
# "IDEATION": {
|
88 |
-
# "score": 45
|
89 |
-
# },
|
90 |
-
# "OPPORTUNISM": {
|
91 |
-
# "score": 20
|
92 |
-
# },
|
93 |
-
# "DRIVE": {
|
94 |
-
# "score": 50
|
95 |
-
# },
|
96 |
-
# "RESILIENCE": {
|
97 |
-
# "score": 32
|
98 |
-
# }
|
99 |
-
# },
|
100 |
-
# "red_flag": {
|
101 |
-
# "HUBRIS": {
|
102 |
-
# "score": 20
|
103 |
-
# },
|
104 |
-
# "MERCURIAL": {
|
105 |
-
# "score": 15
|
106 |
-
# },
|
107 |
-
# "DOMINANT": {
|
108 |
-
# "score": 18
|
109 |
-
# },
|
110 |
-
# "MACHIAVELLIAN": {
|
111 |
-
# "score": 25
|
112 |
-
# }
|
113 |
-
# }
|
114 |
-
# },
|
115 |
-
# {
|
116 |
-
# "name": "Uri Lef",
|
117 |
-
# "main_profile": {
|
118 |
-
# "VISION": {
|
119 |
-
# "score": 70
|
120 |
-
# },
|
121 |
-
# "IDEATION": {
|
122 |
-
# "score": 68
|
123 |
-
# },
|
124 |
-
# "OPPORTUNISM": {
|
125 |
-
# "score": 73
|
126 |
-
# },
|
127 |
-
# "DRIVE": {
|
128 |
-
# "score": 65
|
129 |
-
# },
|
130 |
-
# "RESILIENCE": {
|
131 |
-
# "score": 30
|
132 |
-
# }
|
133 |
-
# },
|
134 |
-
# "red_flag": {
|
135 |
-
# "HUBRIS": {
|
136 |
-
# "score": 55
|
137 |
-
# },
|
138 |
-
# "MERCURIAL": {
|
139 |
-
# "score": 72
|
140 |
-
# },
|
141 |
-
# "DOMINANT": {
|
142 |
-
# "score": 68
|
143 |
-
# },
|
144 |
-
# "MACHIAVELLIAN": {
|
145 |
-
# "score": 50
|
146 |
-
# }
|
147 |
-
# }
|
148 |
-
# }
|
149 |
-
# ]
|
150 |
-
# }
|
151 |
-
#
|
152 |
-
# # Function to generate a completion using OpenAI API
|
153 |
-
# # def generate_one_completion(message, temperature):
|
154 |
-
# # response = client.chat.completions.create(
|
155 |
-
# # model="personality_gpt4o",
|
156 |
-
# # temperature=temperature,
|
157 |
-
# # max_tokens=1000, # Adjust based on desired response length
|
158 |
-
# # frequency_penalty=0.2, # To avoid repetition
|
159 |
-
# # presence_penalty=0.2, # To introduce new topics
|
160 |
-
# # messages= message,
|
161 |
-
# # stream=False
|
162 |
-
# # )
|
163 |
-
# #
|
164 |
-
# # return response
|
165 |
-
#
|
166 |
-
# import json
|
167 |
-
#
|
168 |
-
# def generate_prompt_from_profile(profile, version="TeamSummary"):
|
169 |
-
# with open('prompts.json') as f:
|
170 |
-
# prompt_sets = json.load(f)['Prompts']
|
171 |
-
# prompt_templates = prompt_sets[version]
|
172 |
-
#
|
173 |
-
# try:
|
174 |
-
# team_members = profile['Team']
|
175 |
-
#
|
176 |
-
# team_member_profiles = []
|
177 |
-
# for member in team_members:
|
178 |
-
# profile = f"{member['name']}: Main Profile - VISION: {member['main_profile']['VISION']['score']}, " \
|
179 |
-
# f"IDEATION: {member['main_profile']['IDEATION']['score']}, " \
|
180 |
-
# f"OPPORTUNISM: {member['main_profile']['OPPORTUNISM']['score']}, " \
|
181 |
-
# f"DRIVE: {member['main_profile']['DRIVE']['score']}, " \
|
182 |
-
# f"RESILIENCE: {member['main_profile']['RESILIENCE']['score']}. " \
|
183 |
-
# f"Red Flags - HUBRIS: {member['red_flag']['HUBRIS']['score']}, " \
|
184 |
-
# f"MERCURIAL: {member['red_flag']['MERCURIAL']['score']}, " \
|
185 |
-
# f"DOMINANT: {member['red_flag']['DOMINANT']['score']}, " \
|
186 |
-
# f"MACHIAVELLIAN: {member['red_flag']['MACHIAVELLIAN']['score']}."
|
187 |
-
# team_member_profiles.append(profile)
|
188 |
-
#
|
189 |
-
# # Join the team member profiles into a single string
|
190 |
-
# team_member_profiles_str = "\n".join(team_member_profiles)
|
191 |
-
#
|
192 |
-
# prompt = "\n".join(prompt_templates).replace("{{TEAM_MEMBERS}}", team_member_profiles_str)
|
193 |
-
#
|
194 |
-
# print(prompt)
|
195 |
-
#
|
196 |
-
#
|
197 |
-
# except KeyError as e:
|
198 |
-
# return [{"role": "system", "content": f"Error processing profile data: missing {str(e)}"}]
|
199 |
-
#
|
200 |
-
# message = [
|
201 |
-
# {"role": "system", "content": prompt_sets["System"][0]},
|
202 |
-
# {"role": "user", "content": prompt}
|
203 |
-
# ]
|
204 |
-
# print(prompt)
|
205 |
-
#
|
206 |
-
# return message
|
207 |
-
#
|
208 |
-
#
|
209 |
-
# def display_profile_info(profile):
|
210 |
-
#
|
211 |
-
# st.markdown("### Profile Information:")
|
212 |
-
# team_members = profile["Team"]
|
213 |
-
# for member in team_members:
|
214 |
-
# st.sidebar.markdown(f"#### {member['name']}")
|
215 |
-
# main_profile = member["main_profile"]
|
216 |
-
# red_flag = member["red_flag"]
|
217 |
-
# st.sidebar.markdown("### Main Profile:")
|
218 |
-
# st.sidebar.markdown("\n".join([f"- **{attribute}**: {details['score']}" for attribute, details in main_profile.items()]))
|
219 |
-
# st.sidebar.markdown("### Red Flags:")
|
220 |
-
# st.sidebar.markdown("\n".join([f"- **{attribute}**: {details['score']}" for attribute, details in red_flag.items()]))
|
221 |
-
#
|
222 |
-
# # def validate_json(profile):
|
223 |
-
# # required_keys = ['Team']
|
224 |
-
# # for key in required_keys:
|
225 |
-
# # if key not in profile:
|
226 |
-
# # return False, f"Key '{key}' is missing."
|
227 |
-
# # if not isinstance(profile[key], dict):
|
228 |
-
# # return False, f"'{key}' should be a dictionary."
|
229 |
-
# # return True, "JSON structure is valid."
|
230 |
-
# def logout():
|
231 |
-
# st.session_state['authenticated'] = False
|
232 |
-
# st.session_state['profile'] = None
|
233 |
-
# st.session_state['show_chat'] = None
|
234 |
-
# st.session_state['analysis'] = None
|
235 |
-
# st.rerun()
|
236 |
-
#
|
237 |
-
#
|
238 |
-
# def main_app():
|
239 |
-
#
|
240 |
-
# sidebar_components()
|
241 |
-
#
|
242 |
-
# if st.button('Logout'):
|
243 |
-
# logout()
|
244 |
-
#
|
245 |
-
# # Streamlit app
|
246 |
-
# st.title('Metaprofiling\'s Career Insight Analyzer Demo')
|
247 |
-
#
|
248 |
-
#
|
249 |
-
# # Check if a profile is selected
|
250 |
-
# if st.session_state['profile']:
|
251 |
-
# profile = st.session_state['profile']
|
252 |
-
# display_profile_info(profile) # Display the profile information
|
253 |
-
#
|
254 |
-
# st.markdown("""
|
255 |
-
# ### Generation Temperature
|
256 |
-
# Adjust the 'Generation Temperature' to control the creativity of the AI responses.
|
257 |
-
# - A *lower temperature* (closer to 0.0) generates more predictable, conservative responses.
|
258 |
-
# - A *higher temperature* (closer to 1.0) generates more creative, diverse responses.
|
259 |
-
# """)
|
260 |
-
# # Temperature slider
|
261 |
-
# st.session_state['temperature'] = st.slider("",min_value=0.0, max_value=1.0, value=0.5, step=0.01)
|
262 |
-
#
|
263 |
-
# # Allow user to choose from different versions of the prompt
|
264 |
-
# st.session_state['version'] = st.selectbox("Select Prompt Version", ["TDOS"])
|
265 |
-
# # Generate and display prompt
|
266 |
-
#
|
267 |
-
# if st.button(f'Analyze Profile ({st.session_state["version"]})'):
|
268 |
-
# #with st.spinner('Generating completion...'):
|
269 |
-
# prompt = generate_prompt_from_profile(profile, version=st.session_state['version'])
|
270 |
-
#
|
271 |
-
# meta_eip_prefix = """# META: Entrepreneurial and Intrapreneurial Potential\nMETA evaluates five traits essential for
|
272 |
-
# entrepreneurial success: Vision, Ideation, Opportunism, Drive, and Resilience. It also measures four ‘Red
|
273 |
-
# Flags’ or derailers common to the entrepreneurial personality."""
|
274 |
-
#
|
275 |
-
# with st.chat_message("assistant"):
|
276 |
-
# stream = client.chat.completions.create(
|
277 |
-
# model="personality_gpt4o",
|
278 |
-
# temperature=st.session_state['temperature'],
|
279 |
-
# max_tokens=3000, # Adjust based on desired response length
|
280 |
-
# frequency_penalty=0.2, # To avoid repetition
|
281 |
-
# presence_penalty=0.2, # To introduce new topics
|
282 |
-
# messages= prompt,
|
283 |
-
# stream=True)
|
284 |
-
#
|
285 |
-
# if st.session_state['version'] == "METAEIP":
|
286 |
-
# st.write(meta_eip_prefix)
|
287 |
-
#
|
288 |
-
# response = st.write_stream(stream)
|
289 |
-
# #st.markdown(response_test_taker)
|
290 |
-
#
|
291 |
-
# st.session_state['analysis'] = response
|
292 |
-
# st.session_state['show_chat'] = True
|
293 |
-
# st.rerun()
|
294 |
-
#
|
295 |
-
# # display the response
|
296 |
-
# if st.session_state['analysis']:
|
297 |
-
# st.markdown(st.session_state['analysis'])
|
298 |
-
#
|
299 |
-
# else:
|
300 |
-
# st.write("Please upload a profile JSON file or use the example profile.")
|
301 |
-
#
|
302 |
-
#
|
303 |
-
# # Function to verify credentials and set the session state
|
304 |
-
# def verify_credentials():
|
305 |
-
# if st.session_state['username'] == os.getenv("username_app") and st.session_state['password'] == os.getenv("password_app"):
|
306 |
-
# st.session_state['authenticated'] = True
|
307 |
-
# else:
|
308 |
-
# st.error("Invalid username or password")
|
309 |
-
#
|
310 |
-
#
|
311 |
-
# # Login page
|
312 |
-
# def login_page():
|
313 |
-
#
|
314 |
-
# st.title("Welcome to Metaprofiling's Career Insight Analyzer Demo")
|
315 |
-
# st.write("This application provides in-depth analysis and insights into professional profiles. Please log in to continue.")
|
316 |
-
#
|
317 |
-
# # Description and Instructions
|
318 |
-
# st.markdown("""
|
319 |
-
# ## How to Use This Application
|
320 |
-
# - Enter your username and password in the sidebar.
|
321 |
-
# - Click on 'Login' to access the application.
|
322 |
-
# - Once logged in, you will be able to upload and analyze professional profiles.
|
323 |
-
# """)
|
324 |
-
#
|
325 |
-
# st.sidebar.write("Login:")
|
326 |
-
# username = st.sidebar.text_input("Username")#, key='username')
|
327 |
-
# password = st.sidebar.text_input("Password", type="password")#, key='password')
|
328 |
-
#
|
329 |
-
# st.session_state['username'] = username
|
330 |
-
# st.session_state['password'] = password
|
331 |
-
# st.sidebar.button("Login", on_click=verify_credentials)
|
332 |
-
#
|
333 |
-
# def sidebar_components():
|
334 |
-
# with st.sidebar:
|
335 |
-
# if st.button('Reset'):
|
336 |
-
# st.session_state['profile'] = None
|
337 |
-
# st.session_state['show_chat'] = None
|
338 |
-
# st.session_state['analysis'] = None
|
339 |
-
# st.rerun()
|
340 |
-
#
|
341 |
-
# if not st.session_state['show_chat']:
|
342 |
-
# # Instructions for JSON format
|
343 |
-
# st.markdown("### JSON File Requirements:")
|
344 |
-
# st.markdown("1. Must contain Team as top-level keys.")
|
345 |
-
# st.markdown("2. Both keys should have dictionary values.")
|
346 |
-
#
|
347 |
-
# # File uploader
|
348 |
-
# st.markdown("### Upload a profile JSON file")
|
349 |
-
# uploaded_file = st.file_uploader("", type=['json'])
|
350 |
-
#
|
351 |
-
# if uploaded_file is not None:
|
352 |
-
# try:
|
353 |
-
# profile_data = json.load(uploaded_file)
|
354 |
-
# #valid, message = validate_json(profile_data)
|
355 |
-
# #if valid:
|
356 |
-
# st.session_state['profile'] = profile_data
|
357 |
-
# #else:
|
358 |
-
# #st.error(message)
|
359 |
-
# except json.JSONDecodeError:
|
360 |
-
# st.error("Invalid JSON file. Please upload a valid JSON file.")
|
361 |
-
#
|
362 |
-
# # Button to load example profile
|
363 |
-
# if st.button('Use Example Profile'):
|
364 |
-
# st.session_state['profile'] = example_profile
|
365 |
-
#
|
366 |
-
# # elif uploaded_file is not None:
|
367 |
-
# # st.session_state['profile'] = json.load(uploaded_file)
|
368 |
-
# else:
|
369 |
-
# st.sidebar.title("Chat with Our Career Advisor")
|
370 |
-
# st.sidebar.markdown("Hello, we hope you learned something about yourself in this report. This chat is here so you can ask any questions you have about your report! It’s also a great tool to get ideas about how you can use the information in your report for your personal development and achieving your current goals.")
|
371 |
-
#
|
372 |
-
#
|
373 |
-
#
|
374 |
-
# # List of question templates where {} will be replaced with the name
|
375 |
-
# question_templates = [
|
376 |
-
# "What are the main risks associated with {}’s profile?",
|
377 |
-
# "What are the implications of {}’s profile for working with others?",
|
378 |
-
# "What conclusions might we draw from his profile about {}’s style of leadership?",
|
379 |
-
# "Looking specifically at {}'s Red Flags, are there any particular areas of concern?",
|
380 |
-
# "Based on this profile, is {} better suited as a COO or a CEO?",
|
381 |
-
# "If speed of execution is important, based on his profile, how likely is {} to be able to achieve this?",
|
382 |
-
# "How is {} likely to react to business uncertainty and disruption?",
|
383 |
-
# "Based on his profile, what should a coaching plan designed for {} focus on?"
|
384 |
-
# ]
|
385 |
-
#
|
386 |
-
# # Formatting each question template with the name
|
387 |
-
# questions_list = [question.format("Test Taker") for question in question_templates]
|
388 |
-
#
|
389 |
-
# # Prepare the questions for Markdown display
|
390 |
-
# questions_markdown = "\n\n".join(
|
391 |
-
# [f"Q{index + 1}: {question}" for index, question in enumerate(questions_list)])
|
392 |
-
#
|
393 |
-
# # Code to display in the app
|
394 |
-
# st.sidebar.markdown("### Suggest Questions")
|
395 |
-
# st.sidebar.markdown(questions_markdown)
|
396 |
-
#
|
397 |
-
# # st.sidebar.text_area("Suggested Questions", value=questions.choices[0].message.content, height=200, disabled=True)
|
398 |
-
#
|
399 |
-
# user_input = st.sidebar.text_input("Ask a question about the profile analysis:")
|
400 |
-
#
|
401 |
-
# llm, embed_model = create_models()
|
402 |
-
# configure_settings(llm, embed_model)
|
403 |
-
# index = load_documents_and_create_index()
|
404 |
-
#
|
405 |
-
# if st.sidebar.button('Submit'):
|
406 |
-
# if user_input:
|
407 |
-
# # with open('prompts.json') as f:
|
408 |
-
# # prompt_sets = json.load(f)['Prompts']
|
409 |
-
# # instruction = prompt_sets['Question']
|
410 |
-
#
|
411 |
-
#
|
412 |
-
# # instruction = (
|
413 |
-
# # "You are a knowledgeable advisor providing insights based on the specific analysis provided earlier. "
|
414 |
-
# # "Your responses should around 100 words, directly relate to the user's question, drawing on relevant details from the analysis. "
|
415 |
-
# # "If the user's question does not pertain to the analysis or is beyond the scope of the information provided, "
|
416 |
-
# # "politely decline to answer, stating that the question is outside the analysis context. Focus on delivering "
|
417 |
-
# # "concise, accurate, insightful, and relevant information. \n\n"
|
418 |
-
# # "Question: " + user_input
|
419 |
-
# # )
|
420 |
-
#
|
421 |
-
# # message = generate_prompt_from_profile(st.session_state['profile'])
|
422 |
-
# # message.append({"role": "system", "content": st.session_state['analysis']})
|
423 |
-
# # message.append({"role": "user", "content": "\n".join(instruction).replace('{{QUESTION}}', user_input)})
|
424 |
-
#
|
425 |
-
# # with st.chat_message("assistant"):
|
426 |
-
# # stream = client.chat.completions.create(
|
427 |
-
# # model="personality_gpt4",
|
428 |
-
# # temperature=st.session_state['temperature'],
|
429 |
-
# # max_tokens=500, # Adjust based on desired response length
|
430 |
-
# # frequency_penalty=0.2, # To avoid repetition
|
431 |
-
# # presence_penalty=0.2, # To introduce new topics
|
432 |
-
# # messages=message,
|
433 |
-
# # stream=True
|
434 |
-
# # )
|
435 |
-
#
|
436 |
-
# chat_prompt_template = create_chat_prompt_template(st.session_state['analysis'])
|
437 |
-
# response = execute_query(index, chat_prompt_template, user_input)
|
438 |
-
#
|
439 |
-
# #response = st.write_stream(stream)
|
440 |
-
#
|
441 |
-
#
|
442 |
-
# # output = generate_one_completion(message,st.session_state['temperature'])
|
443 |
-
# #
|
444 |
-
# # #st.sidebar.text_area("Response", value=output.choices[0].message.content, height=200, disabled=True)
|
445 |
-
# st.sidebar.markdown(response)
|
446 |
-
#
|
447 |
-
# # Display the sidebar components based on the state
|
448 |
-
# if 'show_chat' not in st.session_state:
|
449 |
-
# st.session_state['show_chat'] = None
|
450 |
-
#
|
451 |
-
# if 'profile' not in st.session_state:
|
452 |
-
# st.session_state['profile'] = None
|
453 |
-
#
|
454 |
-
# if 'analysis' not in st.session_state:
|
455 |
-
# st.session_state['analysis'] = None
|
456 |
-
#
|
457 |
-
# if 'temperature' not in st.session_state:
|
458 |
-
# st.session_state['temperature'] = 0
|
459 |
-
#
|
460 |
-
# if 'version' not in st.session_state:
|
461 |
-
# st.session_state['version'] = ""
|
462 |
-
#
|
463 |
-
# # Initialize session state for username, password, and authentication
|
464 |
-
# if 'username' not in st.session_state:
|
465 |
-
# st.session_state['username'] = ''
|
466 |
-
# if 'password' not in st.session_state:
|
467 |
-
# st.session_state['password'] = ''
|
468 |
-
# if 'authenticated' not in st.session_state:
|
469 |
-
# st.session_state['authenticated'] = False
|
470 |
-
# # Show login or main app based on authentication
|
471 |
-
# if st.session_state['authenticated']:
|
472 |
-
# main_app()
|
473 |
-
# else:
|
474 |
-
# login_page()
|
475 |
-
|
476 |
-
|
477 |
import streamlit as st
|
478 |
import os
|
479 |
import json
|
@@ -481,6 +5,10 @@ from openai import AzureOpenAI
|
|
481 |
from model import invoke, create_models, configure_settings, load_documents_and_create_index, \
|
482 |
create_chat_prompt_template, execute_query
|
483 |
|
|
|
|
|
|
|
|
|
484 |
client = AzureOpenAI(azure_endpoint="https://personalityanalysisfinetuning.openai.azure.com/", api_key=os.environ.get("AZURE_OPENAI_KEY"), api_version="2024-02-01")
|
485 |
|
486 |
# Example profile (as before)
|
@@ -612,9 +140,7 @@ def main_app():
|
|
612 |
if st.button(f'Analyze Profile ({st.session_state["version"]})'):
|
613 |
prompt = generate_prompt_from_profile(profile, selected_members, version=st.session_state['version'])
|
614 |
|
615 |
-
|
616 |
-
entrepreneurial success: Vision, Ideation, Opportunism, Drive, and Resilience. It also measures four ‘Red
|
617 |
-
Flags’ or derailers common to the entrepreneurial personality."""
|
618 |
|
619 |
with st.chat_message("assistant"):
|
620 |
stream = client.chat.completions.create(
|
@@ -637,6 +163,7 @@ def main_app():
|
|
637 |
st.rerun()
|
638 |
|
639 |
if st.session_state['analysis']:
|
|
|
640 |
st.markdown(st.session_state['analysis'])
|
641 |
|
642 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import json
|
|
|
5 |
from model import invoke, create_models, configure_settings, load_documents_and_create_index, \
|
6 |
create_chat_prompt_template, execute_query
|
7 |
|
8 |
+
meta_eip_prefix = """# META: Entrepreneurial and Intrapreneurial Potential\nMETA evaluates five traits essential for
|
9 |
+
entrepreneurial success: Vision, Ideation, Opportunism, Drive, and Resilience. It also measures four ‘Red
|
10 |
+
Flags’ or derailers common to the entrepreneurial personality."""
|
11 |
+
|
12 |
client = AzureOpenAI(azure_endpoint="https://personalityanalysisfinetuning.openai.azure.com/", api_key=os.environ.get("AZURE_OPENAI_KEY"), api_version="2024-02-01")
|
13 |
|
14 |
# Example profile (as before)
|
|
|
140 |
if st.button(f'Analyze Profile ({st.session_state["version"]})'):
|
141 |
prompt = generate_prompt_from_profile(profile, selected_members, version=st.session_state['version'])
|
142 |
|
143 |
+
|
|
|
|
|
144 |
|
145 |
with st.chat_message("assistant"):
|
146 |
stream = client.chat.completions.create(
|
|
|
163 |
st.rerun()
|
164 |
|
165 |
if st.session_state['analysis']:
|
166 |
+
st.write(meta_eip_prefix)
|
167 |
st.markdown(st.session_state['analysis'])
|
168 |
|
169 |
else:
|