Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from langchain_huggingface import ChatHuggingFace, HuggingFacePipeline
|
| 3 |
+
|
| 4 |
+
@st.cache_resource
|
| 5 |
+
def load_llm():
|
| 6 |
+
llm = HuggingFacePipeline.from_model_id(
|
| 7 |
+
model_id="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
|
| 8 |
+
task="text-generation",
|
| 9 |
+
pipeline_kwargs=dict(
|
| 10 |
+
temperature=0.5,
|
| 11 |
+
max_new_tokens=150
|
| 12 |
+
)
|
| 13 |
+
)
|
| 14 |
+
return ChatHuggingFace(llm=llm)
|
| 15 |
+
|
| 16 |
+
model=load_llm()
|
| 17 |
+
|
| 18 |
+
st.header("QnA Tool")
|
| 19 |
+
|
| 20 |
+
user_input = st.text_input("Enter your prompt")
|
| 21 |
+
|
| 22 |
+
if st.button("Summarize"):
|
| 23 |
+
result = model.invoke(user_input)
|
| 24 |
+
st.write(result.content)
|