Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
model_id = "meta-llama/Llama-3.2-1B-Instruct" # Open-access model
|
5 |
+
pipe = pipeline("text-generation", model=model_id)
|
6 |
+
|
7 |
+
def load_answer(question):
|
8 |
+
return pipe(question, max_length=200)[0]['generated_text']
|
9 |
+
|
10 |
+
st.set_page_config(page_title='LangChain Demo', page_icon=':robot:')
|
11 |
+
st.header("LangChain Demo")
|
12 |
+
|
13 |
+
def get_text():
|
14 |
+
return st.text_input("Question: ", key="input")
|
15 |
+
|
16 |
+
user_input = get_text()
|
17 |
+
submit = st.button("Ask")
|
18 |
+
|
19 |
+
if submit:
|
20 |
+
output = load_answer(user_input)
|
21 |
+
st.write(output)
|