Azure / Azure/azure-sdk-for-python
Incorrect `unresolved-attribute` for Azure AI Inference's `ChatCompletionsClient`
- Lingua principale
- Python
- Stelle
- 5.6k
- Fork
- 3.4k
- Merge medio
- 2g
- PR unite (30g)
- 217
Descrizione
- **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.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.