Dinesh310 commited on
Commit
186c2bc
·
verified ·
1 Parent(s): da81268

Update src/rag_engine.py

Browse files
Files changed (1) hide show
  1. src/rag_engine.py +7 -8
src/rag_engine.py CHANGED
@@ -8,6 +8,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):
@@ -18,11 +19,11 @@ class ProjectRAGEngine:
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):
@@ -56,10 +57,8 @@ class ProjectRAGEngine:
56
  Answer strictly using the context.
57
  If unknown, say you don't know.
58
  Cite document names and page numbers.
59
-
60
  Context:
61
  {context}
62
-
63
  Question:
64
  {question}
65
  """
@@ -87,4 +86,4 @@ class ProjectRAGEngine:
87
  for d in result["context"]
88
  ]
89
 
90
- return result["answer"], sources
 
8
  from langchain_community.embeddings import HuggingFaceEmbeddings
9
  from langchain_openai import ChatOpenAI
10
  from langchain_community.chat_models import ChatLiteLLM
11
+ from langchain_core.messages import HumanMessage, AIMessage
12
 
13
  class ProjectRAGEngine:
14
  def __init__(self):
 
19
  encode_kwargs={"normalize_embeddings": True}
20
  )
21
  # ✅ OpenRouter LLM (Chat only)
22
+ self.llm = ChatOpenAI(
23
+ model="openai/gpt-oss-120b:free",
24
+ base_url="https://openrouter.ai/api/v1",
25
+ api_key=os.getenv("OPENROUTER_API_KEY"),
26
+ extra_body={"reasoning": {"enabled": True}})
27
  self.vector_store = None
28
 
29
  def process_documents(self, pdf_paths):
 
57
  Answer strictly using the context.
58
  If unknown, say you don't know.
59
  Cite document names and page numbers.
 
60
  Context:
61
  {context}
 
62
  Question:
63
  {question}
64
  """
 
86
  for d in result["context"]
87
  ]
88
 
89
+ return result["answer"], sources