Skip to content

Commit

Permalink
enforce conditional and user login check
Browse files Browse the repository at this point in the history
  • Loading branch information
eg9y committed May 29, 2023
1 parent 356db5c commit c8cca72
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/web/src/components/ApiKeySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default function ApiKeySettings({
`}
</p>
<div className="mt-4">
<Switch.Group as="div" className="flex items-center">
<Switch.Group as="div" className="flex items-center gap-2">
<Switch
checked={isEditWithMyKey === true}
onChange={async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/components/RunFromStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function RunFromStart({
}

async function runFromStart() {
if (getSecret().openAiKey.trim() === '') {
if (!getSecret().session && getSecret().openAiKey.trim() === '') {
setNotificationMessage('Please enter an OpenAI API key in the left panel.');
return;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/web/src/utils/runFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ export async function runFlow(
state.chatHistory = [...get().chatApp];
}

if (session?.user.user_metadata.edit_with_api_key && isNodeDoOpenAICall(node)) {
if (
session?.user.user_metadata.edit_with_api_key === false &&
isNodeDoOpenAICall(node)
) {
const creditsUsed = calculateCreditsRequired(
node.data,
node.data.text + node.data.response,
Expand Down

1 comment on commit c8cca72

@vercel
Copy link

@vercel vercel bot commented on c8cca72 May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.