0sparsh2 commited on
Commit
e73b42e
1 Parent(s): 2427766

Major Error Fix

Browse files
Files changed (1) hide show
  1. app.py +14 -8
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
- llm = OpenAI(openai_api_key = str(input_key),
 
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
- submit = st.button("Ask the question")
 
 
35
 
36
- ## If ask button is clicked
37
 
38
- if submit:
39
- st.subheader("The Response is")
40
- st.write(response)
 
 
 
 
 
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")