Spaces:
Running
Running
File size: 1,696 Bytes
24dc52a 80d18e0 561ac7c 24dc52a d9ef11d 24dc52a d9ef11d 24dc52a d9ef11d 24dc52a d9ef11d 24dc52a d9ef11d |
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 52 53 |
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')
st.write('### Enter your file metadata in the following schema:')
user_input = st.text_input(
label='Filename, Description, Discipline',
value="", placeholder=str)
if st.button('Submit'):
try:
filename, description, discipline = user_input.split(',')
st.write('## Analyzing with Vectara + together.ai')
analysis = analyze_metadata(filename, description, discipline)
st.write(analysis)
st.write('## Generate metadata?')
st.write('### Upload the file that corresponds to the submitted metadata')
uploaded_file = st.file_uploader("Choose a PDF file", type=["pdf","txt"])
if uploaded_file is not None:
try:
with tempfile.NamedTemporaryFile(delete=False, suffix=os.path.splitext(uploaded_file.name)[1]) as tmp:
tmp.write(uploaded_file.read())
file_path = tmp.name
st.write(f'Created temporary file {file_path}')
docs = ingest(file_path)
st.write('## Querying Together.ai API')
metadata = generate_metadata(docs)
st.write(f'## Metadata Generated by {MODEL_NAME}')
st.write(metadata)
# Clean up the temporary file
os.remove(file_path)
except Exception as e:
st.error(f'Error: {e}')
except ValueError:
st.error('Please enter 3 comma separated values')
|