import streamlit as st | |
import os | |
from langchain import PromptTemplate, HuggingFaceHub, LLMChain | |
x = st.slider('Select a value') | |
st.write(x, 'squared is', x * x) | |
# https://cobusgreyling.medium.com/langchain-creating-large-language-model-llm-applications-via-huggingface-192423883a74 | |
# !pip install langchain[all] | |
template = """Question: {question}""" | |
HUGGING_FACE_API_KEY= os.environ.get("HUGGING_FACE_API_KEY") | |
Answer= "Let's think step by step." | |
prompt = PromptTemplate(template=template, input_variables=["question"]) | |
llm=HuggingFaceHub(repo_id="Writer/palmyra-small", model_kwargs={"temperature":1e-10},huggingfacehub_api_token=HUGGING_FACE_API_KEY) | |
question=st.text_input("Input the question",'') | |
# question = "When was Google founded?" | |
# print(llm.run(question)) | |
if question: | |
d=LLMChain(llm=llm,prompt=prompt) | |
st.write("out",d.run(question)) | |