IAMTFRMZA commited on
Commit
d25fa67
·
verified ·
1 Parent(s): 35da82e
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -26,7 +26,7 @@ SUPPORTED_AUDIO_FORMATS = (".mp3", ".wav", ".m4a")
26
  SUPPORTED_TEXT_FORMATS = (".txt", ".docx", ".csv", ".xlsx", ".pdf")
27
 
28
 
29
- def contract_chat_section(tab, assistant_id):
30
  with tab:
31
  st.subheader("Chat")
32
 
@@ -36,19 +36,19 @@ def contract_chat_section(tab, assistant_id):
36
  st.error("Please enter your C2 Group of Technologies Access Key to continue.")
37
  st.stop()
38
 
39
- if "messages" not in st.session_state:
40
- st.session_state["messages"] = []
41
 
42
- if st.button("Clear Chat"):
43
- st.session_state["messages"] = []
44
  st.rerun()
45
 
46
- for message in st.session_state.messages:
47
  role, content = message["role"], message["content"]
48
  st.chat_message(role).write(content)
49
 
50
  if prompt := st.chat_input():
51
- st.session_state.messages.append({"role": "user", "content": prompt})
52
  st.chat_message("user").write(prompt)
53
 
54
  try:
@@ -74,7 +74,7 @@ def contract_chat_section(tab, assistant_id):
74
  messages = client.beta.threads.messages.list(thread_id=thread_id)
75
  assistant_message = messages.data[0].content[0].text.value
76
  st.chat_message("assistant").write(assistant_message)
77
- st.session_state.messages.append({"role": "assistant", "content": assistant_message})
78
  except Exception as e:
79
  st.error(f"Error: {str(e)}")
80
 
@@ -82,10 +82,10 @@ ASSISTANT_CONTRACT_ID = "asst_rd9h8PfYuOmHbkvOF3RTmVfn"
82
  ASSISTANT_TECHNICAL_ID = "asst_technical_example" # Replace with actual assistant ID
83
 
84
  # Contract Chat Section
85
- contract_chat_section(tab1, ASSISTANT_CONTRACT_ID)
86
 
87
  # Technical Chat Section
88
- contract_chat_section(tab2, ASSISTANT_TECHNICAL_ID)
89
 
90
  with tab3:
91
  st.subheader("Minutes")
@@ -127,7 +127,7 @@ with tab3:
127
  st.write("### Transcribed and Extracted Text:")
128
  st.text_area("Meeting Transcript", combined_text, height=300)
129
 
130
- if st.button("Generate Meeting Minutes"):
131
  prompt = f"""
132
  Based on the following meeting transcript, generate structured meeting minutes in the format below:
133
 
@@ -164,4 +164,4 @@ with tab3:
164
  st.session_state["generated_minutes"] = response.choices[0].message.content
165
 
166
  st.write("### Generated Meeting Minutes:")
167
- st.text_area("Meeting Minutes", st.session_state["generated_minutes"], height=400)
 
26
  SUPPORTED_TEXT_FORMATS = (".txt", ".docx", ".csv", ".xlsx", ".pdf")
27
 
28
 
29
+ def contract_chat_section(tab, assistant_id, session_key):
30
  with tab:
31
  st.subheader("Chat")
32
 
 
36
  st.error("Please enter your C2 Group of Technologies Access Key to continue.")
37
  st.stop()
38
 
39
+ if session_key not in st.session_state:
40
+ st.session_state[session_key] = []
41
 
42
+ if st.button("Clear Chat", key=f"clear_chat_{session_key}"):
43
+ st.session_state[session_key] = []
44
  st.rerun()
45
 
46
+ for message in st.session_state[session_key]:
47
  role, content = message["role"], message["content"]
48
  st.chat_message(role).write(content)
49
 
50
  if prompt := st.chat_input():
51
+ st.session_state[session_key].append({"role": "user", "content": prompt})
52
  st.chat_message("user").write(prompt)
53
 
54
  try:
 
74
  messages = client.beta.threads.messages.list(thread_id=thread_id)
75
  assistant_message = messages.data[0].content[0].text.value
76
  st.chat_message("assistant").write(assistant_message)
77
+ st.session_state[session_key].append({"role": "assistant", "content": assistant_message})
78
  except Exception as e:
79
  st.error(f"Error: {str(e)}")
80
 
 
82
  ASSISTANT_TECHNICAL_ID = "asst_technical_example" # Replace with actual assistant ID
83
 
84
  # Contract Chat Section
85
+ contract_chat_section(tab1, ASSISTANT_CONTRACT_ID, "contract_messages")
86
 
87
  # Technical Chat Section
88
+ contract_chat_section(tab2, ASSISTANT_TECHNICAL_ID, "technical_messages")
89
 
90
  with tab3:
91
  st.subheader("Minutes")
 
127
  st.write("### Transcribed and Extracted Text:")
128
  st.text_area("Meeting Transcript", combined_text, height=300)
129
 
130
+ if st.button("Generate Meeting Minutes", key="generate_minutes"):
131
  prompt = f"""
132
  Based on the following meeting transcript, generate structured meeting minutes in the format below:
133
 
 
164
  st.session_state["generated_minutes"] = response.choices[0].message.content
165
 
166
  st.write("### Generated Meeting Minutes:")
167
+ st.text_area("Meeting Minutes", st.session_state["generated_minutes"], height=400)