|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
model_id = "microsoft/Phi-3-mini-4k-instruct" |
|
pipe = pipeline("text-generation", model=model_id) |
|
|
|
def load_answer(question): |
|
return pipe(question, max_length=200)[0]['generated_text'] |
|
|
|
st.set_page_config(page_title='LangChain Demo', page_icon=':robot:') |
|
st.header("LangChain Demo") |
|
|
|
def get_text(): |
|
return st.text_input("Question: ", key="input") |
|
|
|
user_input = get_text() |
|
submit = st.button("Ask") |
|
|
|
if submit: |
|
output = load_answer(user_input) |
|
st.write(output) |