Skip to content

Commit

Permalink
Add openai key instead of pro for people who want to get around limits
Browse files Browse the repository at this point in the history
  • Loading branch information
truell20 committed Mar 28, 2023
1 parent 16b1723 commit 9e04a00
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 13 deletions.
12 changes: 2 additions & 10 deletions src/appComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,8 @@ function NoAuthRateLimitPopup() {
</div>
</div>
<div className="errorPopup__body">
We're getting more traffic than our servers can handle right
now. To avoid these limits and to purchase reserved
capacity, you can upgrade to{' '}
<a
className="pay-link"
onClick={() => dispatch(ts.upgradeCursor(null))}
>
Cursor Pro
</a>{' '}
for $20/month.
We're getting more traffic than we can handle right
now. To avoid these limits, you can enter your OpenAI API key in Settings.
</div>
</div>
</Modal>
Expand Down
4 changes: 2 additions & 2 deletions src/components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ export function MarkdownPopup({
</ReactMarkdown>
</div>
<div className={'apply-button-holder'}>
{last && (
{/* {last && (
<button
className="apply-button"
onClick={onApply}
>
Attempt Change
</button>
)}
)} */}
</div>
</div>
)}
Expand Down
28 changes: 27 additions & 1 deletion src/components/settingsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,29 @@ export function SettingsPopup() {
value={settings.tabSize}
/>
</div>
<CursorLogin />

<div className="settings__item">
<div className="settings__item_title">
OpenAI API Key
</div>
<div className="settings__item_description">
We'll use your key for any requests to OpenAI. This will help you avoid "maximum capacity" limits.
</div>
<input
className="settings__item_textarea"
placeholder="Enter your OpenAI API Key"
type="password"
onChange={(e) => {
dispatch(
changeSettings({
openAIKey: e.target.value,
})
)
}}
value={settings.openAIKey || ""}
/>
</div>

<CopilotPanel />
{/* REMOVED CODEBASE-WIDE FEATURES!
<RemoteCodebaseSettingsPanel />*/}
Expand All @@ -171,6 +193,7 @@ export function SettingsPopup() {
languageName={name}
/>
))}
<CursorLogin />
</div>
</div>
<div className="cover-bar"></div>
Expand Down Expand Up @@ -224,6 +247,9 @@ function CursorLogin() {
return (
<div className="settings__item">
<div className="settings__item_title">Cursor Pro</div>
<div className="settings__item_description">
If you'd like to pay for unlimited requests, instead of using your OpenAI API key.
</div>
{currentPanel}
</div>
)
Expand Down
5 changes: 5 additions & 0 deletions src/features/chat/chatThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ export async function getPayload({
// hack
dispatch(updateLastUserMessageMsgType(null))

let oaiKey : string | undefined | null = state.settingsState.settings.openAIKey;
if (oaiKey == null || oaiKey === '') {
oaiKey = null;
}
const userRequest = {
// Core request
message: lastUserMessage.message,
Expand All @@ -291,6 +295,7 @@ export async function getPayload({
customCodeBlocks,
codeBlockIdentifiers,
msgType: chatState.msgType,
apiKey: oaiKey,
// Messy, but needed for the single lsp stuff to work
maxOrigLine: forContinue
? getLastBotMessage(chatState, conversationId)!.maxOrigLine
Expand Down
1 change: 1 addition & 0 deletions src/features/window/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ export interface Settings {
useFour: string
contextType: string
textWrapping: string
openAIKey?: string
tabSize?: string
}

Expand Down
14 changes: 14 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2481,3 +2481,17 @@ free servers .disabled_command .shortcut__block {
cursor: pointer;
text-decoration: underline;
}

.settings__item_textarea {
width: 100%;
height: 100%;
resize: none;
border: none;
background-color: #333;
color: #fff;
font-size: 14px;
margin-top: 8px;
padding: 8px;
box-sizing: border-box;
border-radius: 2px;
}

0 comments on commit 9e04a00

Please sign in to comment.