Spaces:
Sleeping
Sleeping
File size: 2,143 Bytes
c83b762 47aaf42 1c041ec 47aaf42 1c041ec c83b762 1c041ec d850c57 3c40360 ea441ae 3c40360 1c041ec d850c57 11a95cf ea441ae 1c041ec 11a95cf ea441ae 11a95cf ea441ae 11a95cf ea441ae 11a95cf ea441ae |
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
import subprocess
import torch
import streamlit as st
from streamlit import session_state as state
import streamlit_ace
import pipline
if "app" not in state:
state.app = "model"
state.out = ""
in_area = st.container()
out_area = st.container()
in_area.title("Demo using langchain and streamlit")
out_area.header("Output")
def __run_TTI():
with out_area.empty():
out_area.markdown(":green[Running pipline]")
out_area.write(pipline.chain_TI(state.input_text)['text'])
def __run_CC():
with out_area.empty():
out_area.markdown(":green[Running pipline]")
words = state.input_text.rstrip().split()
if len(words) != 2:
out_area.error("Please enter two terms")
else:
out_area.write(pipline.chain_CC({"term1": words[0], "term2": words[1]})['text'])
in_area.text_area("enter text", key="input_text")
tti_button , cc_button = in_area.columns(2)
tti_button.button("What are you trying to imply?", on_click=__run_TTI)
cc_button.button("What is the connection between the two terms?", on_click=__run_CC)
with st.expander("code", expanded=False):
st.code("""
import pipline
if "app" not in state:
state.app = "model"
state.out = ""
in_area = st.container()
out_area = st.container()
in_area.title("Demo using langchain and streamlit")
out_area.header("Output")
def __run_TTI():
with out_area.empty():
out_area.markdown(":green[Running pipline]")
out_area.write(pipline.chain_TI(state.input_text)['text'])
def __run_CC():
with out_area.empty():
out_area.markdown(":green[Running pipline]")
words = state.input_text.rstrip().split()
if len(words) != 2:
out_area.error("Please enter two terms")
else:
out_area.write(pipline.chain_CC({"term1": words[0], "term2": words[1]})['text'])
in_area.text_area("enter text", key="input_text")
tti_button , cc_button = in_area.columns(2)
tti_button.button("What are you trying to imply?", on_click=__run_TTI)
cc_button.button("What is the connection between the two terms?", on_click=__run_CC)
""",language="python") |