Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)
OpenAssistant Conversations (oasst2)
Create a React functional component that converts and image upload to base64.
In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
- User
Create a React functional component that converts and image upload to base64.
- Assistant
This is a React component to convert image to base64 string. Leveraging Material UI Button upload. Credit goes to: https://gist.github.com/wambuguedison/a195f73f118dcae977e41aa5fbef1899
import Button from "@material-ui/core/Button"; class ImageConverter extends React.Component { constructor(props) { super(props); this.state = { files: [] }; this.convert = this.convert.bind(this); } convert(e) { // check max. file size is not exceeded // size is in bytes if (files[0].size > 2000000) { console.log("File too large"); return; } var reader = new FileReader(); reader.readAsDataURL(e.target.files[0]); reader.onload = () => { console.log(reader.result); //base64encoded string }; reader.onerror = error => { console.log("Error: ", error); }; } render() { return ( <> <input accept="image/*" style={{ display: "none" }} id="button-file" type="file" onChange={this.convert} /> <label htmlFor="button-file"> <Button variant="contained" color="primary" component="span" > Add Additional Images </Button> </label> </> ); } } export default ImageConverter;
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.