# last_ai_message_text

> **Function** in `langchain_azure_ai`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-ai/agents/hosting/_converters/_utils/last_ai_message_text)

Return the text content of the last ``AIMessage`` in *messages*.

Used by the default Invocations and non-streaming Responses converters
to surface the assistant's final answer after a graph run. When no
``AIMessage`` is present the function returns an empty string.

## Signature

```python
last_ai_message_text(
    messages: Iterable[Any],
) -> str
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `messages` | `Iterable[Any]` | Yes | An iterable of LangChain messages, typically the ``messages`` channel from a graph result. |

## Returns

`str`

The text content of the last ``AIMessage`` or ``""``.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/7a6a664d617264df8dcb12fcfb1bacc09f21d504/libs/azure-ai/langchain_azure_ai/agents/hosting/_converters/_utils.py#L112)