feat(blocks, ai): add prompt and completion tokens to the save dropdown#2070
feat(blocks, ai): add prompt and completion tokens to the save dropdown#2070baptisteArno merged 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request extends token usage tracking across several modules. Updates include adding "Prompt tokens" and "Completion tokens" to predefined response values, mapping arrays, and conditional logic in chat completion functions. Additionally, legacy OpenAI integrations have been modified to construct and pass a structured tokens object (with total, prompt, and completion tokens) instead of a single numeric value. These changes provide a more granular capture and processing of token metrics. Changes
Sequence Diagram(s)sequenceDiagram
participant RC as runChatCompletion
participant Usage as Usage Object
participant Var as Variable Store
RC->>Usage: Retrieve usage metrics (total, prompt, completion)
loop Process each mapping
Usage-->>RC: Provide specific token metric
alt Mapping is "Prompt tokens"
RC->>Var: Assign usage.promptTokens
else Mapping is "Completion tokens"
RC->>Var: Assign usage.completionTokens
else
RC->>Var: Assign other token values (e.g., total tokens)
end
end
sequenceDiagram
participant Client as createChatCompletionOpenAI
participant ChatAPI as ChatCompletion Service
participant Resume as resumeChatCompletion
Client->>ChatAPI: Request chat completion (retrieve usage data)
ChatAPI-->>Client: Return usage metrics (total, prompt, completion)
Client->>Resume: Pass tokens object (with all token values)
Resume->>Resume: Process tokens using ResumeChatCompletionTokens interface
Resume-->>Client: Return processed chat completion result
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📥 CommitsReviewing files that changed from the base of the PR and between 214410c35989ce25954dcbcde5127094a905bde3 and edc2499. 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
214410c to
2bf543a
Compare
2bf543a to
edc2499
Compare
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🛑 Comments failed to post (1)
.husky/pre-commit (1)
4-4: 🛠️ Refactor suggestion
Remove hardcoded user path to improve portability
The pre-commit hook contains a hardcoded path to the bun executable that is specific to your local machine (
/Users/Alexis/.bun/bin/bun). This will break for other developers who clone the repository since they will have different user paths.Replace the absolute path with just the command name to rely on the system's PATH:
- /Users/Alexis/.bun/bin/bun pre-commit + bun pre-commit📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.bun pre-commit
|
Congrats and thank you, first PR merged 🔥 |
This adds Prompt tokens and Completion tokens options to the save dropdown for AI blocks, based on the available token counts of the CompletionUsage response.