chenguittiMaroua commited on
Commit
3538165
·
verified ·
1 Parent(s): c6f0f67

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -4
main.py CHANGED
@@ -723,6 +723,16 @@ def generate_dynamic_visualization_code(df: pd.DataFrame, request: Visualization
723
 
724
 
725
 
 
 
 
 
 
 
 
 
 
 
726
  SUPPORTED_EXTENSIONS: Dict[str, str] = {
727
  '.txt': 'text/plain',
728
  '.md': 'text/markdown',
@@ -791,9 +801,8 @@ async def extract_text_from_file(file: UploadFile, file_ext: str) -> str:
791
  return "\n".join(text)
792
  elif file_ext == '.pdf':
793
  content = await file.read()
794
- return extract_text(content, 'pdf') # Your existing PDF extraction
795
  elif file_ext == '.odt':
796
- # For ODT files, we'll use a simple text extraction
797
  content = await file.read()
798
  try:
799
  return content.decode('utf-8')
@@ -829,8 +838,6 @@ async def generate_summary(text: str, chunk_size: int = 1000) -> str:
829
  return " ".join(summaries)
830
 
831
 
832
-
833
-
834
  @app.post("/qa")
835
  @limiter.limit("5/minute")
836
  async def question_answering(
 
723
 
724
 
725
 
726
+ SUPPORTED_EXTENSIONS: Dict[str, str] = {
727
+ '.txt': 'text/plain',
728
+ '.md': 'text/markdown',
729
+ '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
730
+ '.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
731
+ '.pdf': 'application/pdf',
732
+ '.rtf': 'application/rtf',
733
+ '.odt': 'application/vnd.oasis.opendocument.text'
734
+ }
735
+
736
  SUPPORTED_EXTENSIONS: Dict[str, str] = {
737
  '.txt': 'text/plain',
738
  '.md': 'text/markdown',
 
801
  return "\n".join(text)
802
  elif file_ext == '.pdf':
803
  content = await file.read()
804
+ return extract_text(content, 'pdf')
805
  elif file_ext == '.odt':
 
806
  content = await file.read()
807
  try:
808
  return content.decode('utf-8')
 
838
  return " ".join(summaries)
839
 
840
 
 
 
841
  @app.post("/qa")
842
  @limiter.limit("5/minute")
843
  async def question_answering(