Keane Moraes commited on
Commit
10d9795
·
1 Parent(s): d3aa9b9

patch for pormpter folder saving

Browse files
Files changed (2) hide show
  1. app.py +4 -0
  2. utils.py +4 -4
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  from topics import TopicModelling
3
  import mdforest
4
  import utils
 
5
 
6
  st.title("Drop the first document")
7
  file1 = st.file_uploader("Upload a file", type=["md", "txt"], key="first")
@@ -14,6 +15,9 @@ results = {}
14
  embedder = utils.load_model()
15
  nlp = utils.load_nlp()
16
 
 
 
 
17
  if file1 is not None and file2 is not None:
18
 
19
  input_text1 = file1.read().decode("utf-8")
 
2
  from topics import TopicModelling
3
  import mdforest
4
  import utils
5
+ import os
6
 
7
  st.title("Drop the first document")
8
  file1 = st.file_uploader("Upload a file", type=["md", "txt"], key="first")
 
15
  embedder = utils.load_model()
16
  nlp = utils.load_nlp()
17
 
18
+ if not os.path.exists("./prompter/"):
19
+ os.mkdir("./prompter/")
20
+
21
  if file1 is not None and file2 is not None:
22
 
23
  input_text1 = file1.read().decode("utf-8")
utils.py CHANGED
@@ -133,8 +133,8 @@ def generate_insights(topics:dict, name1:str, name2:str, text1:str, text2:str, c
133
  # print(cluster_id, " ", sentences)
134
  final_prompt = PROMPT.replace("{{sentences}}", "\n".join(sentences))
135
 
136
- with open(f"prompter/insights_{cluster_id}.prompt", "w") as f:
137
- f.write(final_prompt)
138
 
139
  # Generate insights for each cluster
140
  response = openai.Completion.create(
@@ -157,8 +157,8 @@ def generate_insights(topics:dict, name1:str, name2:str, text1:str, text2:str, c
157
  # print(description)
158
  # final_insights.append({"name": name_of_insight, "description": description})
159
 
160
- with open(f"prompter/insights_{cluster_id}.prompt", "a") as f:
161
- f.write(text)
162
 
163
  final_insights.append(text)
164
  return final_insights
 
133
  # print(cluster_id, " ", sentences)
134
  final_prompt = PROMPT.replace("{{sentences}}", "\n".join(sentences))
135
 
136
+ # with open(f"prompter/insights_{cluster_id}.prompt", "w") as f:
137
+ # f.write(final_prompt)
138
 
139
  # Generate insights for each cluster
140
  response = openai.Completion.create(
 
157
  # print(description)
158
  # final_insights.append({"name": name_of_insight, "description": description})
159
 
160
+ # with open(f"prompter/insights_{cluster_id}.prompt", "a") as f:
161
+ # f.write(text)
162
 
163
  final_insights.append(text)
164
  return final_insights