awacke1 commited on
Commit
e18e5b1
Β·
1 Parent(s): 2de6bf8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -58,7 +58,16 @@ def create_file(filename, prompt, response):
58
  with open(filename, 'w') as file:
59
  file.write(f"# Prompt:\n{prompt}\n# Response:\n{response}")
60
 
 
 
 
 
 
 
 
61
  def get_table_download_link(file_path):
 
 
62
  with open(file_path, 'r') as file:
63
  data = file.read()
64
  b64 = base64.b64encode(data.encode()).decode()
@@ -108,7 +117,7 @@ def read_file_content(file,max_length):
108
  def main():
109
  prompts = ['']
110
  file_content = ""
111
- user_prompt = st.text_area("Your question:", '', height=100)
112
  uploaded_file = st.file_uploader("Choose a file", type=["xml", "json", "html", "htm", "md", "txt"])
113
 
114
  if user_prompt:
@@ -120,16 +129,7 @@ def main():
120
 
121
  if st.button('πŸ’¬ Chat'):
122
  st.write('Thinking and Reasoning with your inputs...')
123
- total_input = "".join(prompts)
124
-
125
- if len(total_input) > 4000:
126
- chunks = [total_input[i:i + max_length] for i in range(0, len(total_input), max_length)]
127
- responses = []
128
- for chunk in chunks:
129
- responses.append(chat_with_model([chunk]))
130
- response = "\n".join(responses)
131
- else:
132
- response = chat_with_model(prompts)
133
  st.write('Response:')
134
  st.write(response)
135
 
@@ -151,4 +151,4 @@ def main():
151
  st.experimental_rerun()
152
 
153
  if __name__ == "__main__":
154
- main()
 
58
  with open(filename, 'w') as file:
59
  file.write(f"# Prompt:\n{prompt}\n# Response:\n{response}")
60
 
61
+ def get_table_download_link_old(file_path):
62
+ with open(file_path, 'r') as file:
63
+ data = file.read()
64
+ b64 = base64.b64encode(data.encode()).decode()
65
+ href = f'<a href="data:file/htm;base64,{b64}" target="_blank" download="{os.path.basename(file_path)}">{os.path.basename(file_path)}</a>'
66
+ return href
67
+
68
  def get_table_download_link(file_path):
69
+ import os
70
+ import base64
71
  with open(file_path, 'r') as file:
72
  data = file.read()
73
  b64 = base64.b64encode(data.encode()).decode()
 
117
  def main():
118
  prompts = ['']
119
  file_content = ""
120
+ user_prompt = st.text_area("Your question:", '', height=120)
121
  uploaded_file = st.file_uploader("Choose a file", type=["xml", "json", "html", "htm", "md", "txt"])
122
 
123
  if user_prompt:
 
129
 
130
  if st.button('πŸ’¬ Chat'):
131
  st.write('Thinking and Reasoning with your inputs...')
132
+ response = chat_with_model(prompts)
 
 
 
 
 
 
 
 
 
133
  st.write('Response:')
134
  st.write(response)
135
 
 
151
  st.experimental_rerun()
152
 
153
  if __name__ == "__main__":
154
+ main()