Spaces:
Sleeping
Sleeping
File size: 1,607 Bytes
24dc52a 80d18e0 561ac7c 24dc52a d9ef11d 24dc52a d9ef11d 24dc52a cdb3fec a565cf7 cdb3fec e39bb0b a565cf7 e39bb0b a565cf7 e39bb0b cdb3fec e39bb0b a565cf7 acfec38 eecb28e d9ef11d eecb28e d9ef11d e39bb0b d9ef11d eecb28e e39bb0b eecb28e e39bb0b eecb28e e39bb0b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import io
import os
import streamlit as st
import tempfile
from scripts import analyze_metadata, generate_metadata, ingest, MODEL_NAME
st.title('# DocVerifyRAG')
st.write('## Anomaly detection for BIM document metadata')
def suggest_metadata(file_upload):
extension = uploaded_file.name.split('.')[-1]
with tempfile.NamedTemporaryFile(delete=False) as tmp:
tmp.write(uploaded_file.read())
st.write(f'Created temporary file {tmp.name}')
st.write('## Ingesting Unstructured file')
docs = ingest(tmp.name)
print(f'Ingested {tmp.name}')
metadata = generate_metadata(docs)
st.write('## Querying Together.ai API')
st.write(f'### Suggested Metadata Generated by {MODEL_NAME}')
st.write(f'#### {metadata}')
with st.form('analyze_form'):
st.write('Enter your file metadata in the following schema:')
text = st.text_input(label='Filename, Description, Discipline',
value="", placeholder=str)
submitted = st.form_submit_button('Submit')
if submitted:
filename, description, discipline = text.split(',')
st.write('## Analyzing with Vectara + together.ai')
analysis = analyze_metadata(filename, description, discipline)
st.write(analysis)
submitted = None
st.write('## Generate metadata?')
uploaded_file = st.file_uploader("Choose a PDF file", type="pdf")
if uploaded_file is not None:
query_api = st.button('Query API')
if query_api:
suggest_metadata(uploaded_file)
query_api = None |