File size: 911 Bytes
61e797f
 
ad57909
 
61e797f
ad57909
 
 
61e797f
ad57909
 
 
 
 
61e797f
ad57909
61e797f
 
 
ad57909
 
 
 
 
61e797f
 
ad57909
61e797f
 
 
ad57909
61e797f
ad57909
61e797f
ad57909
 
61e797f
 
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
37
38
39
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)