Spaces:
Running
Running
| import streamlit as st | |
| from pydantic_ai import Agent | |
| from pydantic_ai.models.groq import GroqModel | |
| import nest_asyncio | |
| import pdfplumber | |
| import os | |
| api_key = os.getenv("API_KEY") | |
| data = [] | |
| #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 | |
| model = GroqModel('llama-3.1-70b-versatile', api_key = api_key) | |
| def extract_data(feed): | |
| with pdfplumber.load(feed) as pdf: | |
| pages = pdf.pages | |
| for p in pages: | |
| data.append(p.extract_tables()) | |
| return None | |
| uploaded_file = st.file_uploader('Choose your .pdf file', type="pdf") | |
| if uploaded_file is not None: | |
| df = extract_data(uploaded_file) | |
| if data is not None: | |
| st.caption(data) | |