Skip to content

Commit

Permalink
syntax fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alanzchen committed Apr 16, 2023
1 parent 44172a2 commit fcdfc88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"name": "sidenote",
"title": "SideNote Integration",
"description": "Enable SideNote integration (requires SideNote). Allows you to send the results to SideNote as a new note.",
"label": "Enabled",
"type": "checkbox",
"default": false,
"required": false
Expand Down
17 changes: 9 additions & 8 deletions src/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ResultView(prompt: string, toast_title: string) {
model: model_override,
messages: [
{ role: "system", content: prompt },
{ role: "user", content: selectedText }
{ role: "user", content: selectedText },
],
stream: true,
},
Expand Down Expand Up @@ -97,7 +97,6 @@ export default function ResultView(prompt: string, toast_title: string) {
setCumulativeTokens(cumulative_tokens + prompt_token_count + response_token_count);
setCumulativeCost(cumulative_cost + estimatePrice(prompt_token_count, response_token_count, model_override));
}

}, [loading]);

let sidenote = undefined;
Expand All @@ -123,8 +122,13 @@ export default function ResultView(prompt: string, toast_title: string) {
<Action.CopyToClipboard title="Copy Results" content={response} />
<Action.Paste title="Paste Results" content={response} />
<Action title="Retry" onAction={retry} shortcut={{ modifiers: ["cmd"], key: "r" }} icon={Icon.Repeat} />
{(
model_override != "gpt-4" && <Action title="Retry with GPT-4" onAction={retryWithGPT4} shortcut={{ modifiers: ["cmd", "shift"], key: "r" }} icon={Icon.ArrowNe} />
{model_override != "gpt-4" && (
<Action
title="Retry with GPT-4"
onAction={retryWithGPT4}
shortcut={{ modifiers: ["cmd", "shift"], key: "r" }}
icon={Icon.ArrowNe}
/>
)}
{sidenote}
</ActionPanel>
Expand All @@ -142,10 +146,7 @@ export default function ResultView(prompt: string, toast_title: string) {
/>
<Detail.Metadata.Separator />
<Detail.Metadata.Label title="Culmulative Tokens" text={cumulative_tokens.toString()} />
<Detail.Metadata.Label
title="Culmulative Cost"
text={cumulative_cost.toString() + " cents"}
/>
<Detail.Metadata.Label title="Culmulative Cost" text={cumulative_cost.toString() + " cents"} />
</Detail.Metadata>
}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function countToken(content: string) {
export function estimatePrice(prompt_token: number, output_token: number, model: string) {
// price is per 1K tokens, but we are measuing in cents. Hence the denominator is 10
if (model == "gpt-3.5-turbo") {
return naiveRound((prompt_token + output_token) * 0.002 / 10, 2);
return naiveRound(((prompt_token + output_token) * 0.002) / 10, 2);
} else if (model == "gpt-4") {
return naiveRound((prompt_token * 0.03 + output_token * 0.06) / 10, 2);
} else {
Expand Down

0 comments on commit fcdfc88

Please sign in to comment.