awacke1 commited on
Commit
1b938a0
·
1 Parent(s): c8fbdd5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -21,6 +21,7 @@ st.set_page_config(
21
  menu = ["txt", "htm", "md", "py"]
22
  choice = st.sidebar.selectbox("Output file type:", menu)
23
  choicePrefix = "Output file type is "
 
24
  if choice == "txt":
25
  st.sidebar.write(choicePrefix + "Text File.")
26
  elif choice == "htm":
@@ -30,6 +31,16 @@ elif choice == "md":
30
  elif choice == "py":
31
  st.sidebar.write(choicePrefix + "Python Code.")
32
 
 
 
 
 
 
 
 
 
 
 
33
  def generate_filename(prompt, file_type):
34
  central = pytz.timezone('US/Central')
35
  safe_date_time = datetime.now(central).strftime("%m%d_%I%M")
@@ -53,14 +64,6 @@ def truncate_document(document, length):
53
  def divide_document(document, max_length):
54
  return [document[i:i+max_length] for i in range(0, len(document), max_length)]
55
 
56
- def chat_with_model(prompt, document_section):
57
- model = "gpt-3.5-turbo"
58
- conversation = [{'role': 'system', 'content': 'You are a helpful assistant.'}]
59
- conversation.append({'role': 'user', 'content': prompt})
60
- conversation.append({'role': 'assistant', 'content': document_section})
61
- response = openai.ChatCompletion.create(model=model, messages=conversation)
62
- return response['choices'][0]['message']['content']
63
-
64
  def get_table_download_link(file_path):
65
  with open(file_path, 'r') as file:
66
  data = file.read()
 
21
  menu = ["txt", "htm", "md", "py"]
22
  choice = st.sidebar.selectbox("Output file type:", menu)
23
  choicePrefix = "Output file type is "
24
+
25
  if choice == "txt":
26
  st.sidebar.write(choicePrefix + "Text File.")
27
  elif choice == "htm":
 
31
  elif choice == "py":
32
  st.sidebar.write(choicePrefix + "Python Code.")
33
 
34
+ model_choice = st.sidebar.radio("Select Model:", ('gpt-3.5-turbo', 'gpt-4-32k'))
35
+
36
+ def chat_with_model(prompt, document_section):
37
+ model = model_choice
38
+ conversation = [{'role': 'system', 'content': 'You are a helpful assistant.'}]
39
+ conversation.append({'role': 'user', 'content': prompt})
40
+ conversation.append({'role': 'assistant', 'content': document_section})
41
+ response = openai.ChatCompletion.create(model=model, messages=conversation)
42
+ return response['choices'][0]['message']['content']
43
+
44
  def generate_filename(prompt, file_type):
45
  central = pytz.timezone('US/Central')
46
  safe_date_time = datetime.now(central).strftime("%m%d_%I%M")
 
64
  def divide_document(document, max_length):
65
  return [document[i:i+max_length] for i in range(0, len(document), max_length)]
66
 
 
 
 
 
 
 
 
 
67
  def get_table_download_link(file_path):
68
  with open(file_path, 'r') as file:
69
  data = file.read()