whackthejacker's picture
Create app.py
bf3219e verified
raw
history blame
2.54 kB
import gradio as gr
# Load the models
models = {
"bigcode/python-stack-v1-functions-filtered-sc2-subset": gr.Interface.load("bigcode/python-stack-v1-functions-filtered-sc2-subset"),
"bigcode/python-stack-v1-functions-filtered-sc2": gr.Interface.load("bigcode/python-stack-v1-functions-filtered-sc2"),
"muellerzr/python-stack-v1-functions-filtered-llama-3-8B": gr.Interface.load("muellerzr/python-stack-v1-functions-filtered-llama-3-8B"),
"YoLo2000/python-stack-functions-filtered": gr.Interface.load("YoLo2000/python-stack-functions-filtered"),
"YoLo2000/python-stack-functions-filteredbigcode/python-stack-v1-functions-filtered-sc2": gr.Interface.load("YoLo2000/python-stack-functions-filteredbigcode/python-stack-v1-functions-filtered-sc2"),
"TheBloke/Python-Code-13B-GGUF": gr.Interface.load("TheBloke/Python-Code-13B-GGUF"),
"replit/replit-code-v1_5-3b": gr.Interface.load("replit/replit-code-v1_5-3b"),
"neulab/codebert-python": gr.Interface.load("neulab/codebert-python")
}
# Load the datasets
datasets = {
"kye/all-huggingface-python-code": gr.Dataset.load("kye/all-huggingface-python-code"),
"ajibawa-2023/WikiHow": gr.Dataset.load("ajibawa-2023/WikiHow"),
"ajibawa-2023/Code-74k-ShareGPT": gr.Dataset.load("ajibawa-2023/Code-74k-ShareGPT"),
"ajibawa-2023/Software-Architectural-Frameworks": gr.Dataset.load("ajibawa-2023/Software-Architectural-Frameworks"),
"ajibawa-2023/Python-Code-23k-ShareGPT": gr.Dataset.load("ajibawa-2023/Python-Code-23k-ShareGPT"),
"HuggingFaceFW/fineweb": gr.Dataset.load("HuggingFaceFW/fineweb"),
"kye/all-huggingface-python-code-2": gr.Dataset.load("kye/all-huggingface-python-code-2"),
"suvadityamuk/huggingface-transformers-code-dataset": gr.Dataset.load("suvadityamuk/huggingface-transformers-code-dataset")
}
# Define the interface
def generate_code(prompt, model, dataset, temperature, max_length):
model_instance = models[model]
dataset_instance = datasets[dataset]
output = model_instance.generate(prompt, dataset_instance, temperature, max_length)
return output
iface = gr.Interface(
fn=generate_code,
inputs=[
________gr.Textbox(label="Prompt"),
________gr.Dropdown(label="Model",_choices=list(models.keys())),
________gr.Dropdown(label="Dataset",_choices=list(datasets.keys())),
________gr.Slider(label="Temperature",_minimum=0.1,_maximum=1.0,_default=0.5),
________gr.Slider(label="Max_Length",_minimum=10,_maximum=1000,_default=200)
____],
outputs="text"
)
# Launch the interface
iface.launch()