IAMTFRMZA commited on
Commit
b75e8c0
·
verified ·
1 Parent(s): 5f827f2
Files changed (1) hide show
  1. app.py +47 -14
app.py CHANGED
@@ -17,7 +17,7 @@ st.caption("Chat with your contract or manage meeting minutes")
17
 
18
  # Sidebar for API Key input
19
  with st.sidebar:
20
- OPENAI_API_KEY = st.text_input("Enter your C2 Group of Technologies provided key", type="password")
21
 
22
  # Tabs for Contract and Minutes
23
  tab1, tab2 = st.tabs(["Contract", "Minutes"])
@@ -31,7 +31,7 @@ with tab1:
31
  if OPENAI_API_KEY:
32
  client = OpenAI(api_key=OPENAI_API_KEY)
33
  else:
34
- st.error("Please enter your C2 Group of Technologies provided key to continue.")
35
  st.stop()
36
 
37
  ASSISTANT_ID = "asst_rd9h8PfYuOmHbkvOF3RTmVfn"
@@ -111,20 +111,28 @@ with tab2:
111
  st.text_area("Meeting Transcript", combined_text, height=300)
112
 
113
  if st.button("Generate Meeting Minutes"):
114
- response = client.chat.completions.create(
115
- model="gpt-4-turbo",
116
- messages=[
117
- {"role": "system", "content": "You are an AI assistant that generates professional meeting minutes."},
118
- {"role": "user", "content": f"Summarize the following into structured meeting minutes:\n{combined_text}"}
119
- ]
120
  )
121
- minutes = response.choices[0].message.content
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  st.write("### Meeting Minutes:")
123
  st.text_area("Generated Minutes", minutes, height=300)
124
 
125
- date_stamp = datetime.now().strftime("%Y-%m-%d")
126
- file_name = f"Minutes_{date_stamp}.docx"
127
-
128
  doc = Document()
129
  doc.add_paragraph(minutes)
130
 
@@ -134,5 +142,30 @@ with tab2:
134
 
135
  st.download_button(label="Download Meeting Minutes",
136
  data=docx_io,
137
- file_name=file_name,
138
- mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  # Sidebar for API Key input
19
  with st.sidebar:
20
+ OPENAI_API_KEY = st.text_input("Enter your OpenAI API Key", type="password")
21
 
22
  # Tabs for Contract and Minutes
23
  tab1, tab2 = st.tabs(["Contract", "Minutes"])
 
31
  if OPENAI_API_KEY:
32
  client = OpenAI(api_key=OPENAI_API_KEY)
33
  else:
34
+ st.error("Please enter your OpenAI API key to continue.")
35
  st.stop()
36
 
37
  ASSISTANT_ID = "asst_rd9h8PfYuOmHbkvOF3RTmVfn"
 
111
  st.text_area("Meeting Transcript", combined_text, height=300)
112
 
113
  if st.button("Generate Meeting Minutes"):
114
+ response = client.beta.threads.messages.create(
115
+ thread_id=ASSISTANT_ID,
116
+ role="user",
117
+ content=f"Summarize the following into structured meeting minutes:\n{combined_text}"
 
 
118
  )
119
+
120
+ run = client.beta.threads.runs.create(
121
+ thread_id=ASSISTANT_ID,
122
+ assistant_id=ASSISTANT_ID
123
+ )
124
+
125
+ while True:
126
+ run_status = client.beta.threads.runs.retrieve(thread_id=ASSISTANT_ID, run_id=run.id)
127
+ if run_status.status == "completed":
128
+ break
129
+ time.sleep(1)
130
+
131
+ messages = client.beta.threads.messages.list(thread_id=ASSISTANT_ID)
132
+ minutes = messages.data[0].content[0].text.value
133
  st.write("### Meeting Minutes:")
134
  st.text_area("Generated Minutes", minutes, height=300)
135
 
 
 
 
136
  doc = Document()
137
  doc.add_paragraph(minutes)
138
 
 
142
 
143
  st.download_button(label="Download Meeting Minutes",
144
  data=docx_io,
145
+ file_name="Meeting_Minutes.docx",
146
+ mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
147
+
148
+ if st.button("Contract Analysis"):
149
+ analysis_prompt = "Analyse this data and provide any insights, risks and relevant data based on the contract that we need to be aware of.\n" + minutes
150
+ response = client.beta.threads.messages.create(
151
+ thread_id=ASSISTANT_ID,
152
+ role="user",
153
+ content=analysis_prompt
154
+ )
155
+
156
+ run = client.beta.threads.runs.create(
157
+ thread_id=ASSISTANT_ID,
158
+ assistant_id=ASSISTANT_ID
159
+ )
160
+
161
+ while True:
162
+ run_status = client.beta.threads.runs.retrieve(thread_id=ASSISTANT_ID, run_id=run.id)
163
+ if run_status.status == "completed":
164
+ break
165
+ time.sleep(1)
166
+
167
+ messages = client.beta.threads.messages.list(thread_id=ASSISTANT_ID)
168
+ analysis_output = messages.data[0].content[0].text.value
169
+
170
+ st.write("### Contract Analysis Output:")
171
+ st.text_area("Contract Analysis", analysis_output, height=300)