Spaces:
Running
Running
File size: 1,691 Bytes
17aafad | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | import os
from dotenv import load_dotenv
from project.pipeline.agents import AgentWorkflow
from project.logger.logging import get_logger
load_dotenv()
logger = get_logger(__name__)
def setup_langsmith():
langsmith_api_key = os.getenv("LANGSMITH_API_KEY")
if langsmith_api_key:
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com"
os.environ["LANGCHAIN_API_KEY"] = langsmith_api_key
os.environ["LANGCHAIN_PROJECT"] = "rag-corrective-pipeline"
logger.info("LangSmith tracing enabled")
else:
logger.warning("LANGSMITH_API_KEY not found, tracing disabled")
def main():
setup_langsmith()
logger.info("Starting RAG application...")
agent = AgentWorkflow()
logger.info("Setting up pipeline with Attention Is All You Need paper...")
agent.setup(use_attention_paper=True)
agent.save_graph("workflow.png")
logger.info("Workflow graph saved")
questions = [
"What is the attention mechanism in transformers?",
"Explain the multi-head attention.",
"What are the advantages of the transformer architecture?"
]
print("\n" + "="*80)
print("RAG PIPELINE WITH CORRECTIVE RAG (CRAG)")
print("="*80 + "\n")
for i, question in enumerate(questions, 1):
print(f"\n{'='*80}")
print(f"Question {i}: {question}")
print(f"{'='*80}\n")
answer = agent.run(question)
print(f"\nAnswer:\n{answer}\n")
print(f"{'='*80}\n")
logger.info("RAG application completed successfully")
if __name__ == "__main__":
main()
|