Spaces:
Runtime error
Runtime error
import requests | |
import os | |
import gradio as gr | |
import json | |
def start_server(): | |
os.system("uvicorn server:app --port 8080 --host 0.0.0.0 --workers 1") | |
os.environ["SSTART"] = "1" | |
if os.environ.get('SSTART') != "1": | |
start_server() | |
def completion(prompt,max_tokens,temperature,top_k,top_p): | |
req = f"http://0.0.0.0:8080?input_text={prompt}&top_p={top_p}&top_k={top_k}&temperature={temperature}&max_length={prompt}" | |
g = requests.get(req).json() | |
return g['text'] | |
demo = gr.Interface( | |
fn=completion, | |
inputs=[ | |
gr.inputs.Textbox(lines=10,placeholder='Write some code..'), | |
gr.inputs.Slider(10,200,10,100,'Max Tokens',False), | |
gr.inputs.Slider(0,1.0,0.1,1.0,'temperature',False), | |
gr.inputs.Slider(0,50,1,40,'top_k',True), | |
gr.inputs.Slider(0,1.0,0.1,0.9,'top_p',True) | |
], | |
outputs="text", | |
theme='dark-huggingface', | |
title='Solo-Coder', | |
description='Build by Ansh and β€οΈ', | |
allow_flagging=False, | |
) | |
if __name__ == "__main__": | |
demo.launch() |