Skip to content

AzureAISearchTool - Object has no attribute 'semantic_config_name' #6430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
StellaSource-Carlisle opened this issue Apr 29, 2025 · 12 comments · Fixed by #6511
Closed

AzureAISearchTool - Object has no attribute 'semantic_config_name' #6430

StellaSource-Carlisle opened this issue Apr 29, 2025 · 12 comments · Fixed by #6511

Comments

@StellaSource-Carlisle
Copy link

What happened?

Bug Description
When attempting to run the AzureAISearchTool.create_hybrid_search(), we are receiving the error message ValueError: Error from Azure AI Search: 'AzureAISearchConfig' object has no attribute 'semantic_config_name'

To Reproduce

_cog_search_tool = AzureAISearchTool.create_hybrid_search(
    name="call_cog_search",
    endpoint=_settings.COG_SEARCH_ENDPOINT,
    index_name=_settings.COG_SEARCH_INDEX,
    credential=AzureKeyCredential(_settings.COG_SEARCH_KEY),
    vector_fields=["description_vector"],
    search_fields=["v_description", "description"],
    select_fields=[
        "product_id",
        "product_description",
        "dims"
    ],
    top=7
)

We have attempted to set the semantic_config_name explicitly to None to no avail.

Expected behavior
The AzureAISearchTool is able to hit the CogSearch endpoint and aggregate the results.

Additional context
Attempted versions 0.5.2 - 0.5.5. Issues remains across all versions.

Which packages was the bug in?

Python Extensions (autogen-ext)

AutoGen library version.

Python 0.5.5

Other library version.

No response

Model used

No response

Model provider

Azure OpenAI

Other model provider

No response

Python version

3.13

.NET version

None

Operating system

MacOS

@ekzhu
Copy link
Collaborator

ekzhu commented Apr 29, 2025

@jay-thakur for awareness

@jay-thakur
Copy link
Contributor

ack

@StellaSource-Carlisle
Copy link
Author

