Spaces:
Sleeping
Sleeping
Download app.py from dincertolga/Langchain_Basic_Chatbot: direct link, hf CLI and curl.
- Browser
- Download file 684 Bytes
-
https://huggingface.co/spaces/dincertolga/Langchain_Basic_Chatbot/resolve/main/app.py
- Command line
-
hf download hf://spaces/dincertolga/Langchain_Basic_Chatbot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/dincertolga/Langchain_Basic_Chatbot/resolve/main/app.py
684 Bytes
| # Q&A Chatbot | |
| from langchain_community.llms import OpenAI | |
| #from dotenv import load_dotenv | |
| #load_dotenv() | |
| import streamlit as st | |
| import os | |
| #Function to load openAI model and get response | |
| def get_openai_response(question): | |
| llm = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"), temperature = 0.5) | |
| response = llm(question) | |
| return response | |
| # initialize streamlit app | |
| st.set_page_config(page_title="Q&A Demo") | |
| st.header("Langchain Application") | |
| 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) | |