CoolFace
Apppublic

thisisanshgupta/solo-coder-20B

sourceHugging Facemitupdated 4y agoView on Hugging Face
2likes
app.py41 linesDownload Raw Back to root
1import os2import sys3import requests4import gradio as gr5 6api_url = "https://api.textsynth.com"7api_key = os.environ["TEXTSYNTH_API_SECRET_KEY"]8api_engine = "gptneox_20B"9 10def completion(prompt,max_tokens,temperature,top_k,top_p):11    response = requests.post(api_url + "/v1/engines/" + "gptneox_20B" + "/completions", headers = { "Authorization": "Bearer " + api_key }, json = { "prompt": prompt, "max_tokens": max_tokens ,"temperature": temperature,"top_k": top_k,"top_p": top_p })12    resp = response.json()13    if "text" in resp: 14        return prompt + resp["text"]15    else:16        print("ERROR", resp)17        assert False18 19    if len(sys.argv) <= 1:20       sys.exit(1)21 22demo = gr.Interface(23       fn=completion, 24       inputs=[25               gr.inputs.Textbox(lines=10,placeholder='Write some code..'),26               gr.inputs.Slider(10,200,10,100,'Max Tokens',False),27               gr.inputs.Slider(0,1.0,0.1,1.0,'temperature',False),28               gr.inputs.Slider(0,50,1,40,'top_k',True),29               gr.inputs.Slider(0,1.0,0.1,0.9,'top_p',True)30       ],31       outputs="text",32       theme='dark-huggingface',33       title='Solo-Coder',34       description='Build by Ansh and ❤️',35       allow_flagging=False,36 37)38 39if __name__ == "__main__":40    demo.launch()41