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 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!