K00B404 commited on
Commit
6f42e1d
·
verified ·
1 Parent(s): f6a20fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -2
app.py CHANGED
@@ -36,7 +36,7 @@ def fetch_logs(file_path):
36
  conn = sqlite3.connect(file_path)
37
  cursor = conn.cursor()
38
 
39
- cursor.execute("SELECT * FROM logs;") # Adjust this query based on your table schema
40
  logs = cursor.fetchall()
41
 
42
  for log in logs:
@@ -70,9 +70,48 @@ def init_db(file='logs.db'):
70
  conn.commit()
71
  conn.close()
72
  print("table made")
 
 
 
 
 
 
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  # Log a request
75
- def log_request(prompt, is_negative, steps, cfg_scale, sampler, seed, strength, use_dev,
76
  enhance_prompt_style, enhance_prompt_option, nemo_enhance_prompt_style, use_mistral_nemo):
77
  conn = sqlite3.connect('logs.db')
78
  c = conn.cursor()
 
36
  conn = sqlite3.connect(file_path)
37
  cursor = conn.cursor()
38
 
39
+ cursor.execute("SELECT * FROM logs2;") # Adjust this query based on your table schema
40
  logs = cursor.fetchall()
41
 
42
  for log in logs:
 
70
  conn.commit()
71
  conn.close()
72
  print("table made")
73
+
74
+ def log_request(prompt, is_negative, steps, cfg_scale, sampler, seed, strength, use_dev, enhance_prompt_style, enhance_prompt_option, nemo_enhance_prompt_style, use_mistral_nemo, huggingface_api_key):
75
+ try:
76
+ # Connect to the SQLite database
77
+ conn = sqlite3.connect('log.db') # Make sure this path is correct
78
+ cursor = conn.cursor()
79
 
80
+ # Create the table if it doesn't exist
81
+ cursor.execute('''
82
+ CREATE TABLE IF NOT EXISTS logs2 (
83
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
84
+ prompt TEXT,
85
+ is_negative INTEGER,
86
+ steps INTEGER,
87
+ cfg_scale REAL,
88
+ sampler TEXT,
89
+ seed INTEGER,
90
+ strength REAL,
91
+ use_dev INTEGER,
92
+ enhance_prompt_style TEXT,
93
+ enhance_prompt_option INTEGER,
94
+ nemo_enhance_prompt_style TEXT,
95
+ use_mistral_nemo INTEGER,
96
+ huggingface_api_key TEXT
97
+ )
98
+ ''')
99
+
100
+ # Insert the log entry
101
+ cursor.execute('''
102
+ INSERT INTO logs2 (
103
+ prompt, is_negative, steps, cfg_scale, sampler, seed, strength, use_dev, enhance_prompt_style, enhance_prompt_option, nemo_enhance_prompt_style, use_mistral_nemo, huggingface_api_key
104
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
105
+ ''', (prompt, is_negative, steps, cfg_scale, sampler, seed, strength, use_dev, enhance_prompt_style, enhance_prompt_option, nemo_enhance_prompt_style, use_mistral_nemo, huggingface_api_key))
106
+
107
+ # Commit the changes and close the connection
108
+ conn.commit()
109
+ conn.close()
110
+ except Exception as e:
111
+ print(f"Error logging request: {e}")
112
+
113
  # Log a request
114
+ def log_requestold(prompt, is_negative, steps, cfg_scale, sampler, seed, strength, use_dev,
115
  enhance_prompt_style, enhance_prompt_option, nemo_enhance_prompt_style, use_mistral_nemo):
116
  conn = sqlite3.connect('logs.db')
117
  c = conn.cursor()