Spaces:
Running
Running
make it clearer that there's many prompt options
Browse files- pages/1_Rewrite.py +17 -4
pages/1_Rewrite.py
CHANGED
@@ -1,9 +1,23 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
-
import html
|
4 |
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
doc = st.text_area("Document", "", placeholder="Paste your document here.")
|
8 |
st.button("Update document")
|
9 |
rewrite_in_progress = st.text_area("Rewrite in progress", key='rewrite_in_progress', value="", placeholder="Clicking the buttons below will update this field. You can also edit it directly; press Ctrl+Enter to apply changes.")
|
@@ -13,7 +27,6 @@ if doc.strip() == "" and rewrite_in_progress.strip() == "":
|
|
13 |
st.stop()
|
14 |
|
15 |
def get_preds_api(prompt, original_doc, rewrite_in_progress, k=5):
|
16 |
-
import requests
|
17 |
response = requests.get("https://tools.kenarnold.org/api/next_token", params=dict(prompt=prompt, original_doc=original_doc, doc_in_progress=rewrite_in_progress, k=k))
|
18 |
response.raise_for_status()
|
19 |
return response.json()['next_tokens']
|
|
|
1 |
import streamlit as st
|
2 |
+
import requests
|
|
|
3 |
|
4 |
|
5 |
+
st.title("Rewrite with Predictive Text")
|
6 |
+
|
7 |
+
# pick a preset prompt or "other"
|
8 |
+
prompt_options = [
|
9 |
+
"Rewrite this document to be ...",
|
10 |
+
"Summarize this document in one sentence.",
|
11 |
+
"Translate this document into Spanish.",
|
12 |
+
"Other"
|
13 |
+
]
|
14 |
+
prompt = st.radio("Prompt", prompt_options, help="Instructions for what the bot should do.")
|
15 |
+
if prompt.startswith("Rewrite this document to be"):
|
16 |
+
rewrite_adjs = ["clear and concise", "more detailed and engaging", "more formal and professional", "more casual and conversational", "more technical and precise", "more creative and imaginative", "more persuasive and compelling"]
|
17 |
+
prompt = "Rewrite this document to be " + st.radio("to be ...", rewrite_adjs) + "."
|
18 |
+
elif prompt == "Other":
|
19 |
+
prompt = st.text_area("Prompt", "Rewrite this document to be more clear and concise.")
|
20 |
+
st.write("Prompt:", prompt)
|
21 |
doc = st.text_area("Document", "", placeholder="Paste your document here.")
|
22 |
st.button("Update document")
|
23 |
rewrite_in_progress = st.text_area("Rewrite in progress", key='rewrite_in_progress', value="", placeholder="Clicking the buttons below will update this field. You can also edit it directly; press Ctrl+Enter to apply changes.")
|
|
|
27 |
st.stop()
|
28 |
|
29 |
def get_preds_api(prompt, original_doc, rewrite_in_progress, k=5):
|
|
|
30 |
response = requests.get("https://tools.kenarnold.org/api/next_token", params=dict(prompt=prompt, original_doc=original_doc, doc_in_progress=rewrite_in_progress, k=k))
|
31 |
response.raise_for_status()
|
32 |
return response.json()['next_tokens']
|