Update src/rag_engine.py
Browse files- src/rag_engine.py +6 -20
src/rag_engine.py
CHANGED
|
@@ -7,7 +7,7 @@ from langchain_core.output_parsers import StrOutputParser
|
|
| 7 |
from langchain_core.runnables import RunnablePassthrough, RunnableParallel
|
| 8 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 9 |
from langchain_openai import ChatOpenAI
|
| 10 |
-
|
| 11 |
|
| 12 |
class ProjectRAGEngine:
|
| 13 |
def __init__(self):
|
|
@@ -17,26 +17,12 @@ class ProjectRAGEngine:
|
|
| 17 |
model_kwargs={"device": "cpu"}, # change to "cuda" if GPU available
|
| 18 |
encode_kwargs={"normalize_embeddings": True}
|
| 19 |
)
|
| 20 |
-
|
| 21 |
# ✅ OpenRouter LLM (Chat only)
|
| 22 |
-
self.llm =
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
api_key=os.getenv("OPENROUTER_API_KEY"),
|
| 28 |
-
|
| 29 |
-
# ✅ OpenRouter endpoint
|
| 30 |
-
base_url="https://openrouter.ai/api/v1",
|
| 31 |
-
|
| 32 |
-
# ✅ REQUIRED HEADERS FOR OPENROUTER
|
| 33 |
-
default_headers={
|
| 34 |
-
"Authorization": f"Bearer {os.getenv('OPENROUTER_API_KEY')}",
|
| 35 |
-
"HTTP-Referer": "http://localhost:8501",
|
| 36 |
-
"X-Title": "Project-RAG-App"
|
| 37 |
-
})
|
| 38 |
-
|
| 39 |
-
|
| 40 |
self.vector_store = None
|
| 41 |
|
| 42 |
def process_documents(self, pdf_paths):
|
|
|
|
| 7 |
from langchain_core.runnables import RunnablePassthrough, RunnableParallel
|
| 8 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 9 |
from langchain_openai import ChatOpenAI
|
| 10 |
+
from langchain_community.chat_models import ChatLiteLLM
|
| 11 |
|
| 12 |
class ProjectRAGEngine:
|
| 13 |
def __init__(self):
|
|
|
|
| 17 |
model_kwargs={"device": "cpu"}, # change to "cuda" if GPU available
|
| 18 |
encode_kwargs={"normalize_embeddings": True}
|
| 19 |
)
|
|
|
|
| 20 |
# ✅ OpenRouter LLM (Chat only)
|
| 21 |
+
self.llm = ChatLiteLLM(
|
| 22 |
+
model="openrouter/openai/gpt-oss-120b:free",
|
| 23 |
+
api_key=os.getenv("OPENROUTER_API_KEY"),
|
| 24 |
+
temperature=0
|
| 25 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
self.vector_store = None
|
| 27 |
|
| 28 |
def process_documents(self, pdf_paths):
|