Spaces:
Sleeping
Sleeping
Carlos Salgado
commited on
Commit
•
eecb28e
1
Parent(s):
b5377e1
restructure app.py
Browse files
app.py
CHANGED
@@ -5,48 +5,39 @@ import tempfile
|
|
5 |
|
6 |
from scripts import analyze_metadata, generate_metadata, ingest, MODEL_NAME
|
7 |
|
8 |
-
|
9 |
st.title('# DocVerifyRAG')
|
10 |
st.write('## Anomaly detection for BIM document metadata')
|
11 |
|
12 |
-
st.
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
if
|
19 |
-
|
20 |
-
filename, description, discipline = user_input.split(',')
|
21 |
|
22 |
st.write('## Analyzing with Vectara + together.ai')
|
23 |
analysis = analyze_metadata(filename, description, discipline)
|
24 |
|
25 |
st.write(analysis)
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
os.remove(file_path)
|
47 |
-
|
48 |
-
except Exception as e:
|
49 |
-
st.error(f'Error: {e}')
|
50 |
-
except ValueError:
|
51 |
-
st.error('Please enter 3 comma separated values')
|
52 |
-
|
|
|
5 |
|
6 |
from scripts import analyze_metadata, generate_metadata, ingest, MODEL_NAME
|
7 |
|
|
|
8 |
st.title('# DocVerifyRAG')
|
9 |
st.write('## Anomaly detection for BIM document metadata')
|
10 |
|
11 |
+
with st.form('my_form'):
|
12 |
+
st.write('Enter your file metadata in the following schema:')
|
13 |
+
text = st.text_input(label='Filename, Description, Discipline',
|
14 |
+
value="", placeholder=str)
|
15 |
+
submitted = st.form_submit_button('Submit')
|
16 |
|
17 |
+
if submitted:
|
18 |
+
filename, description, discipline = text.split(',')
|
|
|
19 |
|
20 |
st.write('## Analyzing with Vectara + together.ai')
|
21 |
analysis = analyze_metadata(filename, description, discipline)
|
22 |
|
23 |
st.write(analysis)
|
24 |
|
25 |
+
st.write('## Generate metadata?')
|
26 |
+
uploaded_file = st.file_uploader("Choose a PDF file", type=["pdf","txt"])
|
27 |
+
|
28 |
+
if uploaded_file is not None:
|
29 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=os.path.splitext(uploaded_file.name)[1]) as tmp:
|
30 |
+
tmp.write(uploaded_file.read())
|
31 |
+
file_path = tmp.name
|
32 |
+
st.write(f'Created temporary file {file_path}')
|
33 |
+
|
34 |
+
docs = ingest(file_path)
|
35 |
+
st.write('## Querying Together.ai API')
|
36 |
+
metadata = generate_metadata(docs)
|
37 |
+
|
38 |
+
form = st.form(key='my_form')
|
39 |
+
form.text_input(label=f'Suggested Metadata Generated by {MODEL_NAME}')
|
40 |
+
stop_button = form.form_submit_button(label='Submit')
|
41 |
+
print(metadata)
|
42 |
+
|
43 |
+
os.remove(file_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|