eaglelandsonce commited on
Commit
ae3526d
·
1 Parent(s): 923a83d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -17,7 +17,11 @@ from collections import deque
17
  from audio_recorder_streamlit import audio_recorder
18
  import streamlit as st
19
 
20
- st.session_state.model_choice = ''
 
 
 
 
21
 
22
  def generate_filename(prompt, file_type):
23
  central = pytz.timezone('US/Central')
@@ -31,7 +35,7 @@ def chat_with_model(prompt, document_section):
31
  conversation.append({'role': 'user', 'content': prompt})
32
  if len(document_section)>0:
33
  conversation.append({'role': 'assistant', 'content': document_section})
34
- response = openai.ChatCompletion.create(model=st.session_state.model_choice, messages=conversation)
35
  return response
36
  #return response['choices'][0]['message']['content']
37
 
@@ -146,19 +150,9 @@ def main():
146
  api_key = st.text_input("Enter OpenAI API Key:", type='password')
147
  if api_key:
148
  openai.api_key = api_key
149
-
150
- #sidebar
151
- models_list = ['gpt-3.5-turbo', 'gpt-3.5-turbo-0301', 'gpt-4']
152
- model_choice = st.sidebar.radio("Select Model:", models_list, index=0)
153
- st.session_state.model_choice = model_choice
154
-
155
- collength, colupload = st.columns([2,3]) # adjust the ratio as needed
156
 
157
- with colupload:
158
- uploaded_file = st.sidebar.file_uploader("Add a file for context:", type=["xml", "json", "xlsx","csv","html", "htm", "md", "txt"])
159
- with collength:
160
- #max_length = 12000 - optimal for gpt35 turbo. 2x=24000 for gpt4. 8x=96000 for gpt4-32k.
161
- max_length = st.sidebar.slider("File section length for large files", min_value=1000, max_value=128000, value=12000, step=1000)
162
 
163
  document_sections = deque()
164
  document_responses = {}
 
17
  from audio_recorder_streamlit import audio_recorder
18
  import streamlit as st
19
 
20
+ st.set_page_config(page_title="Chat Toolkit",layout="wide")
21
+
22
+ menu = ["htm", "txt", "xlsx", "csv", "md", "py"] #619
23
+ choice = st.sidebar.selectbox("Output File Type:", menu)
24
+ model_choice = st.sidebar.radio("Select Model:", ('gpt-3.5-turbo', 'gpt-3.5-turbo-0301', 'gpt-4'))
25
 
26
  def generate_filename(prompt, file_type):
27
  central = pytz.timezone('US/Central')
 
35
  conversation.append({'role': 'user', 'content': prompt})
36
  if len(document_section)>0:
37
  conversation.append({'role': 'assistant', 'content': document_section})
38
+ response = openai.ChatCompletion.create(model=model_choice)
39
  return response
40
  #return response['choices'][0]['message']['content']
41
 
 
150
  api_key = st.text_input("Enter OpenAI API Key:", type='password')
151
  if api_key:
152
  openai.api_key = api_key
 
 
 
 
 
 
 
153
 
154
+ uploaded_file = st.sidebar.file_uploader("Add a file for context:", type=["xml", "json", "xlsx","csv","html", "htm", "md", "txt"])
155
+ max_length = st.sidebar.slider("File section length for large files", min_value=1000, max_value=128000, value=12000, step=1000)
 
 
 
156
 
157
  document_sections = deque()
158
  document_responses = {}