Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| # NEW: Hugging Face Endpoint (بديل OpenAI) | |
| from langchain_huggingface import HuggingFaceEndpoint | |
| # ============================= | |
| # Function to return the response | |
| # ============================= | |
| def load_answer(question): | |
| llm = HuggingFaceEndpoint( | |
| repo_id="google/flan-t5-large", | |
| temperature=0, | |
| max_new_tokens=256 | |
| ) | |
| answer = llm.invoke(question) | |
| return answer | |
| # ============================= | |
| # App UI | |
| # ============================= | |
| st.set_page_config(page_title="LangChain QuestionandAnswerApp", page_icon="🤖") | |
| st.header("LangChain QuestionandAnswerApp (Free Model)") | |
| def get_text(): | |
| input_text = st.text_input("You:", key="input") | |
| return input_text | |
| user_input = get_text() | |
| submit = st.button("Generate") | |
| if submit and user_input: | |
| response = load_answer(user_input) | |
| st.subheader("Answer:") | |
| st.write(response) | |