Shahzad8515 commited on
Commit
756bb52
1 Parent(s): 20e072b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -0
app.py CHANGED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import google.generativeai as genai
3
+ import os
4
+
5
+ # Configure Google Gemini API
6
+ genai.configure(api_key=os.environ["AIzaSyBoPRKPvsVcMZ4e7HumwGEnfXLqee_WDBo"])
7
+
8
+ # Sidebar for input questions
9
+ st.sidebar.title("Prompt Engineering for AI Application")
10
+
11
+ # 1. Functionality of the AI application
12
+ functionality = st.sidebar.text_input(
13
+ "What specific functionality do you want the AI application to have?",
14
+ placeholder="e.g., image classification, text generation"
15
+ )
16
+
17
+ # 2. Preferred programming language or framework
18
+ language = st.sidebar.text_input(
19
+ "What programming language or framework do you prefer to use?",
20
+ placeholder="e.g., Python, TensorFlow"
21
+ )
22
+
23
+ # 3. Specific libraries, tools, or models
24
+ libraries = st.sidebar.text_input(
25
+ "Are there any specific libraries, tools, or models you want to integrate?",
26
+ placeholder="e.g., OpenAI's GPT, Whisper"
27
+ )
28
+
29
+ # 4. Input data or format
30
+ input_data = st.sidebar.text_input(
31
+ "What input data or format will the application work with?",
32
+ placeholder="e.g., text, images"
33
+ )
34
+
35
+ # 5. Specific requirements or constraints
36
+ requirements = st.sidebar.text_input(
37
+ "Do you have any specific requirements or constraints for the output?",
38
+ placeholder="e.g., performance, accuracy"
39
+ )
40
+
41
+ # Combine the user inputs into a prompt
42
+ prompt = f"""
43
+ Write a code to develop an AI application with the following details:
44
+ - Functionality: {functionality}
45
+ - Programming language or framework: {language}
46
+ - Specific libraries, tools, or models: {libraries}
47
+ - Input data or format: {input_data}
48
+ - Specific requirements or constraints: {requirements}
49
+ """
50
+
51
+ # Main content
52
+ st.title("AI Code Generator using Google's Gemini Model")
53
+ st.write("Fill out the details in the sidebar to generate a proper prompt.")
54
+
55
+ if st.sidebar.button("Generate Code"):
56
+ model = genai.GenerativeModel('gemini-1.5-flash')
57
+ response = model.generate_content(prompt)
58
+ st.subheader("Generated Code:")
59
+ st.code(response.text, language='python')
60
+
61
+ # Footer
62
+ st.sidebar.write("---")
63
+ st.sidebar.write("This application helps you generate a prompt to write code for an AI application.")