Spaces:
Sleeping
Sleeping
Download app.py from Sapnil/Langchain_Q-A_ChatBot: direct link, hf CLI and curl.
- Browser
- Download file 866 Bytes
-
https://huggingface.co/spaces/Sapnil/Langchain_Q-A_ChatBot/resolve/main/app.py
- Command line
-
hf download hf://spaces/Sapnil/Langchain_Q-A_ChatBot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Sapnil/Langchain_Q-A_ChatBot/resolve/main/app.py
866 Bytes
| # Author : Sapnil Patel | |
| # Date : 18/12/23 | |
| # This file contains the code related to Chatbot Application | |
| # Import libraries | |
| import os | |
| import streamlit as st | |
| from dotenv import load_dotenv | |
| from langchain.llms import OpenAI | |
| # take evironment variables from .env file | |
| load_dotenv() | |
| # Function to load OpenAI and get response | |
| def get_openai_response(question): | |
| llm = OpenAI(openai_api_key=os.getenv("OPEANAI_API_KEY"),model_name='text-davinci-003',temperature=0.5) | |
| response=llm(question) | |
| return response | |
| # Initialize our streamlit app | |
| st.set_page_config(page_title = "Q & A App") | |
| st.header("Langchain Application with OpenAI") | |
| input = st.text_input("Input: ", key="Input") | |
| response = get_openai_response(input) | |
| submit = st.button("Ask the question") | |
| # If ask button is clicked | |
| if submit: | |
| st.subheader("The Response is") | |
| st.write(response) |