Spaces:
Runtime error
Runtime error
File size: 1,164 Bytes
07879c1 7f3e850 46b04e0 08ccc2c 137db73 e204e9a 137db73 90ad141 07879c1 dc685c3 07879c1 dc685c3 07879c1 dc685c3 07879c1 dc685c3 07879c1 dc685c3 07879c1 5f59db3 7f3e850 07879c1 7f3e850 |
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 streamlit as st
import requests
import os
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()
st.set_page_config(
page_title="Incoder Example",
page_icon="π¨βπ»",
)
st.markdown("# π¨βπ» Incoder Example")
txt = st.text_area('Write code here', '''import os
def remove_file(file):''', height=400)
gen = st.button('Generate')
c = st.code('')
max_length = st.slider('max_length', 1, 2048, 128)
top_k = st.slider('top_k', 0, 100, 50)
top_p = st.slider('top_p', 0.0, 1.0, 0.9)
temperature = st.slider('temperature', 0.0, 1.0, 0.6)
num_beams = st.slider('num_beams', 1, 100, 0)
repetition_penalty = st.slider('repetition_penalty', 1.0, 10.0, 1.0)
if gen:
c.code('Generating...')
req = f"http://0.0.0.0:8080?input_text={txt}&top_p={int(top_p*100)}&top_k={int(top_k*100)}&temperature={int(temperature*100)}&num_beams={int(num_beams*100)}&repetition_penalty={int(top_p*100)}&max_length={max_length}"
res = requests.get(req)
print('ok')
c.code(json.loads(res.text)) |