Azure / Azure/azure-sdk-for-python
azure-ai-inference : LangChain `AzureAIChatCompletionsModel` Does Not Support OpenAI-Style JSON Schema Format
- Lingua principale
- Python
- Stelle
- 5.6k
- Fork
- 3.4k
- Merge medio
- 2g 2h
- PR unite (30g)
- 202
Descrizione
- Issue description
When using `langchain_azure_ai.AzureAIChatCompletionsModel` with structured output (e.g., create_agent(..., response_format=ProviderStrategy()...), the integration fails with:
`ValueError: Unsupported `response_format` {'type': 'json_schema', 'json_schema': {...}}`
This occurs in `azure/ai/inference/_patch.py`
- Steps to Reproduce
```
from langchain_azure_ai.chat_models import AzureAIChatCompletionsModel
from pydantic import BaseModel, Field
import os
llm = AzureAIChatCompletionsModel(
endpoint=os.getenv("GITHUB_INFERENCE_ENDPOINT"),
credential=os.getenv("GITHUB_TOKEN"),
model="gpt-4o",
)
class ContactInfo(BaseModel):
name: str = Field(description="The name of the person")
email: str = Field(description="The email of the person")
phone: str = Field(description="The phone number of the person")
agent = create_agent(
model = gllm_4_1,
tools = [search_tool],
response_format=ProviderStrategy(ContactInfo)
)
agent.invoke({"messages": [HumanMessage(content="Extract contact info from: John Doe, john@example.com, (555) 123-4567")]})
```
- Alternatives considered
Use `langchain-openai` instead, which treats Azure-compatible endpoints as OpenAI endpoints.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia riproducendo l'esempio di output strutturato e ispeziona azure/ai/inference/_patch.py, dove si verifica l'errore di response_format non supportato. Traccia il modo in cui viene convalidato il formato json_schema in stile OpenAI-style, quindi verifica che AzureAIChatCompletionsModel accetti il formato e che l'invocazione dell'output strutturato venga completata senza il ValueError.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- api
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100