mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Fix AI Search Tool Sample and improve AI Search Exceptions (#1206)
* Python: Fix AI Search Tool Sample and improve AI Search Exceptions * Python: Fix AI Search Tool Test --------- Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
e032fe3993
commit
350cdfc1cd
@@ -949,7 +949,7 @@ class AzureAIAgentClient(BaseChatClient):
|
||||
azs_conn_id = await self.project_client.connections.get_default(
|
||||
ConnectionType.AZURE_AI_SEARCH
|
||||
)
|
||||
except HttpResponseError as err:
|
||||
except ValueError as err:
|
||||
raise ServiceInitializationError(
|
||||
"No default Azure AI Search connection found in the Azure AI Project. "
|
||||
"Please create one or provide vector store inputs for the file search tool.",
|
||||
|
||||
@@ -1067,8 +1067,8 @@ async def test_azure_ai_chat_client_prep_tools_file_search_no_connection(mock_ai
|
||||
|
||||
file_search_tool = HostedFileSearchTool(additional_properties={"index_name": "test-index"})
|
||||
|
||||
# Mock connections.get_default to raise HttpResponseError
|
||||
mock_ai_project_client.connections.get_default = AsyncMock(side_effect=HttpResponseError("No connection found"))
|
||||
# Mock connections.get_default to raise ValueError
|
||||
mock_ai_project_client.connections.get_default = AsyncMock(side_effect=ValueError("No connection found"))
|
||||
|
||||
with pytest.raises(ServiceInitializationError, match="No default Azure AI Search connection found"):
|
||||
await chat_client._prep_tools([file_search_tool]) # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user