Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,12 +12,12 @@ from spacy.lang.en import English
|
|
| 12 |
from pinecone import Pinecone, ServerlessSpec
|
| 13 |
|
| 14 |
# Retrieve the API keys from environment variables
|
| 15 |
-
|
| 16 |
-
|
| 17 |
|
| 18 |
# Initialize global variables
|
| 19 |
-
co = cohere.Client('
|
| 20 |
-
pc = Pinecone(api_key='
|
| 21 |
index_name = 'cohere-pinecone'
|
| 22 |
nlp = English()
|
| 23 |
nlp.add_pipe("sentencizer")
|
|
@@ -45,7 +45,7 @@ def split_list(input_list: list, slice_size: int) -> list[list[str]]:
|
|
| 45 |
return [input_list[i:i + slice_size] for i in range(0, len(input_list), slice_size)]
|
| 46 |
|
| 47 |
def process_pdf(pdf_path):
|
| 48 |
-
pages_and_texts = open_and_read_pdf(pdf_path=pdf_path
|
| 49 |
|
| 50 |
for item in pages_and_texts:
|
| 51 |
item["sentences"] = [str(sentence) for sentence in nlp(item["text"]).sents]
|
|
|
|
| 12 |
from pinecone import Pinecone, ServerlessSpec
|
| 13 |
|
| 14 |
# Retrieve the API keys from environment variables
|
| 15 |
+
COHERE_KEY = os.getenv('COHERE_API_KEY')
|
| 16 |
+
PINECONE_KEY = os.getenv('PINECONE_API_KEY')
|
| 17 |
|
| 18 |
# Initialize global variables
|
| 19 |
+
co = cohere.Client('COHERE_KEY')
|
| 20 |
+
pc = Pinecone(api_key='PINECONE_KEY')
|
| 21 |
index_name = 'cohere-pinecone'
|
| 22 |
nlp = English()
|
| 23 |
nlp.add_pipe("sentencizer")
|
|
|
|
| 45 |
return [input_list[i:i + slice_size] for i in range(0, len(input_list), slice_size)]
|
| 46 |
|
| 47 |
def process_pdf(pdf_path):
|
| 48 |
+
pages_and_texts = open_and_read_pdf(pdf_path=pdf_path)
|
| 49 |
|
| 50 |
for item in pages_and_texts:
|
| 51 |
item["sentences"] = [str(sentence) for sentence in nlp(item["text"]).sents]
|