File size: 1,288 Bytes
12d1370
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25f4f54
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
37
38
39
40
41
import os
import sys
import requests
import gradio as gr

api_url = "https://api.textsynth.com"
api_key = os.environ["TEXTSYNTH_API_SECRET_KEY"]
api_engine = "gptneox_20B"

def completion(prompt,max_tokens,temperature,top_k,top_p):
    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 })
    resp = response.json()
    if "text" in resp: 
        return prompt + resp["text"]
    else:
        print("ERROR", resp)
        assert False

    if len(sys.argv) <= 1:
       sys.exit(1)

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()