-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
35 lines (27 loc) · 1.26 KB
/
app.py
File metadata and controls
35 lines (27 loc) · 1.26 KB
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
import streamlit as st
import pandas as pd
from utils.data_handler import load_data, authenticate_google_sheets
from utils.search_api import SearchAPI
from utils.llm_processing import process_with_llm
st.title("AI Agent for Data Extraction")
# File upload
uploaded_file = st.file_uploader("Upload CSV or connect Google Sheet", type=["csv"])
if uploaded_file:
data = pd.read_csv(uploaded_file)
st.write("Data preview:", data.head())
primary_column = st.selectbox("Select the main entity column", data.columns)
# User prompt input
prompt_template = st.text_input("Enter query (e.g., 'Get me the email address of {company}')")
if st.button("Start Extraction"):
results = []
for entity in data[primary_column].unique():
# Web search
query = prompt_template.replace("{company}", entity)
search_results = SearchAPI().search(query)
# LLM processing
parsed_data = process_with_llm(search_results, entity)
results.append(parsed_data)
results_df = pd.DataFrame(results)
st.write("Extracted Data", results_df)
# Download option
st.download_button("Download CSV", results_df.to_csv(index=False), "extracted_data.csv")