meesamraza commited on
Commit
2b674bb
·
verified ·
1 Parent(s): 9e50828

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -41,16 +41,22 @@ def main():
41
  topic = st.selectbox("Choose a programming topic", developer_topics)
42
  user_input = st.text_area("Or ask a programming-related question:", "")
43
 
44
- # If the user provides a query (not from audio), use that directly
45
- if user_input:
46
- query = user_input
47
- response = get_response(query)
48
- st.write("### Response:")
49
- st.write(response)
50
-
51
- # Handle unrelated queries
52
- if user_input and not any(topic in user_input.lower() for topic in developer_topics):
53
- st.write("Sorry, I can only answer programming-related questions.")
 
 
 
 
 
 
54
 
55
  if __name__ == "__main__":
56
  main()
 
41
  topic = st.selectbox("Choose a programming topic", developer_topics)
42
  user_input = st.text_area("Or ask a programming-related question:", "")
43
 
44
+ # Add a submit button to trigger the response
45
+ submit_button = st.button("Submit")
46
+
47
+ # If the user clicks the submit button, process the query
48
+ if submit_button:
49
+ if user_input:
50
+ query = user_input
51
+ # Check if the user input is related to a programming topic
52
+ if any(topic.lower() in user_input.lower() for topic in developer_topics):
53
+ response = get_response(query)
54
+ st.write("### Response:")
55
+ st.write(response)
56
+ else:
57
+ st.write("Sorry, I can only answer programming-related questions.")
58
+ else:
59
+ st.write("Please enter a programming-related question or choose a topic.")
60
 
61
  if __name__ == "__main__":
62
  main()