https://discord.gg/botpress logo
Knowledge base documents always in upload_pending ...
# 🤝help
m
I have uploaded some txt files to knowledge base through file api (please find the curl command below).
Copy code
bash
 curl --location --request PUT 'https://api.botpress.cloud/v1/files' \
 --header 'Content-Type: application/json' \
 --header 'Authorization: bearer PAT' \
 --header 'x-bot-id: BOT_ID' \
 --data '{
     "index": true,
     "indexing": {
         "configuration": {
             "summarization": {
                 "modelType": "balanced"
             }
         }
     },
     "key": "kb-332b00b26e/1022533.txt",
     "size": 123,
     "content": "// content goes here"
 }'
When I checked the status of the documents uploaded it shows empty in studio and in dashboard it shows uploading (attached few screenshots) Let me know If i'm making mistake. Plan details: Plus plan Add ons on extra collaborator. https://cdn.discordapp.com/attachments/1368833813186351164/1368833813555187774/screenshot_2025-05-05_at_11.40.21.png?ex=6819a954&is=681857d4&hm=3deda2a33f97587dab50887fc1259deee1c3ed9ed73ffc389c69921c59074056& https://cdn.discordapp.com/attachments/1368833813186351164/1368833814163488818/screenshot_2025-05-05_at_11.39.142.png?ex=6819a954&is=681857d4&hm=d0e663bd36b110b11af1b541a1d972492994c1390333f2f74b7eed25e02e5d52&
p
I would try adding tags to your request, as such: --data '{ "key": "kb-feb7308af6/newfile.pdf", "url": "https://example.com/path/to/file.pdf", "contentType": "application/pdf", "index": true, "tags": { "knowledgeBaseName": "KB1", "source": "knowledge-base", "kbId": "kb-feb7308af6", "title": "My File" } }' This is from one of my own bots in which a user file was uploaded to the kb. If it still doesn't work, maybe use a POST request instead of PUT.
m
Okay let me try this
Works Thanks 🙂
p
Awesome, happy to help!
m
@prehistoric-airplane-85682 Seems like files are uploaded and shown in knowledge base section in studio, but files are in
uploading_pending
status forever, doesn't change to indexed status. is there any issue with file api??
p
When trying it on my bot that uploads files to the kb programmatically, I am not encountering the same issue. Could you send me pictures and your current code to further investigate?
m
@prehistoric-airplane-85682 please find the code here, I use python
Copy code
def upload_file(file_path, api_key, bot_id, kbId, kbName):
    """Upload a single file to Botpress Cloud Files API"""
    url = "https://api.botpress.cloud/v1/files"
    filename = os.path.basename(file_path)
    try:
        with open(file_path, "r", encoding="utf-8") as f:
            content = f.read()
        size = len(content.encode("utf-8"))

        payload = {
            "index": True,
            "indexing": {"configuration": {"summarization": {"modelType": "balanced"}}},
            "key": f"{kbId}/{filename}",
            "size": size,
            "content": content,
            "tags": {
                "knowledgeBaseName": kbName,
                "source": "knowledge-base",
                "kbId": kbId,
                "title": filename,
            },
            "contentType": "text/plain",
        }

        headers = {
            "Content-Type": "application/json",
            "Authorization": f"bearer {api_key}",
            "x-bot-id": bot_id,
        }

        response = requests.put(url, headers=headers, data=json.dumps(payload))
        print(f"Uploaded {filename}: {response.status_code}")
        return response.status_code == 200
    except Exception as e:
        print(f"Error uploading {filename}: {str(e)}")
        return False
p
I'm not noticing any flagrant issues. If you attempt to query the knowledge base, does it work as expected?
m
Nope, nothing returns from knowledge base while querying
c
Hey @prehistoric-airplane-85682 , I am from @microscopic-stone-6467 's team. Sharing the screenshot to provide additional reference for the issue we are facing. Plz let us know what can be done to resolve this. https://cdn.discordapp.com/attachments/1368833813186351164/1371391802787237938/Screenshot_2025-05-12_at_1.06.48_PM.png?ex=6822f7a5&is=6821a625&hm=6a40d6918943b3f0de83d84883415e739dcb749202194ae88b874a5c3621d60a&
p
Did you upload all the documents at once? Have you considered trying in smaller batches (e.g. 1 to try it out first)? If there's 88 pages of 10 ish files, it might be too large of a load.
m
I used file API and uploaded one by one.
Hey @prehistoric-airplane-85682 , Let me summarise the options we tried: 1. Initially uploaded 1000 txt files directly in knowledge base studio section - it indexed successfully after some time (may be an hour) 2. To automate this, I used file api to upload and index the remaining documents. Those were never indexed and I waited two days, then found still it hasn't been indexed. That's when I started to post it in help channel and created the thread. 3. Tried 5 txts and waited for sometime all had been indexed - through manual uploading 4. Tried same 5 txt files and waited for sometime still remains same with upload_pending status - through file api We have around 25K documents, all are txt files. We are a Plus plan customer. screenshots for references: https://cdn.discordapp.com/attachments/1368833813186351164/1371768524808388638/Screenshot_2025-05-13_at_14.01.17.png?ex=6824567e&is=682304fe&hm=7e4e00ae69786f747fba73ca966cf187b4fc5f904801f6a29bd00838d086278d& https://cdn.discordapp.com/attachments/1368833813186351164/1371768525131223041/Screenshot_2025-05-13_at_13.11.20.png?ex=6824567e&is=682304fe&hm=fa2e0b77c3d685a9acd9e31e20bab083fd31a77d3091d12adb9d9a458e3a6e4a& https://cdn.discordapp.com/attachments/1368833813186351164/1371768525433081876/Screenshot_2025-05-13_at_13.21.10.png?ex=6824567e&is=682304fe&hm=1a460bf659a384408bbddbe2ad382e8fda15e06ccd765f48fdf664581caeb451&
latest code used to upload files:
Copy code
def upload_file(file_path, api_key, bot_id, kbId, kbName):
    """Upload a single file to Botpress Cloud Files API"""
    url = "https://api.botpress.cloud/v1/files"
    filename = os.path.basename(file_path)
    try:
        with open(file_path, "r", encoding="utf-8") as f:
            content = f.read()
        size_in_bytes = int(len(content.encode("utf-8")))

        payload = {
            "index": True,
            "indexing": {
                "configuration": {
                    # "summarization": {"modelType": "balanced"},
                    "vision": {"indexPages": True, "transcribePages": True},
                }
            },
            "key": f"{kbId}/{filename}",
            "size": size_in_bytes,
            "content": content,
            "tags": {
                "knowledgeBaseName": kbName,
                "source": "knowledge-base",
                "kbId": kbId,
                "title": filename,
                "modalities": '["text","image"]',
            },
            "contentType": "text/plain; charset=utf-8",
        }

        headers = {
            "Content-Type": "application/json",
            "Authorization": f"bearer {api_key}",
            "x-bot-id": bot_id,
        }

        response = requests.put(url, headers=headers, data=json.dumps(payload))
        print(f"Uploaded {filename}: {response.status_code}")
        return response.status_code == 200
    except Exception as e:
        print(f"Error uploading {filename}: {str(e)}")
        return False
@red-rocket-93714 tagging you here
3 Views