MCPcopy Index your code
hub / github.com/CL-lau/SQL-GPT / upload_and_process_document

Function upload_and_process_document

components/document_processor.py:10–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9
10def upload_and_process_document() -> tuple[int, list]:
11 st.write('#### Upload a Document file')
12 browse, url_link, sql, code_rep, ocr_ = st.tabs(
13 [' Document ', ' Document Online ', ' Mysql Analysis ', ' Code Rep ', ' OCR Image ']
14 )
15 with browse:
16 upload_file = st.file_uploader(
17 'Browse file (.pdf, .docx, .csv, `.txt`)',
18 type=['pdf', 'docx', 'csv', 'txt'],
19 label_visibility='hidden'
20 )
21 filetype = os.path.splitext(upload_file.name)[1].lower() if upload_file else None
22 upload_file_name = upload_file.name if upload_file else None
23 upload_file = upload_file.read() if upload_file else None
24
25 with url_link:
26 doc_url = st.text_input(
27 "Enter document URL Link (.pdf, .docx, .csv, .txt)",
28 placeholder='https://www.xxx/uploads/file.pdf',
29 label_visibility='hidden'
30 )
31 if doc_url:
32 upload_file, filetype = DocumentLoader.crawl_file(doc_url)
33
34 with sql:
35 sql_url = st.text_input(
36 "Enter Mysql URL Link.",
37 placeholder='127.0.0.1:3306/database_name',
38 )
39 username, password = st.columns(2)
40 with username:
41 sql_username = st.text_input(
42 "Enter Mysql UserName.",
43 placeholder='UserName',
44 )
45 with password:
46 sql_password = st.text_input(
47 "Enter Mysql Password.",
48 placeholder='Password',
49 type='password'
50 )
51
52 with code_rep:
53 code_url = st.text_input(
54 "Enter document URL Link (.pdf, .docx, .csv, .txt)",
55 placeholder='https://www.xxx/',
56 label_visibility='hidden'
57 )
58
59 with ocr_:
60 upload_images = st.file_uploader(
61 'Browse file (.png, .jpg)',
62 type=['png', 'jpg'],
63 label_visibility='hidden',
64 accept_multiple_files=True
65 )
66 import pytesseract
67 from PIL import Image

Callers 1

mainFunction · 0.90

Calls 4

crawl_fileMethod · 0.80
load_documentsMethod · 0.80
split_documentsMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected