File size: 2,152 Bytes
756bb52
 
 
 
 
e266c0b
 
756bb52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import streamlit as st
import google.generativeai as genai
import os

# Configure Google Gemini API
export API_KEY="AIzaSyBoPRKPvsVcMZ4e7HumwGEnfXLqee_WDBo"
genai.configure(api_key=os.environ["API_KEY"])

# Sidebar for input questions
st.sidebar.title("Prompt Engineering for AI Application")

# 1. Functionality of the AI application
functionality = st.sidebar.text_input(
    "What specific functionality do you want the AI application to have?",
    placeholder="e.g., image classification, text generation"
)

# 2. Preferred programming language or framework
language = st.sidebar.text_input(
    "What programming language or framework do you prefer to use?",
    placeholder="e.g., Python, TensorFlow"
)

# 3. Specific libraries, tools, or models
libraries = st.sidebar.text_input(
    "Are there any specific libraries, tools, or models you want to integrate?",
    placeholder="e.g., OpenAI's GPT, Whisper"
)

# 4. Input data or format
input_data = st.sidebar.text_input(
    "What input data or format will the application work with?",
    placeholder="e.g., text, images"
)

# 5. Specific requirements or constraints
requirements = st.sidebar.text_input(
    "Do you have any specific requirements or constraints for the output?",
    placeholder="e.g., performance, accuracy"
)

# Combine the user inputs into a prompt
prompt = f"""
Write a code to develop an AI application with the following details:
- Functionality: {functionality}
- Programming language or framework: {language}
- Specific libraries, tools, or models: {libraries}
- Input data or format: {input_data}
- Specific requirements or constraints: {requirements}
"""

# Main content
st.title("AI Code Generator using Google's Gemini Model")
st.write("Fill out the details in the sidebar to generate a proper prompt.")

if st.sidebar.button("Generate Code"):
    model = genai.GenerativeModel('gemini-1.5-flash')
    response = model.generate_content(prompt)
    st.subheader("Generated Code:")
    st.code(response.text, language='python')

# Footer
st.sidebar.write("---")
st.sidebar.write("This application helps you generate a prompt to write code for an AI application.")