Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Remove api key
Browse files Browse the repository at this point in the history
  • Loading branch information
jermainee committed Mar 11, 2024
1 parent 63833ab commit 8c221f6
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/Writer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import strip from 'strip-markdown'
interface IAppState {
keyword: string|null;
language: string|null;
apiKey: string;
isSubmitted: boolean;
markdownText: string;
plainText: string;
Expand All @@ -23,7 +22,6 @@ export default class Writer extends Component<{}, IAppState> {
this.state = {
keyword: null,
language: 'en',
apiKey: localStorage.getItem("api_key") ?? '',
isSubmitted: false,
markdownText: '',
plainText: '',
Expand Down Expand Up @@ -85,14 +83,6 @@ export default class Writer extends Component<{}, IAppState> {
</div>
</div>

<div className="field">
<label className="label">API key</label>
<div className="control">
<input onChange={this.handleApiKeyChange} className="input" type="password" value={this.state.apiKey} placeholder="Enter your OpenAI API key" required={true}/>
</div>
<div className="is-size-7">The API key will only be stored locally in your browser. <a href="https://platform.openai.com/account/api-keys" target="_blank noreferrer">You find your API key in the OpenAI dashboard.</a></div>
</div>

<div className="field">
<div className="control">
<button type="submit" className="button is-light has-text-weight-bold is-fullwidth">Create draft</button>
Expand Down Expand Up @@ -155,7 +145,7 @@ export default class Writer extends Component<{}, IAppState> {
}

private fetchWriterResponse = () => {
fetch(`${this.apiUrl}/generate/${this.state.keyword}?openai_key=${this.state.apiKey}&language=${this.state.language}`, { keepalive: true })
fetch(`${this.apiUrl}/generate/${this.state.keyword}?language=${this.state.language}`, { keepalive: true })
.then(async (response) => {
// response.body is a ReadableStream
// @ts-ignore
Expand Down Expand Up @@ -188,11 +178,6 @@ export default class Writer extends Component<{}, IAppState> {
this.setState({ language: event.target.value });
}

private handleApiKeyChange = (event: React.ChangeEvent<HTMLInputElement>) => {
localStorage.setItem("api_key", event.target.value);
this.setState({ apiKey: event.target.value });
}

private handleFormSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
this.setState({ isSubmitted: true });
Expand Down

0 comments on commit 8c221f6

Please sign in to comment.