openrag/assets/js/af920ffe.646b8dda.js
2025-10-01 22:22:33 +00:00

1 line
No EOL
21 KiB
JavaScript

"use strict";(self.webpackChunkopenrag_docs=self.webpackChunkopenrag_docs||[]).push([[717],{1260:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>h,contentTitle:()=>c,default:()=>g,frontMatter:()=>d,metadata:()=>s,toc:()=>u});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 OpenRAG API.","source":"@site/docs/get-started/quickstart.mdx","sourceDirName":"get-started","slug":"/quickstart","permalink":"/openrag/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":"Installation","permalink":"/openrag/install"},"next":{"title":"Docker Deployment","permalink":"/openrag/get-started/docker"}}');var o=t(4848),r=t(8453),a=t(9179),i=t(1470),l=t(9365);const d={title:"Quickstart",slug:"/quickstart"},c=void 0,h={},u=[{value:"Prerequisites",id:"prerequisites",level:2},{value:"Find your way around",id:"find-your-way-around",level:2},{value:"Add your own knowledge",id:"add-your-own-knowledge",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 p(e){const n={a:"a",code:"code",h2:"h2",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components},{Details:s}=n;return s||function(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.p,{children:"Get started with OpenRAG by loading your knowledge, swapping out your language model, and then chatting with the OpenRAG API."}),"\n",(0,o.jsx)(n.h2,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.a,{href:"/install",children:"Install and start OpenRAG"})}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["Create a ",(0,o.jsx)(n.a,{href:"https://docs.langflow.org/api-keys-and-authentication",children:"Langflow API key"})]}),"\n",(0,o.jsxs)(s,{children:[(0,o.jsx)("summary",{children:"Create a Langflow API key"}),(0,o.jsxs)(n.p,{children:["A Langflow API key is a user-specific token you can use with Langflow.\nIt is ",(0,o.jsx)(n.strong,{children:"only"})," used for sending requests to the Langflow server.\nIt does ",(0,o.jsx)(n.strong,{children:"not"})," access to OpenRAG."]}),(0,o.jsx)(n.p,{children:"To create a Langflow API key, do the following:"}),(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["In Langflow, click your user icon, and then select ",(0,o.jsx)(n.strong,{children:"Settings"}),"."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["Click ",(0,o.jsx)(n.strong,{children:"Langflow API Keys"}),", and then click ",(0,o.jsx)(a.A,{name:"Plus","aria-hidden":"true"})," ",(0,o.jsx)(n.strong,{children:"Add New"}),"."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["Name your key, and then click ",(0,o.jsx)(n.strong,{children:"Create API Key"}),"."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsx)(n.p,{children:"Copy the API key and store it securely."}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["To use your Langflow API key in a request, set a ",(0,o.jsx)(n.code,{children:"LANGFLOW_API_KEY"})," environment variable in your terminal, and then include an ",(0,o.jsx)(n.code,{children:"x-api-key"})," header or query parameter with your request.\nFor example:"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:'# Set variable\nexport LANGFLOW_API_KEY="sk..."\n\n# Send request\ncurl --request POST \\\n--url "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID" \\\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"\n}\'\n'})}),"\n"]}),"\n"]})]}),"\n"]}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"find-your-way-around",children:"Find your way around"}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsxs)(n.li,{children:["In OpenRAG, click ",(0,o.jsx)(a.A,{name:"MessageSquare","aria-hidden":"true"})," ",(0,o.jsx)(n.strong,{children:"Chat"}),".\nThe chat is powered by the OpenRAG OpenSearch Agent.\nFor more information, see ",(0,o.jsx)(n.a,{href:"/agents",children:"Langflow Agents"}),"."]}),"\n",(0,o.jsxs)(n.li,{children:["Ask ",(0,o.jsx)(n.code,{children:"What documents are available to you?"}),"\nThe agent responds with a message summarizing the documents that OpenRAG loads by default, which are PDFs about evaluating data quality when using LLMs in health care.\nKnowledge is stored in OpenSearch.\nFor more information, see ",(0,o.jsx)(n.a,{href:"/knowledge",children:"Knowledge"}),"."]}),"\n",(0,o.jsxs)(n.li,{children:["To confirm the agent is correct, click ",(0,o.jsx)(a.A,{name:"Library","aria-hidden":"true"})," ",(0,o.jsx)(n.strong,{children:"Knowledge"}),".\nThe ",(0,o.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 vector database."]}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"add-your-own-knowledge",children:"Add your own knowledge"}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsxs)(n.li,{children:["To add documents to your knowledge base, click ",(0,o.jsx)(a.A,{name:"Plus","aria-hidden":"true"})," ",(0,o.jsx)(n.strong,{children:"Add Knowledge"}),".","\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:["Select ",(0,o.jsx)(n.strong,{children:"Add File"})," to add a single file from your local machine (mapped with the Docker volume mount)."]}),"\n",(0,o.jsxs)(n.li,{children:["Select ",(0,o.jsx)(n.strong,{children:"Process Folder"})," to process an entire folder of documents from your local machine (mapped with the Docker volume mount)."]}),"\n",(0,o.jsxs)(n.li,{children:["Select your cloud storage provider to add knowledge from an OAuth-connected storage provider. For more information, see ",(0,o.jsx)(n.a,{href:"/knowledge#oauth-ingestion",children:"OAuth ingestion"}),"."]}),"\n"]}),"\n"]}),"\n",(0,o.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,o.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,o.jsxs)(n.li,{children:["Click the ",(0,o.jsx)(a.A,{name:"Gear","aria-hidden":"true"})," ",(0,o.jsx)(n.strong,{children:"Function Call: search_documents (tool_call)"})," that is printed in the Playground.\nThese events log the agent's request to the tool and the tool's response, so you have direct visibility into your agent's functionality.\nIf you aren't getting the results you need, you can further tune the knowledge ingestion and agent behavior in the next section."]}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"change-components",children:"Swap out the language model to modify agent behavior"}),"\n",(0,o.jsxs)(n.p,{children:["To modify the knowledge ingestion or Agent behavior, click ",(0,o.jsx)(a.A,{name:"Settings2","aria-hidden":"true"})," ",(0,o.jsx)(n.strong,{children:"Settings"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["In this example, you'll try a different LLM to demonstrate how the Agent's response changes.\nYou can only change the ",(0,o.jsx)(n.strong,{children:"Language model"}),", and not the ",(0,o.jsx)(n.strong,{children:"Model provider"})," that you started with in OpenRAG.\nIf you're using Ollama, you can use any installed model."]}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["To edit the Agent's behavior, click ",(0,o.jsx)(n.strong,{children:"Edit in Langflow"}),".\nYou can more quickly access the ",(0,o.jsx)(n.strong,{children:"Language Model"})," and ",(0,o.jsx)(n.strong,{children:"Agent Instructions"})," fields in this page, but for illustration purposes, navigate to the Langflow visual builder."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["OpenRAG warns you that you're entering Langflow. Click ",(0,o.jsx)(n.strong,{children:"Proceed"}),"."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["The OpenRAG OpenSearch Agent flow appears.\n",(0,o.jsx)(n.img,{alt:"OpenRAG Open Search Agent Flow",src:t(3982).A+"",width:"4108",height:"2250"})]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["In the ",(0,o.jsx)(n.strong,{children:"Language Model"})," component, under ",(0,o.jsx)(n.strong,{children:"Model"}),", select a different OpenAI model."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["Save your flow with ",(0,o.jsx)("kbd",{children:"Command+S"}),"."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["In OpenRAG, start a new conversation by clicking the ",(0,o.jsx)(a.A,{name:"Plus","aria-hidden":"true"})," in the ",(0,o.jsx)(n.strong,{children:"Conversations"})," tab."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsx)(n.p,{children:"Ask the same question as before to demonstrate how a different language model changes the results."}),"\n"]}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"integrate-openrag-into-your-application",children:"Integrate OpenRAG into your application"}),"\n",(0,o.jsxs)(n.p,{children:["To integrate OpenRAG into your application, use the ",(0,o.jsx)(n.a,{href:"https://docs.langflow.org/api-reference-api-examples",children:"Langflow API"}),".\nMake requests with Python, TypeScript, or any HTTP client to run one of OpenRAG's default flows and get a response, and then modify the flow further to improve results."]}),"\n",(0,o.jsx)(n.p,{children:"Langflow provides code snippets to help you get started with the Langflow API."}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["To navigate to the OpenRAG OpenSearch Agent flow, click ",(0,o.jsx)(a.A,{name:"Settings2","aria-hidden":"true"})," ",(0,o.jsx)(n.strong,{children:"Settings"}),", and then click ",(0,o.jsx)(n.strong,{children:"Edit in Langflow"})," in the OpenRAG OpenSearch Agent flow."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["Click ",(0,o.jsx)(n.strong,{children:"Share"}),", and then click ",(0,o.jsx)(n.strong,{children:"API access"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["The default code in the API access pane constructs a request with the Langflow server ",(0,o.jsx)(n.code,{children:"url"}),", ",(0,o.jsx)(n.code,{children:"headers"}),", and a ",(0,o.jsx)(n.code,{children:"payload"})," of request data. The code snippets automatically include the ",(0,o.jsx)(n.code,{children:"LANGFLOW_SERVER_ADDRESS"})," and ",(0,o.jsx)(n.code,{children:"FLOW_ID"})," values for the flow. Replace these values if you're using the code for a different server or flow. The default Langflow server address is ",(0,o.jsx)(n.a,{href:"http://localhost:7860",children:"http://localhost:7860"}),"."]}),"\n",(0,o.jsxs)(i.A,{children:[(0,o.jsx)(l.A,{value:"python",label:"Python",children:(0,o.jsx)(n.pre,{children:(0,o.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,o.jsx)(l.A,{value:"typescript",label:"TypeScript",children:(0,o.jsx)(n.pre,{children:(0,o.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,o.jsx)(l.A,{value:"curl",label:"curl",children:(0,o.jsx)(n.pre,{children:(0,o.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\t\t "output_type": "chat",\n\t\t "input_type": "chat",\n\t\t "input_value": "hello world!",\n\t\t }\'\n'})})})]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.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,o.jsxs)(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.\nThe following is an example of a response from running the ",(0,o.jsx)(n.strong,{children:"Simple Agent"})," template flow:"]}),"\n",(0,o.jsxs)(s,{children:[(0,o.jsx)("summary",{children:"Result"}),(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-json",children:'{\n "session_id": "29deb764-af3f-4d7d-94a0-47491ed241d6",\n "outputs": [\n {\n "inputs": {\n "input_value": "hello world!"\n },\n "outputs": [\n {\n "results": {\n "message": {\n "text_key": "text",\n "data": {\n "timestamp": "2025-06-16 19:58:23 UTC",\n "sender": "Machine",\n "sender_name": "AI",\n "session_id": "29deb764-af3f-4d7d-94a0-47491ed241d6",\n "text": "Hello world! \ud83c\udf0d How can I assist you today?",\n "files": [],\n "error": false,\n "edit": false,\n "properties": {\n "text_color": "",\n "background_color": "",\n "edited": false,\n "source": {\n "id": "Agent-ZOknz",\n "display_name": "Agent",\n "source": "gpt-4o-mini"\n },\n "icon": "bot",\n "allow_markdown": false,\n "positive_feedback": null,\n "state": "complete",\n "targets": []\n },\n "category": "message",\n "content_blocks": [\n {\n "title": "Agent Steps",\n "contents": [\n {\n "type": "text",\n "duration": 2,\n "header": {\n "title": "Input",\n "icon": "MessageSquare"\n },\n "text": "**Input**: hello world!"\n },\n {\n "type": "text",\n "duration": 226,\n "header": {\n "title": "Output",\n "icon": "MessageSquare"\n },\n "text": "Hello world! \ud83c\udf0d How can I assist you today?"\n }\n ],\n "allow_markdown": true,\n "media_url": null\n }\n ],\n "id": "f3d85d9a-261c-4325-b004-95a1bf5de7ca",\n "flow_id": "29deb764-af3f-4d7d-94a0-47491ed241d6",\n "duration": null\n },\n "default_value": "",\n "text": "Hello world! \ud83c\udf0d How can I assist you today?",\n "sender": "Machine",\n "sender_name": "AI",\n "files": [],\n "session_id": "29deb764-af3f-4d7d-94a0-47491ed241d6",\n "timestamp": "2025-06-16T19:58:23+00:00",\n "flow_id": "29deb764-af3f-4d7d-94a0-47491ed241d6",\n "error": false,\n "edit": false,\n "properties": {\n "text_color": "",\n "background_color": "",\n "edited": false,\n "source": {\n "id": "Agent-ZOknz",\n "display_name": "Agent",\n "source": "gpt-4o-mini"\n },\n "icon": "bot",\n "allow_markdown": false,\n "positive_feedback": null,\n "state": "complete",\n "targets": []\n },\n "category": "message",\n "content_blocks": [\n {\n "title": "Agent Steps",\n "contents": [\n {\n "type": "text",\n "duration": 2,\n "header": {\n "title": "Input",\n "icon": "MessageSquare"\n },\n "text": "**Input**: hello world!"\n },\n {\n "type": "text",\n "duration": 226,\n "header": {\n "title": "Output",\n "icon": "MessageSquare"\n },\n "text": "Hello world! \ud83c\udf0d How can I assist you today?"\n }\n ],\n "allow_markdown": true,\n "media_url": null\n }\n ],\n "duration": null\n }\n },\n "artifacts": {\n "message": "Hello world! \ud83c\udf0d How can I assist you today?",\n "sender": "Machine",\n "sender_name": "AI",\n "files": [],\n "type": "object"\n },\n "outputs": {\n "message": {\n "message": "Hello world! \ud83c\udf0d How can I assist you today?",\n "type": "text"\n }\n },\n "logs": {\n "message": []\n },\n "messages": [\n {\n "message": "Hello world! \ud83c\udf0d How can I assist you today?",\n "sender": "Machine",\n "sender_name": "AI",\n "session_id": "29deb764-af3f-4d7d-94a0-47491ed241d6",\n "stream_url": null,\n "component_id": "ChatOutput-aF5lw",\n "files": [],\n "type": "text"\n }\n ],\n "timedelta": null,\n "duration": null,\n "component_display_name": "Chat Output",\n "component_id": "ChatOutput-aF5lw",\n "used_frozen_result": false\n }\n ]\n }\n ]\n}\n'})})]}),"\n",(0,o.jsx)(n.p,{children:"To further explore the API, see:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:["The Langflow ",(0,o.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,o.jsx)(n.li,{children:(0,o.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,r.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(p,{...e})}):p(e)}},3982:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/opensearch-agent-flow-a3c183a9f2d5ec513819aba1f1b49c39.png"},9179:(e,n,t)=>{t.d(n,{A:()=>r});t(6540);var s=t(4827),o=t(4848);function r({name:e,...n}){const t=s[e];return t?(0,o.jsx)(t,{...n}):null}}}]);