archana2324 commited on
Commit
2d2d08f
·
verified ·
1 Parent(s): 4c6cb20

Create keyfile-app.py

Browse files
Files changed (1) hide show
  1. keyfile-app.py +33 -0
keyfile-app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import keyfile
2
+ import streamlit as st
3
+ from langchain_openai import OpenAI
4
+ import getpass
5
+ import os
6
+
7
+ # Creating a function for getting the responses from OpenAI
8
+ def get_response(question):
9
+ os.environ["OPENAI_API_KEY"] = keyfile.OPENAI_API_KEY
10
+ llm = OpenAI()
11
+ answer = llm.invoke(question)
12
+ return answer
13
+
14
+ # Using Streamlit for generation of page
15
+ st.set_page_config(page_title = "ASK GPT", page_icon = ":robot:")
16
+ st.header("ASK GPT Application")
17
+
18
+ # Create a function for taking user input
19
+ def get_user_input():
20
+ text = st.text_input("Ask: ", key = "input")
21
+ return text
22
+
23
+ user_input = get_user_input()
24
+ resp = get_response(user_input)
25
+
26
+ # Submission button
27
+ submit = st.button("Ask!")
28
+
29
+ if submit:
30
+ st.subheader("Answer: ")
31
+ st.write(resp)
32
+
33
+ has context menu