Spaces:
Runtime error
Runtime error
Major Error Fix
Browse files
app.py
CHANGED
|
@@ -12,8 +12,9 @@ import os
|
|
| 12 |
|
| 13 |
## Function to load OpenAI model and get responses
|
| 14 |
|
| 15 |
-
def get_openai_response(question,input_key):
|
| 16 |
-
|
|
|
|
| 17 |
#model_name="gpt-3.5-turbo-instruct",
|
| 18 |
temperature=0.5)
|
| 19 |
|
|
@@ -29,12 +30,17 @@ st.header("Langchain Application")
|
|
| 29 |
input_key = st.text_input("Enter OpenAI Key: ", key="input_key")
|
| 30 |
|
| 31 |
input = st.text_input("Input Question: ", key="input")
|
| 32 |
-
response = get_openai_response(input, input_key)
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
## Function to load OpenAI model and get responses
|
| 14 |
|
| 15 |
+
def get_openai_response(question, input_key):
|
| 16 |
+
print('\n\n\n\\n')
|
| 17 |
+
llm = OpenAI(openai_api_key=input_key,
|
| 18 |
#model_name="gpt-3.5-turbo-instruct",
|
| 19 |
temperature=0.5)
|
| 20 |
|
|
|
|
| 30 |
input_key = st.text_input("Enter OpenAI Key: ", key="input_key")
|
| 31 |
|
| 32 |
input = st.text_input("Input Question: ", key="input")
|
|
|
|
| 33 |
|
| 34 |
+
if input_key != "":
|
| 35 |
+
try:
|
| 36 |
+
response = get_openai_response(input, input_key)
|
| 37 |
|
| 38 |
+
submit = st.button("Ask the question")
|
| 39 |
|
| 40 |
+
## If ask button is clicked
|
| 41 |
+
|
| 42 |
+
if submit:
|
| 43 |
+
st.subheader("The Response is")
|
| 44 |
+
st.write(response)
|
| 45 |
+
except:
|
| 46 |
+
st.write("Incorrect API Key")
|