Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import os
|
|
| 3 |
import PyPDF2
|
| 4 |
import docx
|
| 5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 6 |
-
from langchain_cohere import CohereEmbeddings
|
| 7 |
from langchain_community.vectorstores import Chroma
|
| 8 |
from groq import Groq
|
| 9 |
from langchain_core.prompts import PromptTemplate
|
|
@@ -19,10 +19,14 @@ from datetime import datetime
|
|
| 19 |
class DocumentProcessor:
|
| 20 |
def __init__(self):
|
| 21 |
# Using CohereEmbeddings for document processing.
|
|
|
|
| 22 |
if "COHERE_API_KEY" not in os.environ:
|
| 23 |
st.error("Cohere API key is required for document processing.")
|
| 24 |
st.stop()
|
| 25 |
-
self.embeddings = CohereEmbeddings(
|
|
|
|
|
|
|
|
|
|
| 26 |
self.text_splitter = RecursiveCharacterTextSplitter(
|
| 27 |
chunk_size=1000,
|
| 28 |
chunk_overlap=200
|
|
|
|
| 3 |
import PyPDF2
|
| 4 |
import docx
|
| 5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 6 |
+
from langchain_cohere import CohereEmbeddings
|
| 7 |
from langchain_community.vectorstores import Chroma
|
| 8 |
from groq import Groq
|
| 9 |
from langchain_core.prompts import PromptTemplate
|
|
|
|
| 19 |
class DocumentProcessor:
|
| 20 |
def __init__(self):
|
| 21 |
# Using CohereEmbeddings for document processing.
|
| 22 |
+
# Ensure 'COHERE_API_KEY' and 'GROQ_API_KEY' are set as secrets in Hugging Face.
|
| 23 |
if "COHERE_API_KEY" not in os.environ:
|
| 24 |
st.error("Cohere API key is required for document processing.")
|
| 25 |
st.stop()
|
| 26 |
+
self.embeddings = CohereEmbeddings(
|
| 27 |
+
cohere_api_key=os.environ["COHERE_API_KEY"],
|
| 28 |
+
model="embed-english-v3.0" # Specify the Cohere embedding model
|
| 29 |
+
)
|
| 30 |
self.text_splitter = RecursiveCharacterTextSplitter(
|
| 31 |
chunk_size=1000,
|
| 32 |
chunk_overlap=200
|