BGarida commited on
Commit
b4f4511
·
1 Parent(s): 1d550e6

Deploying PDF Version v17

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import os
2
  import tempfile
3
  import logging
4
- import time
5
  from typing import List, Dict
6
  from langchain.embeddings import OpenAIEmbeddings
7
  from langchain.text_splitter import RecursiveCharacterTextSplitter
@@ -42,7 +41,7 @@ text_splitter = RecursiveCharacterTextSplitter(
42
  separators=["\n\n", "\n", " ", ""] # Prioritize splitting on paragraph breaks
43
  )
44
 
45
- # System template (unchanged)
46
  system_template = """You are GPT-4o, an advanced AI model with multimodal capabilities and high intelligence. Use the following pieces of context to answer the user's question.
47
  If you don't know the answer, just say that you don't know, don't try to make up an answer.
48
  ALWAYS return a "SOURCES" part in your answer.
@@ -111,18 +110,18 @@ async def start():
111
 
112
  # Simulate upload progress
113
  for i in range(0, 101, 10):
114
- await msg.update(f"Uploading: {i}%")
115
  if i < 100:
116
- await cl.sleep(0.5) # Use cl.sleep instead of time.sleep
117
 
118
- await msg.update(f"Upload complete. Now processing `{file.name}`...")
119
 
120
  try:
121
  # Simulate processing progress
122
  for i in range(0, 101, 10):
123
- await msg.update(f"Processing: {i}%")
124
  if i < 100:
125
- await cl.sleep(1) # Use cl.sleep instead of time.sleep
126
  if i == 50:
127
  # Actually process the file at the midpoint
128
  chunks_with_metadata = process_file(file)
@@ -154,7 +153,7 @@ async def start():
154
  )
155
 
156
  cl.user_session.set("chain", chain)
157
- await msg.update(f"Processing `{file.name}` complete. You can now ask questions about the book!")
158
 
159
  except Exception as e:
160
  error_msg = f"An error occurred while processing the file: {str(e)}"
 
1
  import os
2
  import tempfile
3
  import logging
 
4
  from typing import List, Dict
5
  from langchain.embeddings import OpenAIEmbeddings
6
  from langchain.text_splitter import RecursiveCharacterTextSplitter
 
41
  separators=["\n\n", "\n", " ", ""] # Prioritize splitting on paragraph breaks
42
  )
43
 
44
+ # System template
45
  system_template = """You are GPT-4o, an advanced AI model with multimodal capabilities and high intelligence. Use the following pieces of context to answer the user's question.
46
  If you don't know the answer, just say that you don't know, don't try to make up an answer.
47
  ALWAYS return a "SOURCES" part in your answer.
 
110
 
111
  # Simulate upload progress
112
  for i in range(0, 101, 10):
113
+ await msg.content.edit(f"Uploading: {i}%")
114
  if i < 100:
115
+ await cl.sleep(0.5)
116
 
117
+ await msg.content.edit(f"Upload complete. Now processing `{file.name}`...")
118
 
119
  try:
120
  # Simulate processing progress
121
  for i in range(0, 101, 10):
122
+ await msg.content.edit(f"Processing: {i}%")
123
  if i < 100:
124
+ await cl.sleep(1)
125
  if i == 50:
126
  # Actually process the file at the midpoint
127
  chunks_with_metadata = process_file(file)
 
153
  )
154
 
155
  cl.user_session.set("chain", chain)
156
+ await msg.content.edit(f"Processing `{file.name}` complete. You can now ask questions about the book!")
157
 
158
  except Exception as e:
159
  error_msg = f"An error occurred while processing the file: {str(e)}"