1 line
No EOL
17 KiB
JavaScript
1 line
No EOL
17 KiB
JavaScript
"use strict";(self.webpackChunkopenrag_docs=self.webpackChunkopenrag_docs||[]).push([[98],{1260:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>h,contentTitle:()=>d,default:()=>g,frontMatter:()=>c,metadata:()=>t,toc:()=>p});const t=JSON.parse('{"id":"get-started/quickstart","title":"Quickstart","description":"Get started with OpenRAG by loading your knowledge, swapping out your language model, and then chatting with the Langflow API.","source":"@site/docs/get-started/quickstart.mdx","sourceDirName":"get-started","slug":"/quickstart","permalink":"/quickstart","draft":false,"unlisted":false,"editUrl":"https://github.com/openrag/openrag/tree/main/docs/docs/get-started/quickstart.mdx","tags":[],"version":"current","frontMatter":{"title":"Quickstart","slug":"/quickstart"},"sidebar":"tutorialSidebar","previous":{"title":"About OpenRAG","permalink":"/"},"next":{"title":"Install OpenRAG with TUI","permalink":"/install"}}');var r=s(4848),i=s(8453),o=s(1610),a=s(1470),l=s(9365);const c={title:"Quickstart",slug:"/quickstart"},d=void 0,h={},p=[{value:"Prerequisites",id:"prerequisites",level:2},{value:"Load and chat with your own documents",id:"load-and-chat-with-your-own-documents",level:2},{value:"Swap out the language model to modify agent behavior",id:"change-components",level:2},{value:"Integrate OpenRAG into your application",id:"integrate-openrag-into-your-application",level:2}];function u(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.p,{children:"Get started with OpenRAG by loading your knowledge, swapping out your language model, and then chatting with the Langflow API."}),"\n",(0,r.jsx)(n.h2,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,r.jsx)(n.admonition,{type:"tip",children:(0,r.jsxs)(n.p,{children:["This quickstart uses a minimal setup to demonstrate OpenRAG's core functionality. After you complete the quickstart, it is recommended that you reinstall OpenRAG with your preferred configuration because some settings are immutable after initial setup. For all installation options, see ",(0,r.jsx)(n.a,{href:"/install",children:"Install OpenRAG with TUI"})," and ",(0,r.jsx)(n.a,{href:"/docker",children:"Install OpenRAG with containers"}),"."]})}),"\n",(0,r.jsxs)(n.p,{children:["Install OpenRAG with the automatic installer.\nThe script detects and installs uv, Docker/Podman, and Docker Compose prerequisites, and then starts OpenRAG with ",(0,r.jsx)(n.code,{children:"uvx"}),"."]}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"Create a directory to store the OpenRAG configuration files:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"mkdir openrag-workspace\ncd openrag-workspace\n"})}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"Run the installer:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"curl -fsSL https://docs.openr.ag/files/run_openrag_with_prereqs.sh | bash\n"})}),"\n",(0,r.jsxs)(n.p,{children:["The TUI creates a ",(0,r.jsx)(n.code,{children:".env"})," file and docker-compose files in the current working directory, and then starts OpenRAG."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Select ",(0,r.jsx)(n.strong,{children:"Basic Setup"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["To generate a password for OpenSearch, click ",(0,r.jsx)(n.strong,{children:"Generate Passwords"}),".\nThe other fields aren't required."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["To start OpenRAG, click ",(0,r.jsx)(n.strong,{children:"Start All Services"}),".\nStartup pulls container images and runs them, so it can take some time.\nWhen startup is complete, the TUI displays the following:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"Services started successfully\nCommand completed successfully\n"})}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["To open the OpenRAG application, navigate to the TUI main menu, and then click ",(0,r.jsx)(n.strong,{children:"Open App"}),".\nAlternatively, in your browser, navigate to ",(0,r.jsx)(n.code,{children:"localhost:3000"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["For your model provider, select ",(0,r.jsx)(n.strong,{children:"OpenAI"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["In the ",(0,r.jsx)(n.strong,{children:"OpenAI API key"})," field, paste your OpenAI API key.\nThe default model settings are fine for the quickstart."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["To confirm your provider settings, click ",(0,r.jsx)(n.strong,{children:"Complete"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["To complete onboarding, click ",(0,r.jsx)(n.strong,{children:"What is OpenRAG"}),", and then click ",(0,r.jsx)(n.strong,{children:"Add a document"}),".\nAlternatively, click ",(0,r.jsx)(o.A,{name:"ArrowRight","aria-hidden":"true"})," ",(0,r.jsx)(n.strong,{children:"Skip overview"}),"."]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["To quit OpenRAG, navigate to the TUI main menu and press ",(0,r.jsx)("kbd",{children:"q"}),".\nTo start OpenRAG again, run ",(0,r.jsx)(n.code,{children:"uvx openrag"}),"."]}),"\n",(0,r.jsx)(n.h2,{id:"load-and-chat-with-your-own-documents",children:"Load and chat with your own documents"}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["In OpenRAG, click ",(0,r.jsx)(o.A,{name:"MessageSquare","aria-hidden":"true"})," ",(0,r.jsx)(n.strong,{children:"Chat"}),".\nThe chat is powered by the OpenRAG OpenSearch Agent.\nFor more information, see ",(0,r.jsx)(n.a,{href:"/agents",children:"Langflow in OpenRAG"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:["Ask ",(0,r.jsx)(n.code,{children:"What documents are available to you?"}),"\nThe agent responds with a message summarizing the documents that OpenRAG loads by default.\nKnowledge is stored in OpenSearch.\nFor more information, see ",(0,r.jsx)(n.a,{href:"/knowledge",children:"OpenSearch in OpenRAG"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:["To confirm the agent is correct about the default knowledge, click ",(0,r.jsx)(o.A,{name:"Library","aria-hidden":"true"})," ",(0,r.jsx)(n.strong,{children:"Knowledge"}),".\nThe ",(0,r.jsx)(n.strong,{children:"Knowledge"})," page lists the documents OpenRAG has ingested into the OpenSearch vector database.\nClick on a document to display the chunks derived from splitting the default documents into the OpenSearch vector database."]}),"\n",(0,r.jsxs)(n.li,{children:["To add documents to your knowledge base, click ",(0,r.jsx)(n.strong,{children:"Add Knowledge"}),".","\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Select ",(0,r.jsx)(o.A,{name:"File","aria-hidden":"true"})," ",(0,r.jsx)(n.strong,{children:"File"})," to add a single file from your local machine."]}),"\n",(0,r.jsxs)(n.li,{children:["Select ",(0,r.jsx)(o.A,{name:"Folder","aria-hidden":"true"})," ",(0,r.jsx)(n.strong,{children:"Folder"})," to process an entire folder of documents from your local machine. The default directory is ",(0,r.jsx)(n.code,{children:"/documents"})," in your OpenRAG directory."]}),"\n",(0,r.jsxs)(n.li,{children:["Select your cloud storage provider to add knowledge from an OAuth-connected storage provider. For more information, see ",(0,r.jsx)(n.a,{href:"/knowledge#oauth-ingestion",children:"OAuth ingestion"}),"."]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["Return to the Chat window and ask a question about your loaded data.\nFor example, with a manual about a PC tablet loaded, ask ",(0,r.jsx)(n.code,{children:"How do I connect this device to WiFi?"}),"\nThe agent responds with a message indicating it now has your knowledge as context for answering questions."]}),"\n",(0,r.jsxs)(n.li,{children:["Click ",(0,r.jsx)(o.A,{name:"Gear","aria-hidden":"true"})," ",(0,r.jsx)(n.strong,{children:"Function Call: search_documents (tool_call)"}),".\nThis log describes how the agent uses tools.\nThis is helpful for troubleshooting when the agent isn't responding as expected."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"change-components",children:"Swap out the language model to modify agent behavior"}),"\n",(0,r.jsxs)(n.p,{children:["To modify the knowledge ingestion or Agent behavior, click ",(0,r.jsx)(o.A,{name:"Settings2","aria-hidden":"true"})," ",(0,r.jsx)(n.strong,{children:"Settings"}),"."]}),"\n",(0,r.jsx)(n.p,{children:"In this example, you'll try a different LLM to demonstrate how the Agent's response changes."}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["To edit the Agent's behavior, click ",(0,r.jsx)(n.strong,{children:"Edit in Langflow"}),".\nYou can more quickly access these parameters in the ",(0,r.jsx)(n.strong,{children:"Language model"})," and ",(0,r.jsx)(n.strong,{children:"Agent Instructions"})," fields in this page, but for illustration purposes, navigate to the Langflow visual builder.\nTo revert the flow to its initial state, click ",(0,r.jsx)(n.strong,{children:"Restore flow"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["OpenRAG warns you that you're entering Langflow. Click ",(0,r.jsx)(n.strong,{children:"Proceed"}),"."]}),"\n",(0,r.jsxs)(n.p,{children:["If Langflow requests login information, enter the ",(0,r.jsx)(n.code,{children:"LANGFLOW_SUPERUSER"})," and ",(0,r.jsx)(n.code,{children:"LANGFLOW_SUPERUSER_PASSWORD"})," from the ",(0,r.jsx)(n.code,{children:".env"})," file in your OpenRAG directory."]}),"\n",(0,r.jsxs)(n.p,{children:["The OpenRAG OpenSearch Agent flow appears in a new browser window.\n",(0,r.jsx)(n.img,{alt:"OpenRAG Open Search Agent Flow",src:s(3982).A+"",width:"4084",height:"2176"})]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Find the ",(0,r.jsx)(n.strong,{children:"Language Model"})," component, and then change the ",(0,r.jsx)(n.strong,{children:"Model Name"})," field to a different OpenAI model."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Save your flow with ",(0,r.jsx)("kbd",{children:"Command+S"})," (Mac) or ",(0,r.jsx)("kbd",{children:"Ctrl+S"})," (Windows)."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Return to the OpenRAG browser window, and start a new conversation by clicking ",(0,r.jsx)(o.A,{name:"Plus","aria-hidden":"true"})," in the ",(0,r.jsx)(n.strong,{children:"Conversations"})," tab."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"Ask the same question you asked before to see how the response differs between models."}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"integrate-openrag-into-your-application",children:"Integrate OpenRAG into your application"}),"\n",(0,r.jsxs)(n.p,{children:["Langflow in OpenRAG includes pre-built flows that you can integrate into your applications using the ",(0,r.jsx)(n.a,{href:"https://docs.langflow.org/api-reference-api-examples",children:"Langflow API"}),"."]}),"\n",(0,r.jsx)(n.p,{children:"The Langflow API accepts Python, TypeScript, or curl requests to run flows and get responses. You can use these flows as-is or modify them to better suit your needs."}),"\n",(0,r.jsx)(n.p,{children:"In this section, you'll run the OpenRAG OpenSearch Agent flow and get a response using the API."}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["To navigate to the OpenRAG OpenSearch Agent flow in Langflow, click ",(0,r.jsx)(o.A,{name:"Settings2","aria-hidden":"true"})," ",(0,r.jsx)(n.strong,{children:"Settings"}),", and then click ",(0,r.jsx)(n.strong,{children:"Edit in Langflow"})," in the OpenRAG OpenSearch Agent flow."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Create a ",(0,r.jsx)(n.a,{href:"https://docs.langflow.org/api-keys-and-authentication",children:"Langflow API key"}),"."]}),"\n",(0,r.jsxs)(n.p,{children:["A Langflow API key is a user-specific token you can use with Langflow.\nIt is ",(0,r.jsx)(n.strong,{children:"only"})," used for sending requests to the Langflow server.\nIt does ",(0,r.jsx)(n.strong,{children:"not"})," access OpenRAG."]}),"\n",(0,r.jsx)(n.p,{children:"To create a Langflow API key, do the following:"}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["Open Langflow, click your user icon, and then select ",(0,r.jsx)(n.strong,{children:"Settings"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:["Click ",(0,r.jsx)(n.strong,{children:"Langflow API Keys"}),", and then click ",(0,r.jsx)(o.A,{name:"Plus","aria-hidden":"true"})," ",(0,r.jsx)(n.strong,{children:"Add New"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:["Name your key, and then click ",(0,r.jsx)(n.strong,{children:"Create API Key"}),"."]}),"\n",(0,r.jsx)(n.li,{children:"Copy the API key and store it securely."}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Langflow includes code snippets for the request to the Langflow API.\nTo retrieve the code snippet, click ",(0,r.jsx)(n.strong,{children:"Share"}),", and then click ",(0,r.jsx)(n.strong,{children:"API access"}),"."]}),"\n",(0,r.jsxs)(n.p,{children:["The default code in the API access pane constructs a request with the Langflow server ",(0,r.jsx)(n.code,{children:"url"}),", ",(0,r.jsx)(n.code,{children:"headers"}),", and a ",(0,r.jsx)(n.code,{children:"payload"})," of request data. The code snippets automatically include the ",(0,r.jsx)(n.code,{children:"LANGFLOW_SERVER_ADDRESS"})," and ",(0,r.jsx)(n.code,{children:"FLOW_ID"})," values for the flow."]}),"\n",(0,r.jsxs)(a.A,{children:[(0,r.jsx)(l.A,{value:"python",label:"Python",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:'import requests\nimport os\nimport uuid\n\napi_key = \'LANGFLOW_API_KEY\'\nurl = "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID" # The complete API endpoint URL for this flow\n\n# Request payload configuration\npayload = {\n "output_type": "chat",\n "input_type": "chat",\n "input_value": "hello world!"\n}\npayload["session_id"] = str(uuid.uuid4())\n\nheaders = {"x-api-key": api_key}\n\ntry:\n # Send API request\n response = requests.request("POST", url, json=payload, headers=headers)\n response.raise_for_status() # Raise exception for bad status codes\n\n # Print response\n print(response.text)\n\nexcept requests.exceptions.RequestException as e:\n print(f"Error making API request: {e}")\nexcept ValueError as e:\n print(f"Error parsing response: {e}")\n'})})}),(0,r.jsx)(l.A,{value:"typescript",label:"TypeScript",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-typescript",children:'const crypto = require(\'crypto\');\nconst apiKey = \'LANGFLOW_API_KEY\';\nconst payload = {\n "output_type": "chat",\n "input_type": "chat",\n "input_value": "hello world!"\n};\npayload.session_id = crypto.randomUUID();\n\nconst options = {\n method: \'POST\',\n headers: {\n \'Content-Type\': \'application/json\',\n "x-api-key": apiKey\n },\n body: JSON.stringify(payload)\n};\n\nfetch(\'http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID\', options)\n .then(response => response.json())\n .then(response => console.warn(response))\n .catch(err => console.error(err));\n'})})}),(0,r.jsx)(l.A,{value:"curl",label:"curl",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:'curl --request POST \\\n --url \'http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID?stream=false\' \\\n --header \'Content-Type: application/json\' \\\n --header "x-api-key: LANGFLOW_API_KEY" \\\n --data \'{\n "output_type": "chat",\n "input_type": "chat",\n "input_value": "hello world!"\n }\'\n'})})})]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"Copy the snippet, paste it in a script file, and then run the script to send the request. If you are using the curl snippet, you can run the command directly in your terminal."}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"If the request is successful, the response includes many details about the flow run, including the session ID, inputs, outputs, components, durations, and more."}),"\n",(0,r.jsx)(n.p,{children:"To further explore the API, see:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["The Langflow ",(0,r.jsx)(n.a,{href:"https://docs.langflow.org/quickstart#extract-data-from-the-response",children:"Quickstart"})," extends this example with extracting fields from the response."]}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"https://docs.langflow.org/api-reference-api-examples",children:"Get started with the Langflow API"})}),"\n"]})]})}function g(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(u,{...e})}):u(e)}},3982:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/opensearch-agent-flow-f3b279e02425cd043002eb7749067108.png"}}]); |