Spaces:
Sleeping
Sleeping
| import keyfile | |
| import streamlit as st | |
| from langchain_openai import OpenAI | |
| import getpass | |
| import os | |
| # Creating a function for getting the responses from OpenAI | |
| def get_response(question): | |
| os.environ["OPENAI_API_KEY"] = keyfile.OPENAI_API_KEY | |
| llm = OpenAI() | |
| answer = llm.invoke(question) | |
| return answer | |
| # Using Streamlit for generation of page | |
| st.set_page_config(page_title = "ASK GPT", page_icon = ":robot:") | |
| st.header("ASK GPT Application") | |
| # Create a function for taking user input | |
| def get_user_input(): | |
| text = st.text_input("Ask: ", key = "input") | |
| return text | |
| user_input = get_user_input() | |
| resp = get_response(user_input) | |
| # Submission button | |
| submit = st.button("Ask!") | |
| if submit: | |
| st.subheader("Answer: ") | |
| st.write(resp) | |