File size: 1,129 Bytes
a674611
 
 
 
 
 
db80a03
 
 
 
 
 
 
 
 
 
a674611
 
 
 
 
 
 
 
 
 
 
 
db80a03
a674611
 
 
 
 
 
 
 
 
 
 
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
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.")