Spaces:
Build error
Build error
Zekun Wu commited on
Commit ·
693b654
1
Parent(s): 4efe666
update
Browse files- app.py +22 -3
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import requests
|
| 2 |
import streamlit as st
|
| 3 |
import json
|
|
@@ -104,10 +107,26 @@ values = st.text_area("Company Values", "innovation, teamwork, transparency")
|
|
| 104 |
batch_size = st.number_input("Batch Size", min_value=1, max_value=100, value=10)
|
| 105 |
repeat_times = st.number_input("Number of Batches", min_value=1, max_value=10, value=1)
|
| 106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
|
| 109 |
if st.button("Generate Potshots"):
|
| 110 |
with st.spinner("Generating customized potshots..."):
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from io import BytesIO
|
| 2 |
+
|
| 3 |
+
import pandas as pd
|
| 4 |
import requests
|
| 5 |
import streamlit as st
|
| 6 |
import json
|
|
|
|
| 107 |
batch_size = st.number_input("Batch Size", min_value=1, max_value=100, value=10)
|
| 108 |
repeat_times = st.number_input("Number of Batches", min_value=1, max_value=10, value=1)
|
| 109 |
|
| 110 |
+
def to_excel(df):
|
| 111 |
+
output = BytesIO()
|
| 112 |
+
writer = pd.ExcelWriter(output, engine='xlsxwriter')
|
| 113 |
+
df.to_excel(writer, index=False, sheet_name='Potshots')
|
| 114 |
+
writer.save()
|
| 115 |
+
processed_data = output.getvalue()
|
| 116 |
+
return processed_data
|
| 117 |
|
| 118 |
|
| 119 |
if st.button("Generate Potshots"):
|
| 120 |
with st.spinner("Generating customized potshots..."):
|
| 121 |
+
df = get_potshots(n_repeat=repeat_times, batch=batch_size, role=role, tone=tone, audience=audience,
|
| 122 |
+
values=values)
|
| 123 |
+
|
| 124 |
+
# Display the generated potshots as a table
|
| 125 |
+
st.write("### Generated Potshots")
|
| 126 |
+
st.dataframe(df)
|
| 127 |
+
|
| 128 |
+
# Provide a download button for the Excel file
|
| 129 |
+
st.write("### Download Potshots")
|
| 130 |
+
excel_data = to_excel(df)
|
| 131 |
+
st.download_button(label="Download Potshots as Excel", data=excel_data, file_name="potshots.xlsx",
|
| 132 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
openai
|
| 2 |
json-repair
|
| 3 |
-
backoff
|
|
|
|
|
|
| 1 |
openai
|
| 2 |
json-repair
|
| 3 |
+
backoff
|
| 4 |
+
pandas
|