Inference / app.py
Max KHANOV
Server restart, updating endpoint
94bcfa5
import streamlit as st
st.header('Args')
st.text('(Llama-7b sft)')
col1, col2 = st.columns([3,1])
example_num = st.selectbox("Select an example", ("None", "Example 1", "Example 2", "Example 3", "Example 4", "Example 5"), index=3)
if example_num != "None":
examples = {"Example 1": "What should you wear to a funeral?",
"Example 2": "I need a good winter glove and I'm wondering what materials I should be looking for. I want something lightly insulated but weather resistant.",
"Example 3": "My son is struggling to learn how to do addition. How can I teach him?",
"Example 4": "How do you get a child to do homework?",
"Example 5": "How do I feel comfortable in my own skin?"}
example_text = examples.get(example_num)
st.session_state.text = example_text
with col1:
text = st.text_area('Enter text', "", height=180, key="text")
with col2:
weight = st.slider('weight', min_value=0.0, max_value=1.5, value=1.5, step=0.01)
k = st.slider("k", min_value=2, max_value=10, value=10, step=1)
trigger = st.button("Generate")
st.subheader("Result")
import requests
GROK_URL = "https://0aaf-128-105-19-70.ngrok-free.app"
ENDPOINT = f"{GROK_URL}/model"
if trigger:
req = requests.get(ENDPOINT, params={"weight": weight, "k": k, "text": text, "ngrok-skip-browser-warning": "1"})
if req.status_code == 200:
result = req.text
else:
result = "Sorry, an error occured!"
st.write(result)