> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jinba.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Jinba Knowledge Base

> Update and manage Jinba knowledge bases for enhanced AI workflows

## Overview

The Jinba Knowledge Base tools allow you to add files to and update files in knowledge bases within the Jinba ecosystem. These tools enable you to maintain up-to-date information repositories that can be accessed by other tools and workflows (such as vector search) for enhanced AI-powered operations.

## Key Features

* `JINBA_KNOWLEDGE_BASE_FILE_ADD`: Add a file to a knowledge base, with configurable chunking
* `JINBA_KNOWLEDGE_BASE_UPDATE`: Update an existing file in a knowledge base with new content
* Integration with vector search capabilities
* Synchronous or asynchronous execution (wait for chunking or return immediately)

## Authentication

These tools authenticate with a workspace secret key via the `token` config, which defaults to `{{ secrets.JINBAFLOW_WS_API_KEY }}` — you usually do not need to set it explicitly.

## Tools

### JINBA\_KNOWLEDGE\_BASE\_FILE\_ADD

Add a file to a knowledge base.

**Input**:

| Parameter         | Type          | Required | Description                                                                                                                              |
| ----------------- | ------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `knowledgeBaseId` | string        | Yes      | Target knowledge base                                                                                                                    |
| `file`            | string        | Yes      | Base64 encoded file content or file URL starting with `https://` or `data:`                                                              |
| `filename`        | string        | Yes      | Name of the file (extension will be auto-detected from the file)                                                                         |
| `metadata`        | string (JSON) | No       | Optional metadata to attach to the file                                                                                                  |
| `chunkerSettings` | object        | No       | Chunking settings: `chunkSize` (1-8192, default: 512), `chunkOverlap` (0-2048, default: 128), `chunkingIdentifier` (default: `"\\n\\n"`) |
| `executionMode`   | string        | No       | `SYNCHRONOUS` to wait for chunking or `ASYNCHRONOUS` to return immediately (default: `ASYNCHRONOUS`)                                     |

**Output**:

| Field             | Type   | Description                                                          |
| ----------------- | ------ | -------------------------------------------------------------------- |
| `knowledgeBaseId` | string | ID of the knowledge base                                             |
| `fileId`          | string | ID of the added file                                                 |
| `filename`        | string | Name of the added file                                               |
| `status`          | string | Processing status: `pending`, `processing`, `completed`, or `failed` |
| `contentType`     | string | Content type of the file                                             |
| `size`            | string | File size                                                            |
| `chunkCount`      | number | Number of chunks created                                             |
| `createdAt`       | string | Creation timestamp                                                   |

### JINBA\_KNOWLEDGE\_BASE\_UPDATE

Update an existing file in a knowledge base with new content.

**Input**:

| Parameter             | Type   | Required | Description                                                                                         |
| --------------------- | ------ | -------- | --------------------------------------------------------------------------------------------------- |
| `knowledgeBaseId`     | string | Yes      | Target knowledge base                                                                               |
| `knowledgeBaseFileId` | string | Yes      | Existing knowledge base file ID to update                                                           |
| `fileUrl`             | string | Yes      | URL of the file content to update with                                                              |
| `updateType`          | string | No       | Update strategy; `FULL_REFRESH` replaces the file in the knowledge base (default: `FULL_REFRESH`)   |
| `executionMode`       | string | No       | `SYNCHRONOUS` to wait for chunking or `ASYNCHRONOUS` to return immediately (default: `SYNCHRONOUS`) |

**Output**:

| Field             | Type   | Description                                                          |
| ----------------- | ------ | -------------------------------------------------------------------- |
| `knowledgeBaseId` | string | ID of the knowledge base                                             |
| `fileId`          | string | ID of the updated file                                               |
| `filename`        | string | Name of the updated file                                             |
| `status`          | string | Processing status: `pending`, `processing`, `completed`, or `failed` |
| `chunkCount`      | number | Number of chunks created                                             |

## Examples

### Example: Add a File to a Knowledge Base

```yaml theme={null}
- id: add_file_to_kb
  tool: JINBA_KNOWLEDGE_BASE_FILE_ADD
  input:
    - name: knowledgeBaseId
      value: "{{secrets.KNOWLEDGE_BASE_ID}}"
    - name: file
      value: "https://example.com/product-manual.pdf"
    - name: filename
      value: "product-manual.pdf"
    - name: executionMode
      value: "SYNCHRONOUS"
    - name: chunkerSettings
      value:
        chunkSize: 512
        chunkOverlap: 128
        chunkingIdentifier: "\\n\\n"
```

### Example: Update an Existing Knowledge Base File

```yaml theme={null}
- id: update_kb_file
  tool: JINBA_KNOWLEDGE_BASE_UPDATE
  input:
    - name: knowledgeBaseId
      value: "{{secrets.KNOWLEDGE_BASE_ID}}"
    - name: knowledgeBaseFileId
      value: "{{secrets.FILE_ID}}"
    - name: fileUrl
      value: "https://example.com/updated-product-manual.pdf"
    - name: updateType
      value: "FULL_REFRESH"
    - name: executionMode
      value: "SYNCHRONOUS"
```

### Example: Generate a Report and Store It in a Knowledge Base

```yaml theme={null}
- id: create_report
  tool: OUTPUT_FILE
  input:
    - name: content
      value: |
        # Weekly Support Summary
        {{steps.summarize_tickets.result.content}}
    - name: filename
      value: "support_summary_{{date | format('YYYY-MM-DD')}}.md"
    - name: fileType
      value: "md"

- id: add_report_to_kb
  tool: JINBA_KNOWLEDGE_BASE_FILE_ADD
  input:
    - name: knowledgeBaseId
      value: "{{secrets.KNOWLEDGE_BASE_ID}}"
    - name: file
      value: "{{steps.create_report.result.url}}"
    - name: filename
      value: "support_summary_{{date | format('YYYY-MM-DD')}}.md"
    - name: executionMode
      value: "ASYNCHRONOUS"
```

## Use Cases

* Maintaining product documentation and changelogs
* Building comprehensive troubleshooting guides
* Creating workflow documentation repositories
* Storing best practices and guidelines
* Building FAQ and support knowledge bases
* Keeping RAG search sources up to date automatically

## Best Practices

* Use descriptive filenames so files are easy to identify later
* Tune `chunkerSettings` for your content: smaller chunks (256-512) for precise retrieval, larger chunks (1024-2048) for maintaining context
* Use `SYNCHRONOUS` execution when downstream steps depend on the file being searchable
* Use `ASYNCHRONOUS` execution for large files to avoid blocking the flow
* Check the `status` output (`pending` / `processing` / `completed` / `failed`) before relying on the file in searches
* Update existing files with `JINBA_KNOWLEDGE_BASE_UPDATE` instead of adding duplicates
