Spaces:
Runtime error
Runtime error
File size: 1,101 Bytes
7f3e850 4932cf0 7f3e850 46b04e0 08ccc2c 137db73 e204e9a 137db73 90ad141 4932cf0 07879c1 4932cf0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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() |