Full stack trace of the error when running. (Hope it's helpful)

2025-04-29 14:13:11 [ERROR] ai.tools.cog_search_tool: 🔍 [Cog-ERROR] - {}
ai-1  | Traceback (most recent call last):
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/autogen_ext/tools/azure/_ai_search.py", line 354, in run
ai-1  |     if self.search_config.query_type == "fulltext" and self.search_config.semantic_config_name is not None:
ai-1  |                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/pydantic/main.py", line 994, in __getattr__
ai-1  |     raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
ai-1  | AttributeError: 'AzureAISearchConfig' object has no attribute 'semantic_config_name'
ai-1  | 
ai-1  | The above exception was the direct cause of the following exception:
ai-1  | 
ai-1  | Traceback (most recent call last):
ai-1  |   File "/app/ai/tools/cog_search_tool.py", line 46, in call_cog_search_async
ai-1  |     results = await _cog_search_tool.run({"query": mappedString})
ai-1  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/autogen_ext/tools/azure/_ai_search.py", line 474, in run
ai-1  |     raise ValueError(f"Error from Azure AI Search: {error_msg}") from e

@jay-thakur
Copy link
Contributor

thank you so much for sharing the stack trace @StellaSource-Carlisle. I am working on it.

@jay-thakur
Copy link
Contributor

Hi @StellaSource-Carlisle,

Could you please try below and let me know the output ?

query_type="semantic",
semantic_config_name ="default"

and

query_type="simple",
semantic_config_name ="default"

@StellaSource-Carlisle
Copy link
Author

StellaSource-Carlisle commented May 6, 2025

Hi @StellaSource-Carlisle,

Could you please try below and let me know the output ?

query_type="semantic",
semantic_config_name ="default"

and

query_type="simple",
semantic_config_name ="default"

Sure thing @jay-thakur . See below for the results of those requested changes.

_cog_search_tool = AzureAISearchTool.create_hybrid_search(
    name="call_cog_search_async",
    endpoint=_settings.COG_SEARCH_ENDPOINT,
    index_name=_settings.COG_SEARCH_INDEX,
    credential=AzureKeyCredential(_settings.COG_SEARCH_KEY),
    vector_fields=["description_vector"],
    search_fields=["variant_description", "description"],
    select_fields=[
        "product_variant_id",
        "product_description",
        "Dimensions"
    ],
    top=7,
    query_type="semantic",
    semantic_config_name ="default"
)

Resulted in:

ai-1  |     from ai.tools.cog_search_tool      import call_cog_search_async      # step-2
ai-1  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/ai/tools/cog_search_tool.py", line 15, in <module>
ai-1  |     _cog_search_tool = AzureAISearchTool.create_hybrid_search(
ai-1  |         name="call_cog_search_async",
ai-1  |     ...<12 lines>...
ai-1  |         semantic_config_name ="default"
ai-1  |     )
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/autogen_ext/tools/azure/_ai_search.py", line 1099, in create_hybrid_search
ai-1  |     return cls(
ai-1  |         name=name,
ai-1  |     ...<9 lines>...
ai-1  |         **kwargs,
ai-1  |     )
ai-1  | TypeError: autogen_ext.tools.azure._ai_search.AzureAISearchTool() got multiple values for keyword argument 'query_type'

_cog_search_tool = AzureAISearchTool.create_hybrid_search(
    name="call_cog_search_async",
    endpoint=_settings.COG_SEARCH_ENDPOINT,
    index_name=_settings.COG_SEARCH_INDEX,
    credential=AzureKeyCredential(_settings.COG_SEARCH_KEY),
    vector_fields=["description_vector"],
    search_fields=["variant_description", "description"],
    select_fields=[
        "product_variant_id",
        "product_description",
        "Dimensions"
    ],
    top=7,
    query_type="simple",
    semantic_config_name ="default"
)

Resulted in:

ai-1  |     from ai.tools.cog_search_tool      import call_cog_search_async      # step-2
ai-1  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/ai/tools/cog_search_tool.py", line 15, in <module>
ai-1  |     _cog_search_tool = AzureAISearchTool.create_hybrid_search(
ai-1  |         name="call_cog_search_async",
ai-1  |     ...<12 lines>...
ai-1  |     semantic_config_name ="default"
ai-1  |     )
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/autogen_ext/tools/azure/_ai_search.py", line 1099, in create_hybrid_search
ai-1  |     return cls(
ai-1  |         name=name,
ai-1  |     ...<9 lines>...
ai-1  |         **kwargs,
ai-1  |     )
ai-1  | TypeError: autogen_ext.tools.azure._ai_search.AzureAISearchTool() got multiple values for keyword argument 'query_type'

Let me know if you'd like me to try anything else.

@jay-thakur
Copy link
Contributor

Hi @StellaSource-Carlisle, thank you again for raising this issue and for your patience as we work through it.

In my previous response, I mistakenly included query_type="simple" & query_type="semantic" in the suggestion. That was an oversight on my part, as this value is already set and doesn't need to be specified explicitly.

To help us further isolate the issue, could you please try running your request again with only

semantic_config_name = <your_semantic_config_name>

I'm also working on a better mechanism to handle this more gracefully going forward, and I appreciate your support in the meantime.

@StellaSource-Carlisle
Copy link
Author

No worries at all @jay-thakur. Happy to help.

So I updated our cog_search function to the following:

_cog_search_tool = AzureAISearchTool.create_hybrid_search(
    name="call_cog_search_async",
    endpoint=_settings.COG_SEARCH_ENDPOINT,
    index_name=_settings.COG_SEARCH_INDEX,
    credential=AzureKeyCredential(_settings.COG_SEARCH_KEY),
    vector_fields=["description_vector"],
    search_fields=["product_description", "product_name"],
    semantic_config_name = "upl_semantic",
    api_version="2024-03-01-Preview", 
    select_fields=[
        "p_id",
        "p_description",
        "p_name"
    ],
    top=7
)

This returned the following error message:

ai-1  | 2025-05-09 15:28:18 [ERROR] ai.tools.cog_search_tool: 🔍 [Cog-ERROR] - {}
ai-1  | Traceback (most recent call last):
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/autogen_ext/tools/azure/_ai_search.py", line 391, in run
ai-1  |     async for doc in search_results:  # type: ignore
ai-1  |     ...<37 lines>...
ai-1  |         results.append(result)
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/search/documents/aio/_paging.py", line 28, in __anext__
ai-1  |     return await self.__anext__()
ai-1  |            ^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/search/documents/aio/_paging.py", line 31, in __anext__
ai-1  |     self._page = await self._page_iterator.__anext__()
ai-1  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/core/async_paging.py", line 94, in __anext__
ai-1  |     self._response = await self._get_next(self.continuation_token)
ai-1  |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/search/documents/aio/_paging.py", line 109, in _get_next_cb
ai-1  |     return await self._client.documents.search_post(search_request=self._initial_query.request, **self._kwargs)
ai-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/core/tracing/decorator_async.py", line 119, in wrapper_use_tracer
ai-1  |     return await func(*args, **kwargs)
ai-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/search/documents/_generated/aio/operations/_documents_operations.py", line 397, in search_post
ai-1  |     raise HttpResponseError(response=response, model=error)
ai-1  | azure.core.exceptions.HttpResponseError: () The parameter 'semanticConfiguration' must not be empty. Alternatively, set a default semantic configuration for this index.
ai-1  | Parameter name: semanticConfiguration
ai-1  | Code: 
ai-1  | Message: The parameter 'semanticConfiguration' must not be empty. Alternatively, set a default semantic configuration for this index.
ai-1  | Parameter name: semanticConfiguration
ai-1  | 
ai-1  | The above exception was the direct cause of the following exception:
ai-1  | 
ai-1  | Traceback (most recent call last):
ai-1  |   File "/app/ai/tools/cog_search_tool.py", line 50, in call_cog_search_async
ai-1  |     results = await _cog_search_tool.run({"query": mappedString})
ai-1  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/autogen_ext/tools/azure/_ai_search.py", line 448, in run
ai-1  |     raise ValueError(f"Error from Azure AI Search: {e.message}") from e
ai-1  | ValueError: Error from Azure AI Search: () The parameter 'semanticConfiguration' must not be empty. Alternatively, set a default semantic configuration for this index.
ai-1  | Parameter name: semanticConfiguration
ai-1  | Code: 
ai-1  | Message: The parameter 'semanticConfiguration' must not be empty. Alternatively, set a default semantic configuration for this index.
ai-1  | Parameter name: semanticConfiguration

Side-note for you. I had to incorporate an api_version as before I added that, I received the following error:

ai-1  | 2025-05-09 15:34:59 [ERROR] ai.tools.cog_search_tool: 🔍 [Cog-ERROR] - {}
ai-1  | Traceback (most recent call last):
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/autogen_ext/tools/azure/_ai_search.py", line 391, in run
ai-1  |     async for doc in search_results:  # type: ignore
ai-1  |     ...<37 lines>...
ai-1  |         results.append(result)
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/search/documents/aio/_paging.py", line 28, in __anext__
ai-1  |     return await self.__anext__()
ai-1  |            ^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/search/documents/aio/_paging.py", line 31, in __anext__
ai-1  |     self._page = await self._page_iterator.__anext__()
ai-1  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/core/async_paging.py", line 94, in __anext__
ai-1  |     self._response = await self._get_next(self.continuation_token)
ai-1  |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/search/documents/aio/_paging.py", line 109, in _get_next_cb
ai-1  |     return await self._client.documents.search_post(search_request=self._initial_query.request, **self._kwargs)
ai-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/core/tracing/decorator_async.py", line 119, in wrapper_use_tracer
ai-1  |     return await func(*args, **kwargs)
ai-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/azure/search/documents/_generated/aio/operations/_documents_operations.py", line 397, in search_post
ai-1  |     raise HttpResponseError(response=response, model=error)
ai-1  | azure.core.exceptions.HttpResponseError: (InvalidRequestParameter) The property 'text' does not exist on type 'Microsoft.Azure.Search.V2023_11_01.VectorQueryBase' or is not present in the API version '2023-11-01'. Make sure to only use property names that are defined by the type.
ai-1  | Parameter name: vectorQueries
ai-1  | Code: InvalidRequestParameter
ai-1  | Message: The property 'text' does not exist on type 'Microsoft.Azure.Search.V2023_11_01.VectorQueryBase' or is not present in the API version '2023-11-01'. Make sure to only use property names that are defined by the type.
ai-1  | Parameter name: vectorQueries
ai-1  | Exception Details:      (InvalidVectorQuery) The property 'text' does not exist on type 'Microsoft.Azure.Search.V2023_11_01.VectorQueryBase' or is not present in the API version '2023-11-01'. Make sure to only use property names that are defined by the type.
ai-1  |         Code: InvalidVectorQuery
ai-1  |         Message: The property 'text' does not exist on type 'Microsoft.Azure.Search.V2023_11_01.VectorQueryBase' or is not present in the API version '2023-11-01'. Make sure to only use property names that are defined by the type.
ai-1  | 
ai-1  | The above exception was the direct cause of the following exception:
ai-1  | 
ai-1  | Traceback (most recent call last):
ai-1  |   File "/app/ai/tools/cog_search_tool.py", line 49, in call_cog_search_async
ai-1  |     results = await _cog_search_tool.run({"query": mappedString})
ai-1  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ai-1  |   File "/app/.venv/lib/python3.13/site-packages/autogen_ext/tools/azure/_ai_search.py", line 448, in run
ai-1  |     raise ValueError(f"Error from Azure AI Search: {e.message}") from e
ai-1  | ValueError: Error from Azure AI Search: (InvalidRequestParameter) The property 'text' does not exist on type 'Microsoft.Azure.Search.V2023_11_01.VectorQueryBase' or is not present in the API version '2023-11-01'. Make sure to only use property names that are defined by the type.
ai-1  | Parameter name: vectorQueries
ai-1  | Code: InvalidRequestParameter
ai-1  | Message: The property 'text' does not exist on type 'Microsoft.Azure.Search.V2023_11_01.VectorQueryBase' or is not present in the API version '2023-11-01'. Make sure to only use property names that are defined by the type.
ai-1  | Parameter name: vectorQueries
ai-1  | Exception Details:      (InvalidVectorQuery) The property 'text' does not exist on type 'Microsoft.Azure.Search.V2023_11_01.VectorQueryBase' or is not present in the API version '2023-11-01'. Make sure to only use property names that are defined by the type.
ai-1  |         Code: InvalidVectorQuery
ai-1  |         Message: The property 'text' does not exist on type 'Microsoft.Azure.Search.V2023_11_01.VectorQueryBase' or is not present in the API version '2023-11-01'. Make sure to only use property names that are defined by the type.

@jay-thakur
Copy link
Contributor

@StellaSource-Carlisle this new PR should resolve all these issues! Thanks for flagging them!

Out of curiosity, I'd love to hear more about your use case if you're open to sharing.

@StellaSource-Carlisle
Copy link
Author

@StellaSource-Carlisle this new PR should resolve all these issues! Thanks for flagging them!

Out of curiosity, I'd love to hear more about your use case if you're open to sharing.

Fantastic news! Thanks so much @jay-thakur for getting that out there, much appreciated.

Regarding use case, sure thing! We have a custom DB canonical that we front with Azure AI Search to help with deep/fuzzy searches against the database. Currently today, we utilize the prompt flows inside of Azure AI studio. However, we're limited by things in prompt flow with silly things, such as limiting response fields. I don't want the AI to utilize the vector fields as part of its context to facilitate the response. Adds unneeded cost and processing.

Therefore, we're migrating the flow to our Agentic AutoGen solution for both speed and reduction of token usage resulting in cheaper and (more importantly) FASTER calls to get our results.

ekzhu added a commit that referenced this issue May 13, 2025
## Why are these changes needed?

Simplified the azure ai search tool and fixed bugs in the code


## Related issue number

"Closes #6430 " 

## Checks

- [X] I've included any doc changes needed for
<https://microsoft.github.io/autogen/>. See
<https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to
build and test documentation locally.
- [X] I've added tests (if relevant) corresponding to the changes
introduced in this PR.
- [X] I've made sure all auto checks have passed.

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
@jay-thakur
Copy link
Contributor

@StellaSource-Carlisle

This PR is merged now. Kindly try now and let me know if there is any issues.

I really appreciate you sharing your use case on how you're using the Azure AI Search tool is resulting in cheaper and (more importantly) FASTER calls to get our results.! It's incredibly rewarding to hear about real-world applications like yours.

I'm curious - are there any additional capabilities or features in the Azure AI Search tool that would be particularly helpful for your specific use case? I'm actively working on improvements, and your insights would be valuable for prioritizing what might benefit you most as customer/user.

I'd love to stay connected to better understand your evolving needs and ensure the tool continues to serve your requirements. If you're open to it, I'd welcome connecting on LinkedIn : https://www.linkedin.com/in/jay-thakur/

Thank you again for sharing your experience - it truly helps drive meaningful development.

@StellaSource-Carlisle
Copy link
Author

@StellaSource-Carlisle

This PR is merged now. Kindly try now and let me know if there is any issues.

I really appreciate you sharing your use case on how you're using the Azure AI Search tool is resulting in cheaper and (more importantly) FASTER calls to get our results.! It's incredibly rewarding to hear about real-world applications like yours.

I'm curious - are there any additional capabilities or features in the Azure AI Search tool that would be particularly helpful for your specific use case? I'm actively working on improvements, and your insights would be valuable for prioritizing what might benefit you most as customer/user.

I'd love to stay connected to better understand your evolving needs and ensure the tool continues to serve your requirements. If you're open to it, I'd welcome connecting on LinkedIn : https://www.linkedin.com/in/jay-thakur/

Thank you again for sharing your experience - it truly helps drive meaningful development.

Confirmed resolved in 0.5.7!

Thank you so much @jay-thakur . For now, this greatly reduced our token usage, cost and improved the speed. Initial testing of migrating from the prompt flow to the Agent/Tool flow inside our Autogen deployment is a ~50% speed increase and a reduction of tokens by >90%!

No additional capabilities as of yet needed with the Azure AI Search tool. Simply having the ability to have this granular control over the queries is lightyears past what we had in the prompt flow service (which was still pretty good!).

Added you on LinkedIn, please keep in touch.

Thanks again gents!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@ekzhu @jay-thakur @jackgerrits @StellaSource-Carlisle and others