awacke1 commited on
Commit
e12378e
β€’
1 Parent(s): 9337711

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -16,7 +16,8 @@ openai.api_key = os.getenv('OPENAI_KEY')
16
  st.set_page_config(
17
  page_title="GPT Streamlit Document Reasoner",
18
  layout="wide")
19
- menu = ["txt", "htm", "md"]
 
20
  choice = st.sidebar.selectbox("Choose output file type to save results", menu)
21
  choicePrefix = "Output and download file set to "
22
  if choice == "txt":
@@ -26,16 +27,15 @@ elif choice == "htm":
26
  elif choice == "md":
27
  st.sidebar.write(choicePrefix + "Markdown.")
28
  elif choice == "py":
29
- st.sidebar.write(choicePrefix + "Python AI UI/UX")
30
 
31
- max_length = st.sidebar.slider("Max document length", min_value=1000, max_value=32000, value=3000, step=1000)
32
 
33
  def truncate_document(document, length):
34
  return document[:length]
35
 
36
  def chat_with_model(prompts):
37
  model = "gpt-3.5-turbo"
38
- #model = "gpt-4-32k" # 32k tokens between prompt and inference tokens
39
  conversation = [{'role': 'system', 'content': 'You are a helpful assistant.'}]
40
  conversation.extend([{'role': 'user', 'content': prompt} for prompt in prompts])
41
  response = openai.ChatCompletion.create(model=model, messages=conversation)
@@ -140,13 +140,6 @@ def main():
140
  if len(file_content) > 0:
141
  st.markdown(f"**File Content Added:**\n{file_content}")
142
 
143
- #all_files = glob.glob("*.txt") + glob.glob("*.htm") + glob.glob("*.md")
144
- #for file in all_files:
145
- # st.sidebar.markdown(get_table_download_link(file), unsafe_allow_html=True)
146
- # if st.sidebar.button("πŸ—‘", key=file):
147
- # os.remove(file)
148
- # st.experimental_rerun()
149
-
150
  all_files = glob.glob("*.txt") + glob.glob("*.htm") + glob.glob("*.md")
151
  for file in all_files:
152
  col1, col2 = st.sidebar.columns([4,1]) # adjust the ratio as needed
@@ -157,6 +150,5 @@ def main():
157
  os.remove(file)
158
  st.experimental_rerun()
159
 
160
-
161
  if __name__ == "__main__":
162
  main()
 
16
  st.set_page_config(
17
  page_title="GPT Streamlit Document Reasoner",
18
  layout="wide")
19
+
20
+ menu = ["txt", "htm", "md", "py"]
21
  choice = st.sidebar.selectbox("Choose output file type to save results", menu)
22
  choicePrefix = "Output and download file set to "
23
  if choice == "txt":
 
27
  elif choice == "md":
28
  st.sidebar.write(choicePrefix + "Markdown.")
29
  elif choice == "py":
30
+ st.sidebar.write(choicePrefix + "Python Code.")
31
 
32
+ max_length = st.sidebar.slider("Max document length", min_value=1000, max_value=32000, value=2000, step=1000)
33
 
34
  def truncate_document(document, length):
35
  return document[:length]
36
 
37
  def chat_with_model(prompts):
38
  model = "gpt-3.5-turbo"
 
39
  conversation = [{'role': 'system', 'content': 'You are a helpful assistant.'}]
40
  conversation.extend([{'role': 'user', 'content': prompt} for prompt in prompts])
41
  response = openai.ChatCompletion.create(model=model, messages=conversation)
 
140
  if len(file_content) > 0:
141
  st.markdown(f"**File Content Added:**\n{file_content}")
142
 
 
 
 
 
 
 
 
143
  all_files = glob.glob("*.txt") + glob.glob("*.htm") + glob.glob("*.md")
144
  for file in all_files:
145
  col1, col2 = st.sidebar.columns([4,1]) # adjust the ratio as needed
 
150
  os.remove(file)
151
  st.experimental_rerun()
152
 
 
153
  if __name__ == "__main__":
154
  main()