incoder-api / app.py
Danil
v
abe5a52
raw
history blame
1.13 kB
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={top_p}&top_k={top_k}&temperature={temperature}&num_beams={num_beams}&repetition_penalty={repetition_penalty}&max_length={max_length}"
res = requests.get(req)
print('ok')
c.code(json.loads(res.text))