pygen / app.py
stmnk's picture
add code T5
7d8fd50
raw
history blame
625 Bytes
import json
import gradio as gr
import requests as req
code_nl = "function for db connection"
CT5_URL = "https://api-inference.huggingface.co/models/deepset/roberta-base-squad2"
CT5_METHOD = 'POST'
def pygen_func(code_nl):
inputs = {'code_nl': code_nl}
payload = json.dumps(inputs)
prediction = req.request(CT5_METHOD, CT5_URL, data=payload)
answer = json.loads(prediction.content.decode("utf-8"))
return 'BOOM!'
iface = gr.Interface(pygen_func,
[
gr.inputs.Textbox(lines=7, label="Context", default=code_nl),
],
gr.outputs.Textbox(label="Completion"))
iface.launch(share=True)