louiecerv's picture
updated forms
0870da0
raw
history blame
1.6 kB
import streamlit as st
import sqlite3
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_system_instruction(username, instruction):
conn = sqlite3.connect('users.db')
c = conn.cursor()
c.execute('SELECT * FROM system_instructions WHERE username=?', (username,))
existing_instruction = c.fetchone()
if existing_instruction:
c.execute('UPDATE system_instructions SET instruction=? WHERE username=?', (instruction, username))
else:
c.execute('INSERT INTO system_instructions(username, instruction) VALUES (?,?)', (username, instruction))
conn.commit()
conn.close()
def show_settings():
st.subheader("Settings")
username = st.session_state["username"]
system_instruction = get_system_instruction(username)
st.write("System Instruction:")
instruction = st.text_area("", value=system_instruction, height=200)
if st.button("Save Changes"):
save_system_instruction(username, instruction)
st.success("System instruction saved successfully.")
st.write("Note: System instruction is not used in this version of the app.")
if st.session_state["authenticated"]:
show_settings()
else:
if not st.session_state["is_starting"]:
st.write("You are not authenticated. Please log in to access this page.")