File size: 831 Bytes
c172768
68741d5
 
 
 
f8a5464
 
 
39bc898
68741d5
 
 
 
c172768
68741d5
0591543
68741d5
c172768
799c144
c172768
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
import banana_dev as banana
import os
api_key = os.getenv("API_KEY")
model_key = os.getenv("MODEL_KEY")

title = "CodeAlpaca"
description = "Instruction following model for code generation."
examples = ["Write a python function to sort a list.","Write a function to scrape hacker news.","Implement a utility function to compute the accuracy of predictions using metric from sklearn.","Write a web server in rust."]
def call_model(prompt):
    model_parameters = {
        "prompt": prompt,
        "max_length":1000

    }
    out = banana.run(api_key, model_key, model_parameters)    
    return out["modelOutputs"][0]["output"]

iface = gr.Interface(fn=call_model, inputs="text", outputs=gr.Code(label="Output",lines=20,language="python"),examples=examples,description=description,title=title)
iface.launch()