louiecerv commited on
Commit
03dba14
·
1 Parent(s): c74f24a

added the system instruction

Browse files
app.py CHANGED
@@ -20,11 +20,12 @@ from pages.Settings import show_settings
20
  if "authenticated" not in st.session_state:
21
  st.session_state["authenticated"] = False
22
 
23
- # --- Database functions ---
24
  def create_usertable():
25
  conn = sqlite3.connect('users.db')
26
  c = conn.cursor()
27
  c.execute('CREATE TABLE IF NOT EXISTS userstable(username TEXT, password TEXT)')
 
 
28
  conn.commit()
29
  conn.close()
30
 
 
20
  if "authenticated" not in st.session_state:
21
  st.session_state["authenticated"] = False
22
 
 
23
  def create_usertable():
24
  conn = sqlite3.connect('users.db')
25
  c = conn.cursor()
26
  c.execute('CREATE TABLE IF NOT EXISTS userstable(username TEXT, password TEXT)')
27
+ c.execute('CREATE TABLE IF NOT EXISTS system_instructions(username TEXT PRIMARY KEY, instruction TEXT)')
28
+ c.execute('CREATE TABLE IF NOT EXISTS user_prompts(id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT, prompt_time TEXT, prompt_type TEXT)')
29
  conn.commit()
30
  conn.close()
31
 
pages/Multimodal.py CHANGED
@@ -1,9 +1,36 @@
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def show_multimodal():
4
- st.title("Multimodal")
5
- # Add your Multimodal page content here
6
- st.write("This is the Multimodal page.")
 
 
 
 
 
 
 
7
 
8
  if st.session_state["authenticated"]:
9
  show_multimodal()
 
1
  import streamlit as st
2
+ import sqlite3
3
+ from datetime import datetime
4
+
5
+ def get_system_instruction(username):
6
+ conn = sqlite3.connect('users.db')
7
+ c = conn.cursor()
8
+ c.execute('SELECT instruction FROM system_instructions WHERE username=?', (username,))
9
+ instruction = c.fetchone()
10
+ conn.close()
11
+ if instruction:
12
+ return instruction[0]
13
+ else:
14
+ return "Default system instruction."
15
+
16
+ def save_user_prompt(username, prompt_time, prompt_type):
17
+ conn = sqlite3.connect('users.db')
18
+ c = conn.cursor()
19
+ c.execute('INSERT INTO user_prompts(username, prompt_time, prompt_type) VALUES (?,?,?)', (username, prompt_time, prompt_type))
20
+ conn.commit()
21
+ conn.close()
22
 
23
  def show_multimodal():
24
+ st.subheader("Multimodal")
25
+ username = st.session_state["username"]
26
+ system_instruction = get_system_instruction(username)
27
+ st.write("System Instruction:")
28
+ st.write(system_instruction)
29
+ prompt = st.text_input("Enter your prompt:")
30
+ if st.button("Ask AI"):
31
+ save_user_prompt(username, datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "Multimodal")
32
+ # Call AI model here
33
+ st.success("Prompt sent to AI model.")
34
 
35
  if st.session_state["authenticated"]:
36
  show_multimodal()
pages/Settings.py CHANGED
@@ -1,9 +1,38 @@
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def show_settings():
4
- st.title("Settings")
5
- # Add your Settings page content here
6
- st.write("This is the Settings page.")
 
 
 
 
 
7
 
8
  if st.session_state["authenticated"]:
9
  show_settings()
 
1
  import streamlit as st
2
+ import sqlite3
3
+
4
+ def get_system_instruction(username):
5
+ conn = sqlite3.connect('users.db')
6
+ c = conn.cursor()
7
+ c.execute('SELECT instruction FROM system_instructions WHERE username=?', (username,))
8
+ instruction = c.fetchone()
9
+ conn.close()
10
+ if instruction:
11
+ return instruction[0]
12
+ else:
13
+ return "Default system instruction."
14
+
15
+ def save_system_instruction(username, instruction):
16
+ conn = sqlite3.connect('users.db')
17
+ c = conn.cursor()
18
+ c.execute('SELECT * FROM system_instructions WHERE username=?', (username,))
19
+ existing_instruction = c.fetchone()
20
+ if existing_instruction:
21
+ c.execute('UPDATE system_instructions SET instruction=? WHERE username=?', (instruction, username))
22
+ else:
23
+ c.execute('INSERT INTO system_instructions(username, instruction) VALUES (?,?)', (username, instruction))
24
+ conn.commit()
25
+ conn.close()
26
 
27
  def show_settings():
28
+ st.subheader("Settings")
29
+ username = st.session_state["username"]
30
+ system_instruction = get_system_instruction(username)
31
+ st.write("System Instruction:")
32
+ instruction = st.text_area("", value=system_instruction, height=200)
33
+ if st.button("Save Changes"):
34
+ save_system_instruction(username, instruction)
35
+ st.success("System instruction saved successfully.")
36
 
37
  if st.session_state["authenticated"]:
38
  show_settings()
pages/Text_prompt.py CHANGED
@@ -1,9 +1,36 @@
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def show_text_prompt():
4
- st.title("Text Prompt")
5
- # Add your Text Prompt page content here
6
- st.write("This is the Text Prompt page.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  if st.session_state["authenticated"]:
9
  show_text_prompt()
 
1
  import streamlit as st
2
+ import sqlite3
3
+ from datetime import datetime
4
+
5
+ def get_system_instruction(username):
6
+ conn = sqlite3.connect('users.db')
7
+ c = conn.cursor()
8
+ c.execute('SELECT instruction FROM system_instructions WHERE username=?', (username,))
9
+ instruction = c.fetchone()
10
+ conn.close()
11
+ if instruction:
12
+ return instruction[0]
13
+ else:
14
+ return "Default system instruction."
15
 
16
  def show_text_prompt():
17
+ st.subheader("Text Prompt")
18
+ username = st.session_state["username"]
19
+ system_instruction = get_system_instruction(username)
20
+ st.write("System Instruction:")
21
+ st.write(system_instruction)
22
+ prompt = st.text_input("Enter your prompt:")
23
+ if st.button("Ask AI"):
24
+ save_user_prompt(username, datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "Text Prompt")
25
+ # Call AI model here
26
+ st.success(f"Prompt {prompt} sent to AI model.")
27
+
28
+ def save_user_prompt(username, prompt_time, prompt_type):
29
+ conn = sqlite3.connect('users.db')
30
+ c = conn.cursor()
31
+ c.execute('INSERT INTO user_prompts(username, prompt_time, prompt_type) VALUES (?,?,?)', (username, prompt_time, prompt_type))
32
+ conn.commit()
33
+ conn.close()
34
 
35
  if st.session_state["authenticated"]:
36
  show_text_prompt()
pages/__pycache__/Multimodal.cpython-313.pyc CHANGED
Binary files a/pages/__pycache__/Multimodal.cpython-313.pyc and b/pages/__pycache__/Multimodal.cpython-313.pyc differ
 
pages/__pycache__/Settings.cpython-313.pyc CHANGED
Binary files a/pages/__pycache__/Settings.cpython-313.pyc and b/pages/__pycache__/Settings.cpython-313.pyc differ
 
pages/__pycache__/Text_prompt.cpython-313.pyc CHANGED
Binary files a/pages/__pycache__/Text_prompt.cpython-313.pyc and b/pages/__pycache__/Text_prompt.cpython-313.pyc differ
 
users.db CHANGED
Binary files a/users.db and b/users.db differ