Dua Rajper commited on
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
from google import genai
|
| 4 |
+
from google.genai import types
|
| 5 |
+
from kaggle_secrets import UserSecretsClient
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
# Get API key from environment variables
|
| 9 |
+
GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
|
| 10 |
+
|
| 11 |
+
# Initialize GenAI client
|
| 12 |
+
client = genai.Client(api_key=GOOGLE_API_KEY)
|
| 13 |
+
|
| 14 |
+
# Define functions for different functionalities
|
| 15 |
+
# ... (Include your code snippets here, refactoring as needed) ...
|
| 16 |
+
|
| 17 |
+
# Example function from your code
|
| 18 |
+
def generate_text(prompt):
|
| 19 |
+
response = client.models.generate_content(
|
| 20 |
+
model="gemini-2.0-flash",
|
| 21 |
+
contents=prompt
|
| 22 |
+
)
|
| 23 |
+
return response.text
|
| 24 |
+
|
| 25 |
+
# Streamlit interface
|
| 26 |
+
st.title("My GenAI App")
|
| 27 |
+
user_input = st.text_input("Enter your prompt:")
|
| 28 |
+
if user_input:
|
| 29 |
+
output = generate_text(user_input)
|
| 30 |
+
st.write(output)
|