File size: 1,495 Bytes
f9b2e38
 
 
 
 
37a687a
a5de40a
6f51025
 
a5de40a
 
 
 
 
6f51025
 
 
f9b2e38
37a687a
f9b2e38
 
37a687a
3738039
f9b2e38
 
 
 
 
94bcfa5
f9b2e38
 
 
3738039
913c08c
3738039
 
 
f9b2e38
3738039
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
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)