openrag/assets/js/af920ffe.059a83cf.js
2025-10-29 17:22:54 +00:00

1 line
No EOL
14 KiB
JavaScript

"use strict";(self.webpackChunkopenrag_docs=self.webpackChunkopenrag_docs||[]).push([[98],{1260:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>h,contentTitle:()=>c,default:()=>g,frontMatter:()=>d,metadata:()=>s,toc:()=>p});const s=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":"Install OpenRAG containers","permalink":"/get-started/docker"},"next":{"title":"Langflow in OpenRAG","permalink":"/agents"}}');var r=t(4848),i=t(8453),o=t(1610),a=t(1470),l=t(9365);const d={title:"Quickstart",slug:"/quickstart"},c=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",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.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Install and start OpenRAG with the ",(0,r.jsx)(n.a,{href:"/install",children:"TUI"})," or ",(0,r.jsx)(n.a,{href:"/get-started/docker",children:"Docker"})]}),"\n"]}),"\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 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:t(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,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/opensearch-agent-flow-f3b279e02425cd043002eb7749067108.png"}}]);