Use this file to discover all available pages before exploring further.
What this builds. A canonical retrieval-augmented pipeline: a query input feeds both a KnowledgeBaseNode (which retrieves and formats context) and an LlmNode that grounds its answer on the retrieved text.
You’ll end up with. A saved rag-pipeline whose Response output is the LLM’s answer over your knowledge base.
import vectorshiftfrom vectorshift.pipeline import ( Pipeline, InputNode, KnowledgeBaseNode, OutputNode, LlmNode,)from vectorshift import KnowledgeBase# Set API keyvectorshift.api_key = "your api key here"# Create input node for user queryinput_node = InputNode( node_name="Query",)# Fetch knowledge baseknowledge_base = KnowledgeBase.fetch(name="your knowledge base name here")# Create knowledge base node to retrieve relevant documentsknowledge_base_node = KnowledgeBaseNode( query=input_node.text, knowledge_base=knowledge_base, format_context_for_llm=True,)# Create LLM node that uses both the query and retrieved documentsllm_node = LlmNode( system="You are a helpful assistant that answers questions based on the provided context documents.", prompt=f"Query: {input_node.text}\n\nContext: {knowledge_base_node.formatted_text}", provider="openai", model="gpt-4o-mini", temperature=0.7,)# Create output node for the LLM responseoutput_node = OutputNode(node_name="Response", value=llm_node.response)# Create the RAG pipelinePIPELINE_NAME = "rag-pipeline"try: rag_pipeline = Pipeline.fetch(name=PIPELINE_NAME) print(f"Pipeline fetched: id={rag_pipeline.id}, branch_id={rag_pipeline.branch_id}")except Exception as e: print(f"Error fetching pipeline: {e}") rag_pipeline = Pipeline.new( name=PIPELINE_NAME, nodes=[input_node, knowledge_base_node, llm_node, output_node], ) print(f"Pipeline created: id={rag_pipeline.id}, branch_id={rag_pipeline.branch_id}")