Spaces:
Build error
Build error
Keane Moraes
commited on
Commit
·
ca564a1
1
Parent(s):
15ea0fb
updates on quality of life and output changes
Browse files- app.py +7 -4
- insights.prompt +7 -10
- media/qrcode.png +0 -0
- utils.py +5 -14
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import mdforest
|
|
| 4 |
import utils
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
st.title("Welcome to
|
| 8 |
|
| 9 |
col1, mid, col2 = st.columns([30,5,20])
|
| 10 |
with col1:
|
|
@@ -57,7 +57,10 @@ if file1 is not None and file2 is not None:
|
|
| 57 |
st.success("Done!")
|
| 58 |
|
| 59 |
st.title("Insights generated")
|
| 60 |
-
|
| 61 |
for result in results:
|
| 62 |
-
with st.expander("
|
| 63 |
-
st.write(result)
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import utils
|
| 5 |
import os
|
| 6 |
|
| 7 |
+
st.title("Welcome to Embeddr")
|
| 8 |
|
| 9 |
col1, mid, col2 = st.columns([30,5,20])
|
| 10 |
with col1:
|
|
|
|
| 57 |
st.success("Done!")
|
| 58 |
|
| 59 |
st.title("Insights generated")
|
| 60 |
+
st.markdown("### The following insights are common to both documents.")
|
| 61 |
for result in results:
|
| 62 |
+
with st.expander(result["name"]):
|
| 63 |
+
st.write(result["description"])
|
| 64 |
+
st.markdown("Related Concepts:")
|
| 65 |
+
for insight in result["concepts"]:
|
| 66 |
+
st.markdown(f" - {insight}")
|
insights.prompt
CHANGED
|
@@ -15,13 +15,10 @@ The more complex concepts in document 2 is : {{complex2}}
|
|
| 15 |
The sentences in one of the clusters is : {{sentences}}
|
| 16 |
|
| 17 |
From the sentences and topics above, explain the common idea between the documents and write a paragraph about it and give me 3 new concepts that are linked to this idea.
|
| 18 |
-
You output format should be:
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
name:
|
| 22 |
-
description:
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
- <FILL-RELATED-CONCEPT-2>
|
| 26 |
-
- <FILL-RELATED-CONCEPT-3>
|
| 27 |
-
"""
|
|
|
|
| 15 |
The sentences in one of the clusters is : {{sentences}}
|
| 16 |
|
| 17 |
From the sentences and topics above, explain the common idea between the documents and write a paragraph about it and give me 3 new concepts that are linked to this idea.
|
| 18 |
+
You output format should be in a json format as follows:
|
| 19 |
+
|
| 20 |
+
{
|
| 21 |
+
"name": "name of the idea",
|
| 22 |
+
"description": "description of the idea",
|
| 23 |
+
"concepts": ["concept1", "concept2", "concept3"]
|
| 24 |
+
}
|
|
|
|
|
|
|
|
|
media/qrcode.png
CHANGED
|
|
utils.py
CHANGED
|
@@ -131,7 +131,8 @@ def generate_insights(topics:dict, name1:str, name2:str, text1:str, text2:str, c
|
|
| 131 |
for cluster_id, sentences in clusters.items():
|
| 132 |
|
| 133 |
# print(cluster_id, " ", sentences)
|
| 134 |
-
|
|
|
|
| 135 |
|
| 136 |
# with open(f"prompter/insights_{cluster_id}.prompt", "w") as f:
|
| 137 |
# f.write(final_prompt)
|
|
@@ -141,26 +142,16 @@ def generate_insights(topics:dict, name1:str, name2:str, text1:str, text2:str, c
|
|
| 141 |
model="text-davinci-003",
|
| 142 |
prompt=final_prompt,
|
| 143 |
max_tokens=200,
|
| 144 |
-
temperature=0.
|
| 145 |
top_p=1,
|
| 146 |
frequency_penalty=0.0,
|
| 147 |
presence_penalty=0.0,
|
| 148 |
)
|
| 149 |
|
| 150 |
text = response['choices'][0]['text']
|
| 151 |
-
|
| 152 |
|
| 153 |
-
|
| 154 |
-
# name_of_insight = text[name_location+6:name_location+6+text[name_location+6:].find("\n")]
|
| 155 |
-
# print(name_of_insight)
|
| 156 |
-
# description = text[:name_location] + text[description_location+13:description_location+13+text[description_location+13:].find("\n")]
|
| 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
|
| 165 |
|
| 166 |
|
|
|
|
| 131 |
for cluster_id, sentences in clusters.items():
|
| 132 |
|
| 133 |
# print(cluster_id, " ", sentences)
|
| 134 |
+
final_sentences = "\n".join(sentences)[:4000]
|
| 135 |
+
final_prompt = PROMPT.replace("{{sentences}}", final_sentences)
|
| 136 |
|
| 137 |
# with open(f"prompter/insights_{cluster_id}.prompt", "w") as f:
|
| 138 |
# f.write(final_prompt)
|
|
|
|
| 142 |
model="text-davinci-003",
|
| 143 |
prompt=final_prompt,
|
| 144 |
max_tokens=200,
|
| 145 |
+
temperature=0.7,
|
| 146 |
top_p=1,
|
| 147 |
frequency_penalty=0.0,
|
| 148 |
presence_penalty=0.0,
|
| 149 |
)
|
| 150 |
|
| 151 |
text = response['choices'][0]['text']
|
| 152 |
+
jsonify = json.loads(text)
|
| 153 |
|
| 154 |
+
final_insights.append(jsonify)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
return final_insights
|
| 156 |
|
| 157 |
|