pattonma commited on
Commit
3f2dc36
1 Parent(s): 4115710

file loading testing

Browse files
Files changed (2) hide show
  1. app.py +2 -3
  2. helper_functions.py +0 -8
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import chainlit as cl
2
- from helper_functions import process_file, load_documents_from_url, store_uploaded_file
3
  import models
4
  import agents
5
  import asyncio
@@ -85,8 +85,7 @@ async def handle_response(res):
85
  await msg.send()
86
 
87
  # load the file
88
- file_path = store_uploaded_file(file)
89
- docs = await asyncio.to_thread(process_file, file_path)
90
  await cl.Message(content="loaded docs").send()
91
  splits = await asyncio.to_thread(models.semanticChunker_tuned.split_documents, docs)
92
  await cl.Message(content="split docs").send()
 
1
  import chainlit as cl
2
+ from helper_functions import process_file, load_documents_from_url
3
  import models
4
  import agents
5
  import asyncio
 
85
  await msg.send()
86
 
87
  # load the file
88
+ docs = await asyncio.to_thread(process_file, file)
 
89
  await cl.Message(content="loaded docs").send()
90
  splits = await asyncio.to_thread(models.semanticChunker_tuned.split_documents, docs)
91
  await cl.Message(content="split docs").send()
helper_functions.py CHANGED
@@ -11,14 +11,6 @@ import requests
11
  import tempfile
12
  from chainlit.types import AskFileResponse
13
 
14
- def store_uploaded_file(uploaded_file: AskFileResponse):
15
- with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".pdf") as temp_file:
16
- temp_file_path = temp_file.name
17
-
18
- with open(temp_file_path, "wb") as f:
19
- f.write(uploaded_file.content)
20
- return temp_file_path
21
-
22
  def process_file(uploaded_file: AskFileResponse):
23
  if uploaded_file.endswith(".pdf"):
24
  with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".pdf") as temp_file:
 
11
  import tempfile
12
  from chainlit.types import AskFileResponse
13
 
 
 
 
 
 
 
 
 
14
  def process_file(uploaded_file: AskFileResponse):
15
  if uploaded_file.endswith(".pdf"):
16
  with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".pdf") as temp_file: