sempy_labs.rti package

Module contents

sempy_labs.rti.nl_to_kql(kql_database: str | UUID, billing_item: str | UUID, billing_item_type: Literal['KQLQueryset', 'KQLDashboard', 'Eventhouse'], prompt: str, chat_messages: dict | List[dict] | None = None, user_shots: List[dict] | None = None, workspace: str | UUID | None = None) str

Returns a KQL query generated from natural language.

This is a wrapper function for the following API: Copilot - NL To KQL.

Service Principal Authentication is supported (see here for examples).

Parameters:
  • kql_database (str | uuid.UUID) – The name or UUID of the KQL database.

  • billing_item (str | uuid.UUID) – The name or ID of the item for the request. This can be a KQLQueryset, KQLDashboard, or Eventhouse item. This item is used for billing the request.

  • billing_item_type (Literal["KQLQueryset", "KQLDashboard", "Eventhouse"]) – The type of the billing item.

  • prompt (str) – The natural language to generate the KQL query from.

  • chat_messages (Optional[str | List[str]], default=None) –

    The chat messages for the request. The chat messages provide additional context for generating the KQL query if necessary.

    Example:
    chat_messages = [
    {

    “content”: “Content….”, “role”: “User”

    }, {

    ”content”: “Content…”, “role”: “Assistant”

    }

    ]

  • user_shots (Optional[List[str]], default=None) –

    The user shots for the request. This consists of user provided pairs of natural language and KQL queries in order to help in generating the current requested KQL query.

    Example:
    user_shots = [
    {

    “kqlQuery”: “KQL Query….”, “naturalLanguage”: “Natural language….”

    }, {

    ”kqlQuery”: “KQL Query…”, “naturalLanguage”: “Natural language…”

    }

    ]

  • workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The generated KQL query.

Return type:

str