Spaces:
Runtime error
Runtime error
Download utils/functions.py from ainur1/table_and_text_QA: direct link, hf CLI and curl.
- Browser
- Download file 900 Bytes
-
https://huggingface.co/spaces/ainur1/table_and_text_QA/resolve/main/utils/functions.py
- Command line
-
hf download hf://spaces/ainur1/table_and_text_QA/utils/functions.py
-
curl -L -o functions.py https://huggingface.co/spaces/ainur1/table_and_text_QA/resolve/main/utils/functions.py
900 Bytes
| import pandas as pd | |
| from langchain.document_loaders import PyPDFLoader | |
| from langchain.text_splitter import CharacterTextSplitter | |
| def make_descriptions(table, tittle): | |
| df = pd.read_csv(table) | |
| columns = list(df.columns) | |
| table_description0 = { | |
| 'path': 'random', | |
| 'number': 1, | |
| 'columns': ["clothes", "animals", "students"], | |
| 'tittle': "fashionable student clothes" | |
| } | |
| table_description1 = { | |
| 'path': table, | |
| 'number': 2, | |
| 'columns': columns, | |
| 'tittle': tittle | |
| } | |
| table_descriptions = [table_description0, table_description1] | |
| return table_descriptions | |
| def make_documens(pdf): | |
| loader = PyPDFLoader(pdf) | |
| documents = loader.load() | |
| text_splitter = CharacterTextSplitter(chunk_size=500, chunk_overlap=0, separator='\n') | |
| documents = text_splitter.split_documents(documents) | |
| return documents | |