fix(inference-billing): fix inference billing when stream is true via API, add drag-and-drop functionality to deployed chat#1606
Merged
waleedlatif1 merged 2 commits intostagingfrom Oct 12, 2025
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
Fixed inference billing when stream=true by deferring logging completion until after tokenization, and added drag-and-drop file upload to deployed chat interface.
Key Changes:
- Billing Fix: Deferred
loggingSession.safeComplete()call in streaming execution flow to ensure cost/token data fromprocessStreamingBlockLogs()is included in trace spans before logging - Drag-and-Drop: Added drag event handlers (
onDragEnter,onDragOver,onDragLeave,onDrop) to chat input with visual feedback viadragCounterstate and conditional styling - Added
skipLoggingCompleteparameter toexecuteWorkflow()options and_streamingMetadatafield toExecutionResultfor passing logging session through streaming pipeline
The billing fix addresses a timing issue where streaming executions logged incomplete cost data because tokenization happened after logging completion.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- Both features are well-implemented with clear separation of concerns. The billing fix properly defers logging until after tokenization without affecting non-streaming flows. The drag-and-drop implementation uses standard browser APIs with proper event handling and guards against streaming state. No breaking changes or security issues detected.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/workflows/streaming.ts | 5/5 | Added deferred logging completion after tokenization to ensure cost data is calculated before logging |
| apps/sim/app/api/workflows/[id]/execute/route.ts | 5/5 | Added skipLoggingComplete parameter and streaming metadata to defer logging completion until after tokenization |
| apps/sim/executor/types.ts | 5/5 | Added _streamingMetadata to ExecutionResult for passing logging session data to streaming handler |
| apps/sim/app/chat/components/input/input.tsx | 5/5 | Implemented drag-and-drop file upload with visual feedback using drag counter and event handlers |
Sequence Diagram
sequenceDiagram
participant Client
participant API as /api/workflows/[id]/execute
participant Execute as executeWorkflow()
participant Streaming as createStreamingResponse()
participant Tokenize as processStreamingBlockLogs()
participant TraceSpans as buildTraceSpans()
participant LogSession as loggingSession
Client->>API: POST with stream=true
API->>Streaming: createStreamingResponse()
Streaming->>Execute: executeWorkflow(skipLoggingComplete: true)
Execute->>Execute: Run workflow execution
Execute->>Execute: Build initial trace spans
Note over Execute,LogSession: Skip logging completion (skipLoggingComplete=true)
Execute->>Execute: Attach _streamingMetadata (loggingSession, processedInput)
Execute-->>Streaming: Return result with _streamingMetadata
Streaming->>Streaming: Update result.logs with streamed content
Streaming->>Tokenize: processStreamingBlockLogs(logs, streamedContent)
Tokenize->>Tokenize: Calculate tokens & cost for streamed content
Tokenize-->>Streaming: Updated logs with cost data
Streaming->>TraceSpans: buildTraceSpans(result)
TraceSpans-->>Streaming: traceSpans with cost data
Streaming->>LogSession: safeComplete(traceSpans, finalOutput)
Note over LogSession: Now includes accurate billing/cost data
LogSession-->>Streaming: Logging complete
Streaming->>Streaming: Clear _streamingMetadata
Streaming-->>Client: Stream response with accurate billing
4 files reviewed, no comments
waleedlatif1
added a commit
that referenced
this pull request
Oct 12, 2025
… API, add drag-and-drop functionality to deployed chat (#1606) * fix(inference): fix inference billing when stream is true via API * add drag-and-drop to deployed chat
waleedlatif1
added a commit
that referenced
this pull request
Oct 12, 2025
… API, add drag-and-drop functionality to deployed chat (#1606) * fix(inference): fix inference billing when stream is true via API * add drag-and-drop to deployed chat
waleedlatif1
added a commit
that referenced
this pull request
Oct 12, 2025
* improvement(performance): remove unused source/target indices, add index on snapshot id (#1603) * fix(blog): rename building to blogs with redirect (#1604) * improvement(privacy-policy): updated privacy policy for google (#1602) * updated privacy policy for google * update terms, privacy, and emails to incl address and update verbiage * feat(guardrails): added guardrails block/tools and docs (#1605) * Adding guardrails block * ack PR comments * cleanup checkbox in dark mode * cleanup * fix supabase tools * fix(inference-billing): fix inference billing when stream is true via API, add drag-and-drop functionality to deployed chat (#1606) * fix(inference): fix inference billing when stream is true via API * add drag-and-drop to deployed chat * feat(mistal): added mistral as a provider, updated model prices (#1607) * feat(mistal): added mistral as a provider, updated model prices * remove the ability for a block to reference its own outluts * fixed order of responses for guardrails block * feat(versions): added the ability to rename deployment versions (#1610) * fix(vulns): fix various vulnerabilities and enhanced code security (#1611) * fix(vulns): fix SSRF vulnerabilities * cleanup * cleanup * regen docs * remove unused deps * fix failing tests * cleanup * update deps * regen bun lock
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.
Summary
fix inference billing when stream is true via API, add drag-and-drop functionality to deployed chat
Type of Change
Testing
Tested manually.
Checklist