user_authentication / pages /Multimodal.py
louiecerv's picture
added the system instruction
03dba14
import streamlit as st
import sqlite3
from datetime import datetime
def get_system_instruction(username):
conn = sqlite3.connect('users.db')
c = conn.cursor()
c.execute('SELECT instruction FROM system_instructions WHERE username=?', (username,))
instruction = c.fetchone()
conn.close()
if instruction:
return instruction[0]
else:
return "Default system instruction."
def save_user_prompt(username, prompt_time, prompt_type):
conn = sqlite3.connect('users.db')
c = conn.cursor()
c.execute('INSERT INTO user_prompts(username, prompt_time, prompt_type) VALUES (?,?,?)', (username, prompt_time, prompt_type))
conn.commit()
conn.close()
def show_multimodal():
st.subheader("Multimodal")
username = st.session_state["username"]
system_instruction = get_system_instruction(username)
st.write("System Instruction:")
st.write(system_instruction)
prompt = st.text_input("Enter your prompt:")
if st.button("Ask AI"):
save_user_prompt(username, datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "Multimodal")
# Call AI model here
st.success("Prompt sent to AI model.")
if st.session_state["authenticated"]:
show_multimodal()
else:
if not st.session_state["is_starting"]:
st.write("You are not authenticated. Please log in to access this page.")