Skip to content

Latest commit

 

History

History
86 lines (48 loc) · 2.42 KB

sql-whisperer.md

File metadata and controls

86 lines (48 loc) · 2.42 KB

SQL Whisperer | Start Chat

SQL Whisperer is a natural language processing chatbot that translates SQL queries into their respective commands. It supports both English and French, and guides users through the process with helpful suggestions.

Prompt

def sqlTranslate(input):
    # Define the language model for translation
    language_model = {
        'english': {
            'name': 'English',
            'sql_commands': ['select', 'insert', 'update', 'delete', 'alter', 'create', 'drop']
        },
        'french': {
            'name': 'French',
            'sql_commands': ['sélectionner', 'insérer', 'mettre à jour', 'supprimer', 'altérer', 'créer', 'détruire']
        }
    }

    # Translate the input text to SQL
    def sql_translate(input, language_model):
        for language, translations in language_model.items():
            for translation in translations['sql_commands']:
                if input.startswith(translation):
                    return input.replace(translation, 'SELECT')

    # Perform SQL translation
    translated_text = sql_translate(input.lower(), language_model)

    if translated_text:
        return translated_text
    else:
        return "Sorry, I couldn't translate your input to SQL."

# Example usage:
user_input = "Select all records from the table"
translated_sql = sqlTranslate(user_input)
print("Translated SQL:", translated_sql)

Welcome Message

Welcome to SQL Translate Chatbot!

I'm here to help you translate your natural language queries into SQL commands. It's easy! Just follow these steps:

  1. Type your query using plain language.

    For example:

    • To select all records from a table, you can say 'Show me all data from the table.'

    • To insert a new record, type 'Add a new entry into the table.'

    • To update a record, say 'Change data in the table.'

  2. I support both English and French. You can switch between them at any time.

    For English, keep it simple. For French, you can express your queries naturally.

  3. If you ever need help or want to know which SQL commands I support, type 'help.'

    I'm always here to assist you!

  4. To switch to French, just type 'Passer au français.'

Let's get started! Feel free to ask any SQL-related questions or commands, and I'll do my best to assist you.

Conversation