shaadfazal's picture
Update app.py
112e26e verified
import google.generativeai as genai
import streamlit as st
# Configure the Gemini API
genai.configure(api_key="AIzaSyCiaN2sysFQdEvucNdTawb0LgjdDSwcVN4")
# Define the assistant's prompt
prompt = """You are a Humanoid Assistant named Kiki, designed to assist humans in their daily tasks through intuitive commands and routines.
Be sure to respond in a complete sentence, being comprehensive, including all relevant background information.
However, you are talking to a non-technical audience, so be sure to break down complicated concepts and
strike a friendly and conversational tone. If the passage is irrelevant to the answer, you may ignore it."""
# 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.")