All skills
microsoft avatar

/azure-ai-language-conversations-py

@4a2873f
by microsoftmicrosoft/skills3.1k stars
351

Implement Conversational Language Understanding (CLU) using the azure-ai-language-conversations Python SDK. Use when working with ConversationAnalysisClient to analyze conversation intent and entities, building NLP features, or integrating language understanding into applications.

Use this Skill: https://skilld.dev/gh/microsoft/skills/azure-ai-language-conversations-py

This session only. Nothing lands on disk.

referencesnon-hero-scenarios.md

≈1.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

azure-ai-language-conversations-py non-hero scenarios

These scenarios are intentionally separate from hero flows in SKILL.md. They cover secondary/advanced patterns typically used after the primary end-to-end path is working.

Operational hardening

Retry Policy

Configure retries for transient service errors:

import os
from azure.identity import DefaultAzureCredential
from azure.ai.language.conversations import ConversationAnalysisClient
from azure.core.pipeline.policies import RetryPolicy

retry_policy = RetryPolicy(retry_total=3, retry_backoff_factor=2)
credential = DefaultAzureCredential()

with ConversationAnalysisClient(
    os.environ["AZURE_CONVERSATIONS_ENDPOINT"],
    credential,
    retry_policy=retry_policy,
) as client:
    result = client.analyze_conversation(
        task={
            "kind": "Conversation",
            "analysisInput": {
                "conversationItem": {
                    "participantId": "1",
                    "id": "1",
                    "modality": "text",
                    "language": "en",
                    "text": "Set an alarm for 7am tomorrow",
                },
                "isLoggingEnabled": False,
            },
            "parameters": {
                "projectName": os.environ["AZURE_CONVERSATIONS_PROJECT"],
                "deploymentName": os.environ["AZURE_CONVERSATIONS_DEPLOYMENT"],
            },
        }
    )

Entity Extraction and Confidence Filtering

Access predicted entities and skip low-confidence results:

import os
from azure.identity import DefaultAzureCredential
from azure.ai.language.conversations import ConversationAnalysisClient

MIN_CONFIDENCE = 0.7

credential = DefaultAzureCredential()

with ConversationAnalysisClient(
    os.environ["AZURE_CONVERSATIONS_ENDPOINT"], credential
) as client:
    result = client.analyze_conversation(
        task={
            "kind": "Conversation",
            "analysisInput": {
                "conversationItem": {
                    "participantId": "1",
                    "id": "1",
                    "modality": "text",
                    "language": "en",
                    "text": "Book a flight to London next Monday",
                },
                "isLoggingEnabled": False,
            },
            "parameters": {
                "projectName": os.environ["AZURE_CONVERSATIONS_PROJECT"],
                "deploymentName": os.environ["AZURE_CONVERSATIONS_DEPLOYMENT"],
                "verbose": True,
            },
        }
    )

    prediction = result["result"]["prediction"]
    top_intent = prediction["topIntent"]
    confidence = next(
        i["confidenceScore"]
        for i in prediction["intents"]
        if i["category"] == top_intent
    )

    if confidence < MIN_CONFIDENCE:
        print(f"Low confidence ({confidence:.2f}) — ask for clarification")
    else:
        print(f"Intent: {top_intent} ({confidence:.2f})")
        for entity in prediction.get("entities", []):
            print(f"  Entity: {entity['category']} = {entity['text']}")

Orchestration Workflow Routing

When the CLU project is an orchestration project, route to the target skill:

result = client.analyze_conversation(
    task={
        "kind": "Conversation",
        "analysisInput": {
            "conversationItem": {
                "participantId": "1",
                "id": "1",
                "modality": "text",
                "language": "en",
                "text": "What's the weather like today?",
            },
            "isLoggingEnabled": False,
        },
        "parameters": {
            "projectName": os.environ["AZURE_ORCHESTRATION_PROJECT"],
            "deploymentName": os.environ["AZURE_ORCHESTRATION_DEPLOYMENT"],
        },
    }
)

prediction = result["result"]["prediction"]
top_intent = prediction["topIntent"]

# Orchestration: prediction['intents'] is a dict keyed by intent name
intent_data = prediction["intents"].get(top_intent, {})
target_kind = intent_data.get("targetProjectKind")  # e.g. "Luis" or "Conversation"
print(f"Routed to: {top_intent} ({target_kind})")

Async Client

Use the async client for concurrent request handling:

import os
from azure.identity.aio import DefaultAzureCredential
from azure.ai.language.conversations.aio import ConversationAnalysisClient

async def analyze_async(text: str) -> dict:
    async with DefaultAzureCredential() as credential:
        async with ConversationAnalysisClient(
            os.environ["AZURE_CONVERSATIONS_ENDPOINT"], credential
        ) as client:
            result = await client.analyze_conversation(
                task={
                    "kind": "Conversation",
                    "analysisInput": {
                        "conversationItem": {
                            "participantId": "1",
                            "id": "1",
                            "modality": "text",
                            "language": "en",
                            "text": text,
                        },
                        "isLoggingEnabled": False,
                    },
                    "parameters": {
                        "projectName": os.environ["AZURE_CONVERSATIONS_PROJECT"],
                        "deploymentName": os.environ["AZURE_CONVERSATIONS_DEPLOYMENT"],
                    },
                }
            )
            return result["result"]["prediction"]

Source: SKILL.md on GitHub

1 warning15d4 checks · Risk SAFE
  • Gen Agent Trust Hub15d

    This skill implements Azure AI Language Conversations using official Microsoft SDKs and follows established security best practices for credential management. It includes considerations for processing external user input for NLP analysis, which is the skill's primary function.

  • Socket15d

    No alerts

  • Snyk15d

    Risk: LOW · No issues

  • Runlayer6mo

    2/2 files flagged

Signed by skilld at 4a2873f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 months ago
metadata
{
  "author": "Microsoft",
  "version": "1.0.0"
}

README badge

README badge for microsoft/skills/azure-ai-language-conversations-py