safer parsing
Browse files30 unmodified lines313233343536373839404142434427 unmodified lines72737475767730 unmodified linesA :obj:`list` | `dict`: will be serialized and returned"""# get inputsinputs = data.pop("inputs", None)if not inputs:return f"Inputs not in payload got {data}"# get additional date field0prompt = inputs.pop("prompt", None)image_url = inputs.pop("image", None)if image_url is None:return "You need to upload an image URL for LLaVA to work."27 unmodified linesoutput = self.model.generate(**inputs, max_new_tokens=100)clean = self.processor.decode(output[0], skip_special_tokens=True)return clean30 unmodified lines313233343536373839404142434427 unmodified lines72737475767778798030 unmodified linesA :obj:`list` | `dict`: will be serialized and returned"""# get inputsinputs = data.get("inputs")if not inputs:return f"Inputs not in payload got {data}"# get additional date field0prompt = inputs.get("prompt")image_url = inputs.get("image")if image_url is None:return "You need to upload an image URL for LLaVA to work."27 unmodified linesoutput = self.model.generate(**inputs, max_new_tokens=100)if not output:return 'Model failed to generate'clean = self.processor.decode(output[0], skip_special_tokens=True)return clean
handler.py+6-3