BGarida commited on
Commit
552deeb
·
1 Parent(s): b1805d6

Deploying PDF Version v19

Browse files
Files changed (1) hide show
  1. app.py +6 -24
app.py CHANGED
@@ -105,33 +105,14 @@ async def start():
105
  return
106
 
107
  file = files[0]
108
- msg = cl.Message(content=f"Processing `{file.name}`...")
109
- await msg.send()
110
-
111
- # Create a progress bar for upload
112
- upload_progress = cl.Progress(total=100, description="Uploading")
113
- await upload_progress.send()
114
-
115
- # Simulate upload progress
116
- for i in range(0, 101, 10):
117
- await upload_progress.update(i)
118
- await cl.sleep(0.5)
119
-
120
- await cl.Message(content=f"Upload complete. Now processing `{file.name}`...").send()
121
-
122
- # Create a progress bar for processing
123
- process_progress = cl.Progress(total=100, description="Processing")
124
- await process_progress.send()
125
 
126
  try:
127
- # Simulate processing progress
128
- for i in range(0, 101, 10):
129
- await process_progress.update(i)
130
- await cl.sleep(1)
131
- if i == 50:
132
- # Actually process the file at the midpoint
133
- chunks_with_metadata = process_file(file)
134
 
 
135
  embeddings = OpenAIEmbeddings(model=APP_CONFIG["embedding_model"])
136
  docsearch = await cl.make_async(Chroma.from_documents)(
137
  [Document(page_content=chunk["content"], metadata=chunk["metadata"]) for chunk in chunks_with_metadata],
@@ -144,6 +125,7 @@ async def start():
144
  return_messages=True,
145
  )
146
 
 
147
  chain = ConversationalRetrievalChain.from_llm(
148
  ChatOpenAI(
149
  model_name=APP_CONFIG["model_name"],
 
105
  return
106
 
107
  file = files[0]
108
+ await cl.Message(f"Starting to process `{file.name}`. This may take a few minutes...").send()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
  try:
111
+ # Process the file
112
+ await cl.Message("Reading and splitting the document...").send()
113
+ chunks_with_metadata = process_file(file)
 
 
 
 
114
 
115
+ await cl.Message("Creating embeddings and setting up the retrieval system...").send()
116
  embeddings = OpenAIEmbeddings(model=APP_CONFIG["embedding_model"])
117
  docsearch = await cl.make_async(Chroma.from_documents)(
118
  [Document(page_content=chunk["content"], metadata=chunk["metadata"]) for chunk in chunks_with_metadata],
 
125
  return_messages=True,
126
  )
127
 
128
+ await cl.Message("Finalizing the chat model...").send()
129
  chain = ConversationalRetrievalChain.from_llm(
130
  ChatOpenAI(
131
  model_name=APP_CONFIG["model_name"],