Spaces:
Runtime error
Runtime error
from abc import ABC, abstractmethod | |
import replicate | |
class GenericModel: | |
def __init__(self, name: str): | |
self.name = name | |
def load(self): | |
pass | |
def generate(self, prompt: str): | |
pass | |
class ReplicateModel(GenericModel): | |
def __init__(self, name: str): | |
super().__init__(name) | |
def load(self): | |
return self | |
def generate(self, prompt: str): | |
iterator = replicate.run(self.name, input={'prompt': prompt}) | |
return ''.join(item for item in iterator) |