Download app.py from Ankit93/LangChain: direct link, hf CLI and curl.
- Browser
- Download file 779 Bytes
-
https://huggingface.co/spaces/Ankit93/LangChain/resolve/main/app.py
- Command line
-
hf download hf://spaces/Ankit93/LangChain/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Ankit93/LangChain/resolve/main/app.py
779 Bytes
| 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): | |
| # try: | |
| # llm = OpenAI(model="text-davinci-003",openai_api_key=os.getenv("OPEN_API_KEY"),temperature=0.6) | |
| # response=llm(question) | |
| # except: | |
| 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) | |