File size: 1,042 Bytes
8254353
 
c90e0f6
8254353
 
40c0aeb
 
 
 
c90e0f6
 
4b5ea20
c90e0f6
 
4b5ea20
c90e0f6
 
40c0aeb
8254353
8475b83
8254353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e82396e
8254353
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
40
41
42
43
44
import streamlit as st
from langchain.llms import HuggingFaceHub

#Function to return the response 
def generate_answer(query):
    llm = HuggingFaceHub(
        repo_id = "huggingfaceh4/zephyr-7b-alpha", 
        model_kwargs={"temperature": 0.5, "max_length": 64,"max_new_tokens":512}
    )
    prompt = f"""
             <|system|>
            You are an AI assistant that follows instruction extremely well. Please be truthful and give direct answers
            </s>
             <|user|>
             {query}</s>
             <|assistant|>
            """
    result = llm.predict(prompt)
    return result
    

#App UI starts here 
st.set_page_config(page_title = "LangChain Demo", page_icon = ":robot:")
st.header("LangChain Demo")


#Gets User Input 
def get_text():
    input_text = st.text_input("You: ", key="input")
    return input_text


user_input = get_text()
response = generate_answer(user_input)

submit = st.button("Generate")

#If the button clicked
if submit:
    st.subheader("Answer: ")
    st.write(response)