<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ekrem Yıldız on Medium]]></title>
        <description><![CDATA[Stories by Ekrem Yıldız on Medium]]></description>
        <link>https://medium.com/@yildz.ekrem?source=rss-8b1b4e29e57a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*T4kWI88pKB4VgB0CvUUljQ.jpeg</url>
            <title>Stories by Ekrem Yıldız on Medium</title>
            <link>https://medium.com/@yildz.ekrem?source=rss-8b1b4e29e57a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 13:01:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yildz.ekrem/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From RAG Chaos to Reliable AI Agents: Disciple]]></title>
            <link>https://medium.com/turknettech/from-rag-chaos-to-reliable-ai-agents-disciple-8bd370aeb620?source=rss-8b1b4e29e57a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bd370aeb620</guid>
            <category><![CDATA[knowledge-base]]></category>
            <category><![CDATA[agentic-rag]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Ekrem Yıldız]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 06:20:07 GMT</pubDate>
            <atom:updated>2026-01-05T06:20:07.624Z</atom:updated>
            <content:encoded><![CDATA[<p>AI agents are increasingly occupying more space in our daily lives. Beyond general-purpose models like ChatGPT or Gemini, which support us in many everyday tasks, <em>we are now seeing agents that can independently solve industrial problems</em>. In these types of solutions, as the complexity of agents increases, the main challenge stops being the model itself. The real problems — especially in RAG-based solutions — emerge <strong>during the retrieval of the right data</strong> and presenting it to the agent. This makes content management, control, and operational sustainability critically important.</p><p>In RAG- and agent-based systems, when knowledge is not properly structured, cannot be tested, or when it is unclear what is currently live in production, even the most powerful agent becomes <strong>unreliable</strong>. This is exactly the point where we built <strong>Disciple</strong>. With <strong>Disciple</strong>, our goal was to ensure that any knowledge base content can be managed, validated, and delivered to production with maximum confidence and safety.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dd7gUjjH4Qchapf1n83Z2Q.png" /></figure><p><strong>In this article,</strong> I’ll first touch on how our expectations from AI change when we move from general-purpose models to industrial AI agents. Then, I’ll dive into why Knowledge Base management becomes one of the most critical layers in RAG-based agent systems. Finally, I’ll walk through how we designed Disciple to bring control, testability, and operational confidence into this layer, and why this matters when scaling AI agents in production environments.</p><h3>From Next-Token Prediction to Industrial AI Agents</h3><p>Before diving into agents and the solutions we provide with Disciple, it is worth briefly revisiting, how an LLM actually works. At its core, what an LLM does is quite simple: given a sequence of tokens, it predicts which token should come next — <strong><em>next-token prediction</em></strong>. This simple mechanism, when scaled with massive amounts of data and parameters, forms the foundation of today’s highly capable models.</p><p>Because of this, when we approach AI as a “general challenge,” our expectations naturally grow. We want it to know mathematics, solve large problems, not make mistakes in simple daily tasks… These are exactly the kinds of expectations we have from models like ChatGPT or Gemini.</p><p>However, when it comes to <strong>delivering an industrial solution</strong>, the picture changes.</p><p>In industrial contexts, <strong>success</strong> is not defined by how broadly an AI can reason, but by <strong>how reliably it can solve a small, well-defined problem end to end, in a consistent and measurable way</strong>. Even if this problem represents only a small part of a larger process, it must be handled reliably from start to finish. Only then can we perform a meaningful cost–benefit analysis and measure how much human effort the solution truly eliminates.</p><h4>Let’s dive into AI agents..</h4><p>An AI agent is not just a model that generates text; it is an entity that can operate within a workflow that we explicitly design. In production environments, agents are equipped with tools that <strong>manage narrowly scoped, well-defined processes</strong>. Each of these processes may be small on its own, but as their number grows and their interactions are structured coherently, agents can solve larger and more complex tasks in a controlled manner.</p><p>In practice, we can group agent tools into three main categories:</p><ul><li><strong>Flows:</strong> Structures that manage processes deterministically through predefined states and transitions.</li><li><strong>API-based services:</strong> Services that retrieve specific user- or system-related data exactly when needed.</li><li><strong>Knowledge Base services:</strong> Services that perform retrieval over agent-specific vector databases to fulfill their function.</li></ul><p>By definition, flows and APIs are designed to solve <strong>deterministic problems with clear boundaries</strong>. The Knowledge Base layer, however, is fundamentally probabilistic. To solve these problems, we rely on Retrieval-Augmented Generation (RAG) and store knowledge in vector databases.</p><p>At a surface level, a RAG system looks quite simple. Documents are embedded, split into chunks, and written into a vector database. At query time, relevant chunks are retrieved and injected into the model’s context. Embedding, chunking, indexing — that’s it.</p><p>But once we move into <strong>production</strong>, this layer becomes <strong>one of the most fragile parts</strong> of the agent architecture.</p><p>General-purpose RAG solutions typically rely on automated information extraction <strong><em>from documents or web pages</em></strong>. While this approach can work for exploratory or experimental use cases, it introduces serious problems in production environments. Content ownership becomes unclear, data quality cannot be guaranteed, and the most critical question often cannot be answered confidently:</p><blockquote><strong>“What exact information is being served to users right now?”</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qFrnw9vhIW-eaF5dquvYCA.png" /><figcaption>As we need reliable, auditable solutions, the agents should be designed in a different mindset.</figcaption></figure><p>An industrial approach requires a different mindset. Instead of treating documents as raw inputs, <strong><em>knowledge must be prepared, structured, and curated from the very beginning</em></strong>. This is essential for building consistent agents. Content management, traceability, and accuracy must be ensured by design — before the data ever reaches the vector database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2xdzFZeD513vqVtLfdcTA.png" /><figcaption>General RAGs’ Knowledge Base Pipeline</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kPh9ju405QkgkziPBJzVrg.png" /><figcaption>Disciple’s Knowledge Base Pipeline — We create our own structured data to make sure each information available for the agent.</figcaption></figure><p>An incorrect or irrelevant retrieval can break the entire behavior of an agent. Worse, this failure is often silent. If RAG fails, the agent fails — and in most cases, <strong><em>the root cause is not the model, but the data</em></strong>. A wrong chunk leads to wrong retrieval, which leads to a wrong answer. Undebuggable knowledge results in an untrustworthy system.</p><p>As the TurkNet AI team, we follow this principle across all of our RAG-based agent projects that rely on Knowledge Bases. Since the teams responsible for producing and maintaining this content are our product and quality teams, we provide them with a dedicated platform to manage it: <strong>Disciple</strong>. By separating content creation from embedding and retrieval pipelines, we ensure that knowledge remains both controllable and safe for agents to consume in production.</p><blockquote><strong><em>If retrieval fails, agent fails — and this happens usually silently.</em></strong></blockquote><h3>Structure of the Disciple</h3><p>Disciple is designed to be adaptable to different RAG-based systems as well as more complex agent architectures. In this case, I’ll focus on a live, customized version of Disciple built for our <strong>Digital Assistant</strong> — a customer support assistant that operates in a multi-agent setup rather than as a single, monolithic system.</p><p>In this architecture, a master agent coordinates multiple domain-specific expert agents. Each expert agent has its own set of tools, diagnostic flows, and knowledge base. Through Disciple, we manage all of these knowledge bases centrally. On the infrastructure side, each expert’s knowledge base corresponds to a separate collection in <a href="https://qdrant.tech/">Qdrant</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*8PbsfxjOyl6yTxwSneRHgQ.png" /><figcaption>Main Structure of our Digital Assistant. Disciple is used to edit Knowledge Base of each expert.</figcaption></figure><p>One of the most critical design decisions behind <strong>Disciple</strong> was <strong>the ability to test Knowledge Base changes before they are pushed to the live environment</strong>. Any content change made in production carries risk. Compared to the previous state, incorrect retrievals may occur, or previously working behaviors may break. Similarly, when introducing new knowledge base content, it is essential to test how users will actually experience the responses generated by the system.</p><p>For this reason, we designed <strong>Disciple</strong> to <strong><em>include a pre-production environment</em></strong> that mirrors the production setup almost exactly. In practice, the only difference is that the underlying vector database points to a pre-production instance. This allows content changes to be applied and evaluated safely before going live.</p><p>Editors can test their updates in pre-production by interacting directly with the agent running in “debug mode” through <strong>Disciple</strong>. We enable this by intercepting the debug mode in our main <strong>Digital Assistant</strong> application, ensuring that <strong>Disciple</strong>’s tests are executed against the correct pre-production collections.</p><p>After testing is complete, the content is synchronized to production through a controlled approval process. This deployment can be carried out directly from the interface, without any dependency on the technical team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*bhOZplZ2e-_CPPlwYzVFNw.png" /><figcaption>Any modification on Knowledge Base is testable in <strong>Disciple</strong> to ensure that the user experience remains consistent and predictable.</figcaption></figure><p>On the interface side, we structured <strong>Disciple</strong> into a small number of focused sections. The <strong>Collections</strong>, <strong>Upload</strong>, and <strong>Demo</strong> pages handle the knowledge base lifecycle, while the <strong>Chats</strong> and <strong>Stats</strong> pages provide visibility into live usage and quality analysis.</p><p>The core idea was simple: to give users with editor permissions a real-time snapshot of the production system, allowing them to observe potential issues in the knowledge base layer, make adjustments, and safely deploy updated content to production — all from a single interface.</p><h4>Collection Management</h4><p>In terms of data architecture, alongside the live vector database we run on Qdrant, we also use a <a href="https://www.postgresql.org/">PostgreSQL</a> database to track all changes, additions, and versioning operations.</p><p>In our main table, <strong>Collection_Items</strong>, each knowledge base entry is recorded separately. To support versioning and rollback on the same item, each Knowledge Base entry is identified by a <strong>group_id</strong>. This allows us to overwrite the existing vector in Qdrant when an item is updated.</p><p>Since multiple records can belong to the same knowledge base item, the currently active version is marked with <strong><em>is_active=True</em></strong>, while previous versions are retained for traceability and rollback purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NhxYgooj-kyDwD3S8RInMA.png" /><figcaption>Edit operation workflow on knowledge base items: left-part is for the Disciple use-case, right-part is for live synchronization.</figcaption></figure><p>In addition, all CRUD operations are managed through explicit states such as <strong>Pending</strong>, <strong>Approved</strong>, and <strong>Synced</strong>. This ensures that every change is first applied to the pre-production collections, and only after explicit approval are the production collections updated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-NLEkIkLCfJmJ9vSoSyKZw.png" /><figcaption>Crucial fields of Collection Items to create versionable system.</figcaption></figure><h4>User Roles</h4><p>Role-based access control was integrated into Disciple, especially because live customer data can be viewed within the platform as part of the real-time snapshot of the main application. At a high level, we identified the need for three distinct roles.</p><ul><li><strong>Viewers — </strong>can only view Knowledge Base contents through the <em>Collection</em> page.</li><li><strong>Editors</strong> — typically domain experts from product and quality teams — have additional capabilities. They can inspect live application chats, create, edit, and delete knowledge base items through the <em>Collection</em> page, and test their changes using the <em>Demo</em> page.</li><li><strong>Admins</strong> — have all editor permissions, with the added ability to synchronize approved knowledge base changes to the production environment.</li></ul><p>This separation is not only required due to regulations such as personal data protection laws, but also plays a key role in ensuring security and operational simplicity. We address this requirement easily by leveraging <a href="https://flask-security-too.readthedocs.io/en/stable/">Flask Security</a>’s Role-Based Access Control (RBAC) system:</p><pre>from flask_security import roles_accepted<br><br>@main.route(&quot;/collection&quot;)<br>@login_required<br>@roles_accepted(&quot;admin&quot;, &quot;editor&quot;, &quot;viewer&quot;)<br>def collection():<br>    ...<br><br>@main.route(&quot;/demo&quot;)<br>@login_required<br>@roles_accepted(&quot;admin&quot;, &quot;editor&quot;)</pre><p>The functions are accessible by accepted roles in the initial definitions.</p><h4>User Experience</h4><p>All the active knowledge base items are visible in the Collection Page. There are simple search and filter mechanisms available. Authorized users can manipulate the content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8QUvnn-RHzDOJ5RwG_YQTg.png" /><figcaption>Collection Page — All active items are visible here.</figcaption></figure><p>Once an editor makes any change, the related questions can be tested through the <strong><em>Demo</em></strong> page. We designed this page as a debugging module: if a response is incorrect, the user can inspect detailed information about the agent call. In some cases, the expected knowledge base content may not have been retrieved for the question; in others, the question may have been routed to an unintended expert agent:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NC1nbqUh0TBVPSRv4QQQ-g.png" /><figcaption>Demo page: test area of current changes.</figcaption></figure><p>Beyond this debugging capability, we see <strong>Disciple</strong> gradually expanding in scope. In upcoming iterations, we discuss to allow updates to the central agent’s prompt and expert-specific prompts directly through <strong>Disciple</strong>. With the right technical foundations in place, enabling product teams to manage flows and service definitions through Disciple starts to feel like a natural next step — one that turns Disciple into more than just a knowledge base portal.</p><p>Up to this point, the components described represent the core of Disciple’s architecture. In addition, through the <strong>Upload</strong> page, authorized users (admins) can promote approved changes to production or roll them back when necessary.</p><p>The <strong>Chats</strong> and <strong>Stats</strong> pages, on the other hand, are designed to be flexible. Depending on the data structure of the AI agent running in the main application, these pages can be customized to support different monitoring, analysis, and quality-tracking needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fFIxnqGWlDzzf4lZLLGT2w.png" /><figcaption><strong>Chats</strong> page of Disciple for Digital Assistant. The users can view the live stats and details of a specific session. That is important for debugging the faults of the Agent and especially Knowledge Base content.</figcaption></figure><h3>In conclusion;</h3><p>Disciple’s main goal is to bring <strong>all Knowledge Base management processes</strong> required for a RAG-based agent project <strong>into a single platform</strong>.</p><p>Before Disciple, even a small content change in a production system followed a painful workflow. Content teams would notify us, we would apply the changes manually, rerun embedding pipelines, and treat almost every update like a version release. As the number of projects and agents grew, this approach quickly became unsustainable.</p><h4>With Disciple:</h4><ul><li>Dependencies between teams were significantly reduced.</li><li>Content management became much faster and smoother.</li><li>And most importantly, the question <em>“What exactly are we serving to users as a Knowledge Base in production right now?”</em> finally became answerable.</li></ul><blockquote><strong>Disciple doesn’t make agents smarter — it makes them reliable</strong>. And in industrial AI agent solutions, that’s what truly makes the difference.</blockquote><p>We’ll be sharing the core source code on GitHub very soon — stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bd370aeb620" width="1" height="1" alt=""><hr><p><a href="https://medium.com/turknettech/from-rag-chaos-to-reliable-ai-agents-disciple-8bd370aeb620">From RAG Chaos to Reliable AI Agents: Disciple</a> was originally published in <a href="https://medium.com/turknettech">Turknet Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Your Own Q/A Bot with Langflow]]></title>
            <link>https://medium.com/turknettech/create-your-own-q-a-bot-with-langflow-dead90093f2d?source=rss-8b1b4e29e57a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dead90093f2d</guid>
            <category><![CDATA[q-and-a]]></category>
            <category><![CDATA[langflow]]></category>
            <category><![CDATA[turknet]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Ekrem Yıldız]]></dc:creator>
            <pubDate>Thu, 28 Nov 2024 12:50:50 GMT</pubDate>
            <atom:updated>2024-11-28T12:52:15.671Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to the world of GenAI powered assistants. In this blog post, we will walk you through how to create a simple Q/A (question-answering) system on documents using LangFlow. Additionally, we will introduce the Retrieval-Augmented Generation (RAG) method, demonstrating how to build a more advanced Q/A system on LangFlow with a practical example for handling larger and more complex documents.</p><p>At <strong>TurkNet</strong>, we leverage <strong>LangFlow</strong> to build straightforward demos for various LLM (Language Model) applications. The tool enables us to efficiently collect data and organize prompts from stakeholders, simplifying the process of developing and testing these demos.</p><h3>Quick Intro About Langflow</h3><p>LangFlow is a low-code platform designed for developers, simplifying the creation of powerful AI agents and workflows that can interact with any API, model, or database. Some examples of what you can build with LangFlow include:</p><ul><li>A Q&amp;A system for documents</li><li>A helper assistant for chatting about any topic</li><li>An agent with multiple capabilities, such as retrieving data, performing actions, and facilitating interactions between different “tools.”</li></ul><p>With <strong>LangFlow</strong>, you can quickly prototype simplified versions of many trending AI use cases. Additionally, you can easily experiment with various LLM models (such as <strong>GPT</strong>, <strong>Groq</strong>, <strong>Anthropiq</strong>, or even your own local LLM model) and compare their performance based on your specific requirements.</p><h3>Section 1: Getting Started with Langflow</h3><p>If you are familiar with python environment and packages, you may want pass this section.</p><ul><li><strong>1.1. Installing and Setting Up Langflow</strong></li></ul><p>It’s really easy to run LangFlow. You just need a Python environment to install LangFlow locally. If you don’t have a Python environment on your local machine, you can follow this link to install <a href="https://docs.anaconda.com/miniconda/">Miniconda</a>. I assume you already have a Python interpreter (Miniconda, in our example) set up.</p><p>First we need to create a new environment, let’s name it as <em>langflow</em>:</p><pre>conda create -n langflow python==3.11<br>conda activate langflow</pre><p>Next, we need to install the <a href="https://pypi.org/project/langflow/"><em>langflow</em></a> package. If there are new updates, you may want to install the latest version. In this tutorial, version 1.0.18 is used.</p><pre>python -m pip install langflow==1.0.18<br>or<br>python -m pip install langflow</pre><p>After the required packages installed you just start <em>langflow</em> from your python terminal:</p><pre>python -m langflow run</pre><p>Then you can open this link in your browser <a href="http://127.0.0.1:7860/all">http://127.0.0.1:7860/</a> to access langflow. If everything is set up correctly, you should see a screen similar to Image 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OYOpqgTQStH49SK8NLSdYA.png" /><figcaption>Image 1: Langflow UI — Initial Page</figcaption></figure><p><strong>1.2. Understanding Langflow’s Interface</strong></p><p>We are now ready to continue with the interface. There is a section called <strong>Folders</strong> to store your projects. You can customize this section to enable downloading/uploading entire folders at once. There is also a <strong>Store</strong> section, where you can access examples published by the community, including use cases from real users. These can be accessed via an API key from LangFlow, though this is not the focus of this tutorial.</p><p>The <strong>Flows</strong> section is where you’ll primarily work. To create a new flow, click the <strong>New Project</strong> button. It will ask if you’d like to use a template or start from scratch. The templates will look like Image 2. For this tutorial, we’ll continue with the <strong>Document QA</strong> template as a basic example.</p><figure><img alt="Image 2: Project Templates" src="https://cdn-images-1.medium.com/max/1024/1*zvtBMNhBLzavzGAkuZTd9g.png" /><figcaption>Image 2: Available Flow Templates</figcaption></figure><p>As a brief, we will dive into the logic of language models in the next section.</p><h3>Section 2: How Querying Works on a Language Model</h3><p>From classical NLP models to the latest LLMs, we use <em>embedding</em> models to convert text-based data into numerical representations. Each language model has its own embedding model that generates numerical data for processing. This numerical data is referred to as vectors, which are one-dimensional arrays.</p><p>In our use case, we first need to retrieve our data. If the data source includes images or websites, we must extract the text data using OCR (Optical Character Recognition) and crawling models. Once we have the dataset as text documents, we need to embed them into vectors. This is the preprocessing step, which results in the information being represented as vectors — our data source once the process is complete.</p><p>When we want to query the data, the query should also pass through the same embedding model. This way, all the text data is in vector format. This step is a prerequisite for working with language models.</p><p>In LLMs, the embedded data is fed into the <strong>Prompt</strong>. The model then takes the prompt and generates a response or answer, as directed. The scheme is drawn in Image 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*85uh-4dY3xdWVshZYLOaOw.png" /><figcaption>Image 3: Logic of Basic Q/A on an LLM</figcaption></figure><p>In the next section we will create this model in Langflow.</p><h3>Section 3: Lets Create A Simple Document Q&amp;A Chain</h3><h4><strong>2.1. Let’s Create A Basic Document QA Workflow</strong></h4><p>We start from the flow template given in Image 4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1YWd6ZlEJSS1XN5Ajpp9mA.png" /><figcaption>Image 4: Document QA Flow</figcaption></figure><p>In this use case, we have a document to search for question answering, summarization, or other tasks. The document is loaded into the <strong>File</strong> component, where you can upload any text data from your file. Supported file formats include: .txt, .md, .mdx, .csv, .json, .yaml, .yml, .xml, .html, .htm, .pdf, .docx, .py, .sh, .sql, .js, .ts, and .tsx.</p><p>As an example, we are using the <a href="https://www.mevzuat.gov.tr/mevzuatmetin/1.5.2709.pdf">Constitution of Turkey</a>. The <strong>Parse Data</strong> component reads the data and divides it into chunks that will be fed into the <strong>Prompt</strong>, as discussed in the previous section.</p><p>The prompt uses a generic template that takes the document and queries it with the question. In LangFlow’s template, the prompt is already set up for generic Q&amp;A. The prompt is as follows:</p><pre>Answer user&#39;s questions based on the document below:<br><br>---<br>{Document}<br>---<br>Question:<br>{Question}<br>Answer:</pre><p>The question comes from the <strong>Chat Input</strong> component. Once the user sends the message, the prompt is compiled and passed to the OpenAI LLM module (the GPT-4o model by default). After the model responds, the output from the LLM is sent to the <strong>Chat Output</strong> module.</p><p>In LangFlow, the <strong>Chat Input</strong> and <strong>Chat Output</strong> components are the main communication points between the user and the flow. You can send input and receive output messages from anywhere in the chat. This is one of the most useful features of LangFlow.</p><p>Once you’ve completed everything, you’ll need to enter your OpenAI API key in order to use GPT models. After that, you’re ready to run the flow by clicking the <strong>Run</strong> button at the top of the <strong>Chat Output</strong> component. All of the components will execute from beginning to end, and the build is complete when you see the green tick in the <strong>Chat Output</strong>. At that point, you can open the <strong>Playground</strong> pane and start interacting with the document.</p><p>In the <strong>Playground</strong> pane, there is a chat space that looks like Image 5. You can ask questions about the document in this area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAI2NWveOqtym7JPEbR2FA.png" /><figcaption>Image 5: Playground Area</figcaption></figure><p>It’s as simple as that. However, in this example, we’ve loaded the entire document into the flow. What about large documents? This approach may not be practical, as there is a token limit for LLMs, which could prevent the model from responding to long documents. Even if the document is within the token limits, OpenAI charges based on token usage, so it could quickly deplete your credit. We will explore RAG, which is a solution of this problem.</p><h3>Section 4: How About Long Documents — RAG</h3><p>For longer documents, we use a technique called Retrieval-Augmented Generation (RAG), which helps retrieve a relevant, smaller portion of the dataset to use in the prompt. To implement a RAG system with a language model, there are two key steps: creating a vector database and retrieving the relevant data.</p><h4>Section 4.1: Creating a Vector DB</h4><p>The general process for creating a vector database is shown in Image 6. While we may have a large number of documents, the core concept remains the same: we need a vector database (vectorstores) to store the many vectors generated from the data. At TurkNet, we use <strong>Qdrant</strong> as our vector database because it is rapidly growing and supports fast querying algorithms (such as <strong>HNSW</strong>), in addition to being an open-source platform. Compared to other alternatives, it offers strong performance. However, most vector databases (e.g., <strong>Weaviate</strong>, <strong>Milvus</strong>, <strong>Chroma</strong>, etc.) will perform similarly when handling smaller datasets (approximately up to 100,000 vectors).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6KlEhCyJ6wuG1rRY6E5Aw.png" /><figcaption>Image 6: Loading data to vector database</figcaption></figure><h4>Section 4.2: Apply RAG Using the Vector DB</h4><p>Once the vector database is created, the Q&amp;A model with RAG will function as shown in Image 7. The key difference here is that the incoming query performs a similarity search on the vector database, returning <strong>k</strong> similar vectors. The value of <strong>k</strong> can be adjusted based on your use case. A larger <strong>k</strong> might provide more reliable results (depending on your dataset), while a smaller <strong>k</strong> could reduce token costs. These <strong>k</strong> similar vectors will then represent the document for that specific query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QmGePhZYuDNzw4KcbcMRPQ.png" /><figcaption>Image 7: Q/A Workflow with RAG</figcaption></figure><p>The background is that simple. Search engines and the other retrieval related tasks restricts and gets that relative data from database so the system could be small enough to work on live. This theoretical part is done. Let’s see how to create this workflow on Langflow in the next section.</p><h3>Section 5: RAG on Langflow</h3><p>We will start from the template, Vector Store RAG of Langflow. You will see 2 different flows in Image 8, as we shown the idea in section 4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ChYFX5JvMJI2C8iWMsfJ-Q.png" /><figcaption>Section 8: RAG Template of Langflow</figcaption></figure><p>We’ll begin by creating the vector database in the next section. Here, we’ll replace the <strong>Astra DB</strong> module with <strong>Chroma DB</strong> from the modules section in the left menu. Chroma DB is simpler to work with since it operates in-memory and doesn’t require any external APIs. After establishing the necessary connections, we’ll run the Chroma DB module to create the vector stores.</p><p>In the main flow, we’ll also need to replace <strong>Astra DB</strong> with <strong>Chroma DB</strong>. As mentioned in the previous section, note that the <strong>Chat Input</strong> now connects to the <strong>Search Input</strong>. You can specify the number of vectors returned to the prompt in the Chroma DB settings, with the default value set to 10.</p><p>Finally, let’s update the prompt. For this example, I’ve chosen a fun task: scenario writing using RAG. I asked ChatGPT to generate an appropriate prompt for this task, and I’ve set it up as follows:</p><pre>{context}<br><br>---<br>The scenario is given above.<br>When asked a question about a scenario, respond with a detailed answer and try to generate alternative versions of the scenario. While answering:<br><br>Expand and develop the given scenario. How might events unfold in this version?<br>1- Provide two or more alternative scenarios that could arise. In these alternatives, different character actions or event outcomes might occur.<br>2- Explain the strengths and weaknesses of each alternative, and suggest which one might be more likely or interesting.<br>3- Present various perspectives on how the scenario could evolve in different ways.<br><br>Always respond in Turkish!<br><br>Question: {question}<br><br>Answer: </pre><p>Next, I added the <strong>Interstellar</strong> scenario to the <strong>File</strong> component, and now the flow is ready to run! I asked a question about the scenario (as shown in Image 9), and the model provided an answer along with some alternative responses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Hh4wCe0NRgqvH5ig7L0OA.png" /><figcaption>Image 9: RAG — Playground</figcaption></figure><h3>All in All</h3><p>In this blog post, we demonstrated how to create a simple Q/A bot using LangFlow, while also explaining how a language model works. Later, we introduced the RAG (Retrieval-Augmented Generation) method, which is used when working with larger documents, and showed how to implement it using LangFlow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dead90093f2d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/turknettech/create-your-own-q-a-bot-with-langflow-dead90093f2d">Create Your Own Q/A Bot with Langflow</a> was originally published in <a href="https://medium.com/turknettech">Turknet Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>