| from langchain import HuggingFaceHub |
| from langchain.llms import OpenAI |
| from dotenv import load_dotenv |
| import streamlit as st |
| import os |
|
|
| load_dotenv() |
|
|
| def get_openai_response(question): |
| |
| |
| |
| |
| llm_hugg = HuggingFaceHub(repo_id="google/flan-t5-large",model_kwargs={'temperature':0, "max_length":64}) |
| response=llm_hugg(question) |
| return response |
|
|
| st.set_page_config(page_title="Q&A Demo") |
| st.header("Langchain Aplication") |
|
|
| input = st.text_input("Input: ",key="input") |
| response = get_openai_response(input) |
| submit = st.button("Ask Question") |
| if submit: |
| st.subheader("The Response is:") |
| st.write(response) |
|
|