shaadfazal's picture
Update app.py
db80a03 verified
import google.generativeai as genai
import streamlit as st
# Configure the Gemini API
genai.configure(api_key="AIzaSyCiaN2sysFQdEvucNdTawb0LgjdDSwcVN4")
# Load the prompt from the guidelines.txt file
def load_prompt():
try:
with open("guidelines.txt", "r", encoding="utf-8") as file:
return file.read().strip()
except Exception as e:
return f"Error loading prompt: {e}"
# Load the prompt
prompt = load_prompt()
# Function to interact with Gemini
def ask_gemini(query):
try:
full_query = prompt + "\n\nUser: " + query + "\nAssistant:"
model = genai.GenerativeModel("gemini-1.5-flash-latest")
response = model.generate_content(full_query)
return response.text.strip()
except Exception as e:
return f"Error: {e}"
# Streamlit UI
st.title("πŸ’¬ Kiki -- Your AI-based Humanoid Assistant")
st.write("Type your message below and get a response.")
# Text input
user_input = st.text_input("You:", "")
if user_input:
response = ask_gemini(user_input)
st.write("πŸ€– Kiki:", response)
st.write("πŸ”Ή Developed with Streamlit & Gemini AI.")