-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Adds horizontal line separators for sections. This makes it simpler to scan. 2. Adds Insights tab for stats. 3. Adds test case creation command copy.
- Loading branch information
Showing
3 changed files
with
117 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Step } from '../../../api'; | ||
|
||
export const InsightsView = (props: { steps: Step[] }) => { | ||
// Initialize a variable to hold the total sum | ||
let totalPromptTokens = 0; | ||
let totalCompletionTokens = 0; | ||
const openaiPromptTokenCost = 500 / 1_000_000; | ||
const openaiCompletionTokenCost = 1500 / 1_000_000; | ||
let totalLLMCalls = 0; | ||
|
||
// Iterate over each step | ||
props.steps.forEach((step) => { | ||
let hasPromptCall = false; | ||
// Iterate over each attribute in the step | ||
step.attributes.forEach((attribute) => { | ||
// Check if the attribute name ends with '_tokens' | ||
if (attribute.key.endsWith('prompt_tokens')) { | ||
hasPromptCall = true; | ||
// Add the attribute value to the total sum | ||
totalPromptTokens += attribute.value as number; | ||
} else if (attribute.key.endsWith('completion_tokens')) { | ||
totalCompletionTokens += attribute.value as number; | ||
} | ||
}); | ||
if (hasPromptCall) { | ||
totalLLMCalls += 1; | ||
} | ||
}); | ||
|
||
const totalCost = | ||
(totalPromptTokens * openaiPromptTokenCost + | ||
totalCompletionTokens * openaiCompletionTokenCost) / | ||
100.0; | ||
|
||
if (totalLLMCalls > 0) { | ||
// Display the total sum | ||
return ( | ||
<div> | ||
<h2>Total Prompt Tokens: {totalPromptTokens}</h2> | ||
<h2>Total Completion Tokens: {totalCompletionTokens}</h2> | ||
<h2>Total Cost: ${totalCost}</h2> | ||
<h2>Total LLM Calls: {totalLLMCalls}</h2> | ||
</div> | ||
); | ||
} else { | ||
return ( | ||
<div> | ||
<h2>No LLM calls found.</h2> | ||
</div> | ||
); | ||
} | ||
}; |
This file contains 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