Azure / Azure/azure-sdk-for-python

Incorrect `unresolved-attribute` for Azure AI Inference's `ChatCompletionsClient`

Abierto
#45,339 2 comentarios 0 reacciones 1 asignado Reclamado por @dargilco Ver en GitHub
AI Model Inference customer-reported needs-team-attention question Service Attention
Lenguaje dominante
Python
Estrellas
5.6k
Forks
3.4k
Merge medio
2 d 2 h
PR fusionados (30 d)
213

Descripción

- **Package Name**: `azure-ai-inference`
- **Package Version**: `1.0.0b9`
- **Operating System**: Windows
- **Python Version**: `3.13`

**Describe the bug**

As stated [in this issue](https://github.com/astral-sh/ty/issues/2898), `ty` complains that `ChatCompletionsClient` does not have a `complete` attribute.

**To Reproduce**

Here's a minimal example that should show the problem in VS Code, or when doing `ty check`:

```python
from azure.ai.inference.aio import ChatCompletionsClient
from azure.ai.inference.models import UserMessage
from azure.core.credentials import AzureKeyCredential

async def mcp_client(token: str, prompt: str):
client = ChatCompletionsClient(
endpoint="https://models.github.ai/inference",
credential=AzureKeyCredential(token),
)
messages = [UserMessage(content=prompt)]
response = await client.complete(model="openai/gpt-4o-mini", messages=messages)
return response

if __name__ == "__main__":
import asyncio

token = "github_pat_###"
response = asyncio.run(mcp_client(token, "What is the capital of France?"))
print(response.choices[0].message.content)
```

**Expected behavior**

Since the class `ChatCompletionsClient` does have the `complete` attribute (and indeed, the code runs fine), this error should not happen. As mentioned in the referenced issue, it seems that this might be due to the particular implementation of the class.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.