CaGBERT / app.py
MSey90
Update app.py
c447bbf unverified
raw
history blame
809 Bytes
from transformers import pipeline
import streamlit as st
@st.cache_resource
def context_text(text): return f"### Context\n{text}\n\n### Answer"
@st.cache_resource
def load_pipe():
return pipeline("text-generation", model="MSey/tiny_CaLL_r10_O1_f10_LT_c1022")
pipe = load_pipe()
st.header("Test Environment for tiny_CaLL_r10_O1_f10_LT_c1022")
user_input = st.text_input("Enter your Prompt here:", "")
contexted_ipnut = context_text(user_input)
context_len = len(contexted_ipnut)
if user_input:
with st.spinner('Generating response...'):
response = pipe(contexted_ipnut, max_new_tokens = 200, num_return_sequences=1)
generated_text = response[0]['generated_text'][context_len:]
st.write("Generated Text:")
st.markdown(generated_text)
st.text(generated_text)