![]() ![]() execute( 'SELECT id FROM chat_prompts_tags WHERE tag = ?', ( tag,))Ĭ. execute( 'INSERT INTO chat_prompts_tags (tag) VALUES (?)', ( tag,))Ĭ. execute( 'INSERT INTO chat_prompts (title, slug, prompt, hash, variables, notes) VALUES (?, ?, ?, ?, ?, ?)', ( title, sluggify( title), prompt, generate_hash( prompt), None if ( variables is None or variables = ) else json. _validate_prompt( prompt, variables), 'Invalid prompt'Ĭ. replace( ' ', '_') + '*' not in prompt:ĭef add_prompt( self, title: str, prompt: str, tags: list = None, variables: list =, notes: str = None) -> int:Īssert self. # Commit the changes and close the connectionĭef _validate_prompt( self, prompt: str, variables: list = ) -> bool: # If any of the tables don't exist, create themĬreated_at DATETIME DEFAULT CURRENT_TIMESTAMP,įOREIGN KEY (tag_id) REFERENCES chat_prompts_tags(id),įOREIGN KEY (prompt_id) REFERENCES chat_prompts(id) SELECT name FROM sqlite_master WHERE type='table' AND name='chat_prompts_tags_map' Ĭhat_prompts_tags_map_exists = cursor. # Check if the chat_prompts_tags_map table exists SELECT name FROM sqlite_master WHERE type='table' AND name='chat_prompts_tags' Ĭhat_prompts_tags_exists = cursor. # Check if the chat_prompts_tags table exists SELECT name FROM sqlite_master WHERE type='table' AND name='chat_prompts' Ĭhat_prompts_exists = cursor. If None, will use the environmentĭatabase = os. # Use the sha256 hash function from the hashlib library to generate the hashĭef _init_( self, database: str = None) -> None:ĭatabase (str): SQLite database file. # Create a function to generate the hash of the prompt
0 Comments
Leave a Reply. |