Neurolingua commited on
Commit
b789611
1 Parent(s): 475fb44

Update other_function.py

Browse files
Files changed (1) hide show
  1. other_function.py +21 -2
other_function.py CHANGED
@@ -35,7 +35,7 @@ def generate_response(query,chat_history):
35
  response += chunk.choices[0].delta.content
36
  return response.replace("###", '').replace('\nUser:','')
37
  class ConversationBufferMemory:
38
- def __init__(self, max_size=6):
39
  self.memory = []
40
  self.max_size = max_size
41
 
@@ -183,4 +183,23 @@ def download_and_save_as_txt(url, account_sid, auth_token):
183
  except requests.exceptions.HTTPError as err:
184
  print(f"HTTP error occurred: {err}")
185
  except Exception as err:
186
- print(f"An error occurred: {err}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  response += chunk.choices[0].delta.content
36
  return response.replace("###", '').replace('\nUser:','')
37
  class ConversationBufferMemory:
38
+ def __init__(self, max_size):
39
  self.memory = []
40
  self.max_size = max_size
41
 
 
183
  except requests.exceptions.HTTPError as err:
184
  print(f"HTTP error occurred: {err}")
185
  except Exception as err:
186
+ print(f"An error occurred: {err}")
187
+
188
+ def download_file(url, extension):
189
+ try:
190
+ response = requests.get(url)
191
+ response.raise_for_status()
192
+ filename = f"{uuid.uuid4()}{extension}"
193
+ file_path = os.path.join(UPLOAD_FOLDER, filename)
194
+
195
+ with open(file_path, 'wb') as file:
196
+ file.write(response.content)
197
+
198
+ print(f"File downloaded and saved as {file_path}")
199
+ return file_path
200
+
201
+ except requests.exceptions.HTTPError as err:
202
+ print(f"HTTP error occurred: {err}")
203
+ except Exception as err:
204
+ print(f"An error occurred: {err}")
205
+ return None