Spaces:
Runtime error
Runtime error
Download app.py from arnavpathak/Open_AI_Test: direct link, hf CLI and curl.
- Browser
- Download file 586 Bytes
-
https://huggingface.co/spaces/arnavpathak/Open_AI_Test/resolve/main/app.py
- Command line
-
hf download hf://spaces/arnavpathak/Open_AI_Test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/arnavpathak/Open_AI_Test/resolve/main/app.py
586 Bytes
| # Chat-Bot | |
| from langchain.llms import OpenAI | |
| from dotenv import load_dotenv | |
| import streamlit as st | |
| import os | |
| load_dotenv() | |
| def GetOpenaiResponse(question): | |
| llm = OpenAI( | |
| openai_api_key=os.getenv("OPENAI_API_KEY"), | |
| temperature=0.6, | |
| ) | |
| response = llm.invoke(question) | |
| return response | |
| st.set_page_config(page_title="Q&A Demo") | |
| st.header("Ask a question") | |
| input = st.text_input("Input : ", key="input") | |
| response = GetOpenaiResponse(input) | |
| submit = st.button("Generate Answer") | |
| if submit: | |
| st.subheader("The response is :") | |
| st.write(response) | |