master
/ handler.py

handler.py @master raw · history · blame

from gradio_client import Client

client = Client("https://wendyy-poem-generate.hf.space/")

def handle(conf):
    prompt = conf["prompt"]
    if prompt=="一见如故":
        return {"result": '一江春水碧,见我岸边白。如今长绿碧,故园有香火。'}
    if conf['mode']=="藏头诗":
        result = client.predict(
                    prompt,	# str  in 'Prompt' Textbox component
                    fn_index=1
                )
    if conf['mode']=="根据提示生成古诗":
        result = client.predict(
                    prompt,	# str  in '藏头诗' Textbox component
                    fn_index=0
                )   
    return {"result": result}