ChatBotAgenticRAG1 / refusal_chain.py
Phoenix21's picture
Update refusal_chain.py
012428a verified
raw
history blame contribute delete
559 Bytes
# refusal_chain.py
import os
from langchain.chains import LLMChain
from langchain_groq import ChatGroq
from langchain_core.output_parsers import StrOutputParser
from prompts import refusal_prompt
def get_refusal_chain() -> LLMChain:
"""
Builds the refusal chain for out-of-scope queries.
"""
chat_groq_model = ChatGroq(
model="Gemma2-9b-It",
groq_api_key=os.environ["GROQ_API_KEY"] # must be set in environment
)
output_parser=StrOutputParser()
chain=refusal_prompt|chat_groq_model|output_parser
return chain