cog
cog copied to clipboard
Output type List[Output] causes cog to generate invalid output schema
This code:
class Output(BaseModel):
text: str
class Predictor(BasePredictor):
def predict(self) -> list[Output]:
pass
confuses cog's get_output_type into generating a schema with no Output, thereby confusing the replicate.com UI
Not sure if it's related but there was a change in Python 3.9 that made capital-L List the thing you use for type hinting, rather than list which is now just the built-in python list function.
If you do this, does it work?
from typing import List
class Output(BaseModel):
text: str
class Predictor(BasePredictor):
def predict(self) -> List[Output]:
pass
No change. Test with cog run python3 -m cog.command.openapi_schema
Here's another one: https://github.com/replicate/cog/pull/1267#issuecomment-1885038556
cc @aron