BobyMaurya455 commited on
Commit
3403463
·
verified ·
1 Parent(s): 7b164e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -46
app.py CHANGED
@@ -1,46 +1,48 @@
1
- #genai.configure(api_key="AIzaSyB2FrTywdRUmHXICxRPYTN_TznajASTKDY")
2
-
3
- import streamlit as st
4
- import google.generativeai as genai
5
-
6
- # Configure the API key for Gemini AI
7
- genai.configure(api_key="AIzaSyB2FrTywdRUmHXICxRPYTN_TznajASTKDY")
8
- model = genai.GenerativeModel("gemini-1.5-flash")
9
-
10
- # Streamlit App layout
11
- st.title("AI-Powered Python Code Assistant")
12
- st.markdown("This assistant can help you with code suggestions, debugging, and reusable snippets using Gemini AI.")
13
-
14
- # Sidebar
15
- st.sidebar.header("Select Feature")
16
- feature = st.sidebar.selectbox(
17
- "Choose what you need help with:",
18
- ["Code Suggestions", "Code Debugging", "Reusable Code Snippets", "General Code Query"]
19
- )
20
-
21
- # Input box for user to type code or query
22
- user_input = st.text_area("Enter your Python code or query here:")
23
-
24
- # Button to trigger the AI response
25
- if st.button("Get AI Suggestions"):
26
-
27
- # Generate response based on selected feature
28
- if feature == "Code Suggestions":
29
- prompt = f"Suggest code completion for the following Python code:\n{user_input}"
30
- elif feature == "Code Debugging":
31
- prompt = f"Find and fix the bugs in the following Python code:\n{user_input}"
32
- elif feature == "Reusable Code Snippets":
33
- prompt = f"Provide reusable Python code snippets related to: {user_input}"
34
- else:
35
- prompt = f"Provide an explanation or advice on this Python code/query:\n{user_input}"
36
-
37
- # Get response from Gemini AI model
38
- response = model.generate_content(prompt)
39
-
40
- # Display AI's response in the app
41
- st.subheader("AI's Response:")
42
- st.code(response.text, language="python")
43
-
44
- # Optionally, you can add a footer or additional features here
45
- st.markdown("---")
46
- st.markdown("Powered by **Streamlit** and **Google Gemini AI**")
 
 
 
1
+ #genai.configure(api_key="AIzaSyB2FrTywdRUmHXICxRPYTN_TznajASTKDY")
2
+
3
+ import streamlit as st
4
+ import google.generativeai as genai
5
+
6
+ # Configure the API key for Gemini AI
7
+ genai.configure(api_key="AIzaSyD8tAz466UNCkLl83WBT05imim-JYL5Gr4")
8
+
9
+ # AIzaSyB2FrTywdRUmHXICxRPYTN_TznajASTKDY
10
+ model = genai.GenerativeModel("gemini-1.5-flash")
11
+
12
+ # Streamlit App layout
13
+ st.title("AI-Powered Python Code Assistant")
14
+ st.markdown("This assistant can help you with code suggestions, debugging, and reusable snippets using Gemini AI.")
15
+
16
+ # Sidebar
17
+ st.sidebar.header("Select Feature")
18
+ feature = st.sidebar.selectbox(
19
+ "Choose what you need help with:",
20
+ ["Code Suggestions", "Code Debugging", "Reusable Code Snippets", "General Code Query"]
21
+ )
22
+
23
+ # Input box for user to type code or query
24
+ user_input = st.text_area("Enter your Python code or query here:")
25
+
26
+ # Button to trigger the AI response
27
+ if st.button("Get AI Suggestions"):
28
+
29
+ # Generate response based on selected feature
30
+ if feature == "Code Suggestions":
31
+ prompt = f"Suggest code completion for the following Python code:\n{user_input}"
32
+ elif feature == "Code Debugging":
33
+ prompt = f"Find and fix the bugs in the following Python code:\n{user_input}"
34
+ elif feature == "Reusable Code Snippets":
35
+ prompt = f"Provide reusable Python code snippets related to: {user_input}"
36
+ else:
37
+ prompt = f"Provide an explanation or advice on this Python code/query:\n{user_input}"
38
+
39
+ # Get response from Gemini AI model
40
+ response = model.generate_content(prompt)
41
+
42
+ # Display AI's response in the app
43
+ st.subheader("AI's Response:")
44
+ st.code(response.text, language="python")
45
+
46
+ # Optionally, you can add a footer or additional features here
47
+ st.markdown("---")
48
+ st.markdown("Powered by **Streamlit** and **Google Gemini AI**")