Spaces:
Sleeping
Sleeping
Update keyfile-streamlit-app.py
Browse files- keyfile-streamlit-app.py +18 -2
keyfile-streamlit-app.py
CHANGED
@@ -1,33 +1,49 @@
|
|
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 |
-
|
|
|
1 |
import keyfile
|
2 |
+
|
3 |
import streamlit as st
|
4 |
+
|
5 |
from langchain_openai import OpenAI
|
6 |
+
|
7 |
import getpass
|
8 |
+
|
9 |
import os
|
10 |
|
11 |
# Creating a function for getting the responses from OpenAI
|
12 |
+
|
13 |
def get_response(question):
|
14 |
+
|
15 |
os.environ["OPENAI_API_KEY"] = keyfile.OPENAI_API_KEY
|
16 |
+
|
17 |
llm = OpenAI()
|
18 |
+
|
19 |
answer = llm.invoke(question)
|
20 |
+
|
21 |
return answer
|
22 |
|
23 |
# Using Streamlit for generation of page
|
24 |
+
|
25 |
st.set_page_config(page_title = "ASK GPT", page_icon = ":robot:")
|
26 |
+
|
27 |
st.header("ASK GPT Application")
|
28 |
|
29 |
# Create a function for taking user input
|
30 |
+
|
31 |
def get_user_input():
|
32 |
+
|
33 |
text = st.text_input("Ask: ", key = "input")
|
34 |
+
|
35 |
return text
|
36 |
|
37 |
user_input = get_user_input()
|
38 |
+
|
39 |
resp = get_response(user_input)
|
40 |
|
41 |
# Submission button
|
42 |
+
|
43 |
submit = st.button("Ask!")
|
44 |
|
45 |
if submit:
|
46 |
+
|
47 |
st.subheader("Answer: ")
|
|
|
48 |
|
49 |
+
st.write(resp)
|