Repository navigation
Bot ingest: R2 + KB pipeline for uploads, live-step streaming endpoint - #9
Merged
Merged
Conversation
- /api/bots/ingest: a linked user's PDFs are fetched once, replied to
synchronously as JSON, and pushed in the background through queueKbIngest
(chunk -> embeddings -> Pinecone memories) + queueExtraction (PDF -> JSON ->
draft invoice), each writing its own D1 rows. Response gains { kb: { queued } }.
- /api/bots/ingest/stream: SSE 'step' events as the finance agent calls tools,
then a 'done' event with the answer, so bots can show progress instead of a
spinner. Writes a bot_events audit row.
- rename 0014_bot_link_compat.sql -> 0016 (0014 collided with 0014_org_currency)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
/api/bots/ingestnow runs the full document pipeline. When a linked user sends a PDF, the bytes are fetched once, replied to synchronously as structured JSON (as before), and in the background pushed through:queueKbIngest→ R2 → chunk → embeddings → Pinecone (memory graph) →kb_documentsD1 rowsqueueExtraction→ R2 → PDF→JSON → auto draft invoice →doc_extractsD1 rowsResponse gains
{ kb: { queued: [...] } }so the bot can say "added to your knowledge base".POST /api/bots/ingest/stream— SSE. Emitsstepevents as the finance agent calls tools, thendonewith the answer. Lets bots show progress instead of a spinner. Writes abot_eventsaudit row. Falls back to the Workers-AI one-shot for unlinked users.Migration renumber —
0014_bot_link_compat.sql→0016(collided with0014_org_currency.sql).To deploy
Note
maincurrently failsnpm run buildon pre-existing missing deps (@tabler/icons-react,liveline,glimm) — unrelated to this PR, but blocks deploy until fixed.Paired with discord.grayoffice PR (live-streaming-ask).
🤖 Generated with Claude Code