Spaces:
Sleeping
Sleeping
Fixed the RAG with openrouter
Browse files85 unmodified lines868788899091929394959673 unmodified lines17017117217317417517617785 unmodified linesprompt=router_prompt)# Company QA Chaincompany_qa_chain = load_qa_chain(llm, chain_type="stuff")# Cybersecurity Chaincybersecurity_template = """You are a cybersecurity expert. Answer the following cybersecurity question based on your knowledge without claiming yourself as expert:Question: {question}73 unmodified lines"route": "COMPANY"}# Run the QA chainanswer = company_qa_chain.run(input_documents=docs, question=query)sources = list(set([doc.metadata.get("source", "Unknown") for doc in docs]))return {85 unmodified lines868788899091929394959697989910010110210310410510610710810911011111211311411511673 unmodified lines19019119219319419519619719819920085 unmodified linesprompt=router_prompt)# Custom Company QA Chain with natural promptcompany_qa_template = """You are a helpful assistant for CyberAlertNepal. Answer the following question about our company using the information provided and links if only available. Give a natural, direct and polite response .Question: {question}Information:{context}Answer:"""company_qa_prompt = PromptTemplate(input_variables=["question", "context"],template=company_qa_template)company_qa_chain = LLMChain(llm=llm,prompt=company_qa_prompt)# Cybersecurity Chaincybersecurity_template = """You are a cybersecurity professional. Answer the following question truthfully and concisely.If you are not 100% sure about the answer, simply respond with: "I am not sure about the answer."Do not add extra explanations or assumptions. Do not provide false or speculative information.Question: {question}73 unmodified lines"route": "COMPANY"}# Combine document content for contextcontext = "\n\n".join([doc.page_content for doc in docs])# Run the custom QA chainanswer = company_qa_chain.run(question=query, context=context)sources = list(set([doc.metadata.get("source", "Unknown") for doc in docs]))return {
features/rag_chatbot/rag_pipeline.py+28-5