Spaces:
Build error
Build error
File size: 910 Bytes
af79bbb 23a7d6f | 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 | import streamlit as st
from langchain_huggingface import ChatHuggingFace, HuggingFacePipeline
import os
# Load model
@st.cache_resource
def load_model():
llm = HuggingFacePipeline.from_model_id(
model_id='TinyLlama/TinyLlama-1.1B-Chat-v1.0',
task='text-generation',
pipeline_kwargs=dict(
temperature=0.5,
max_new_tokens=100
)
)
return ChatHuggingFace(llm=llm)
model = load_model()
# Streamlit UI
st.set_page_config(page_title="TinyLlama Chatbot", layout="centered")
st.title("🦙 TinyLlama Chatbot")
st.markdown("Ask any question and get an answer using TinyLlama!")
# Input box
user_input = st.text_input("Enter your question here:", "")
# Generate and display answer
if user_input:
with st.spinner("Generating response..."):
response = model.invoke(user_input)
st.success("Response:")
st.write(response.content)
|