class App{ constructor() { this.apiKey = null; this.model = null; this.inputs = { text: "", apiKeyInput: "", modelInput: "" }; this.states = { input: 0, apiKey: 1, model: 2 }; this.state = this.states.input; } handleKeyPress = (e) => { if (e.keyCode === 13) { if (this.state === this.states.input) { this.setState(this.states.apiKey); } else if (this.state === this.states.apiKey) { this.setState(this.states.model); } else if (this.state === this.states.model) { this.setState(this.states.input); } } } handleInputChange = (e) => { const inputValue = e.target.value; if (this.state === this.states.input) { this.inputs.text = inputValue; } else if (this.state === this.states.apiKey) { this.inputs.apiKeyInput = inputValue; } else if (this.state === this.states.model) { this.inputs.modelInput = inputValue; } } setState = (newState) => { console.log("setState", newState); if (newState === this.states.input) { this.inputs.apiKey = this.inputs.apiKeyInput; this.inputs.model = this.inputs.modelInput; } this.state = newState; } render() { return (

ChatGPT

ChatGPT is a simple chat interface that uses the OpenAI API to generate responses based on the user's input. You can use this app to test your OpenAI API keys and models, or just to have a fun conversation with a chatbot!

this.handleKeyPress(e)} onChange={(e) => this.handleInputChange(e)} className="w-full round" autoFocus x-data={{ input: this.inputs.text }} x-cloak x-show={state} />
{this.state === this.states.input ? (
this.handleKeyPress(e)} onChange={(e) => this.handleInputChange(e)} className="border border-gray-400 rounded w-full p-2" />
) : null} {this.state === this.states.apiKey ? (
) : null}
); } } export default App;