Skip to content

Commit e28e3a4

Browse files
committed
Update tests and docs
1 parent 9bbb423 commit e28e3a4

File tree

4 files changed

+71
-8
lines changed

4 files changed

+71
-8
lines changed

app/backend/prepdocslib/searchmanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ async def create_agent(self):
444444
if self.use_acls:
445445
field_names.extend(["oids", "groups"])
446446
if self.search_images:
447-
field_names.append("images")
447+
field_names.append("images/url")
448448
async with self.search_info.create_search_index_client() as search_index_client:
449449
knowledge_source = SearchIndexKnowledgeSource(
450450
name=self.search_info.index_name, # Use the same name for convenience

docs/deploy_features.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ To enable reasoning models, follow the steps in [the reasoning models guide](./r
152152
153153
## Using agentic retrieval
154154
155-
⚠️ This feature is not fully compatible with [multimodal feature](./multimodal.md).
156-
157155
This feature allows you to use agentic retrieval in place of the Search API. To enable agentic retrieval, follow the steps in [the agentic retrieval guide](./agentic_retrieval.md)
158156
159157
## Using different embedding models
@@ -231,8 +229,6 @@ If you have already deployed:
231229
232230
## Enabling multimodal embeddings and answering
233231
234-
⚠️ This feature is not currently compatible with [agentic retrieval](./agentic_retrieval.md).
235-
236232
When your documents include images, you can optionally enable this feature that can
237233
use image embeddings when searching and also use images when answering questions.
238234

docs/multimodal.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,4 @@ and you may still see good results with just text inputs, since the inputs conta
113113
## Compatibility
114114

115115
* This feature is **not** compatible with [integrated vectorization](./deploy_features.md#enabling-integrated-vectorization), as the currently configured built-in skills do not process images or store image embeddings. Azure AI Search does now offer built-in skills for multimodal support, as demonstrated in [azure-ai-search-multimodal-sample](https://github.com/Azure-Samples/azure-ai-search-multimodal-sample), but we have not integrated them in this project. Instead, we are working on making a custom skill based off the data ingestion code in this repository, and hosting that skill on Azure Functions. Stay tuned to the releases to find out when that's available.
116-
* This feature is **not** fully compatible with the [agentic retrieval](./agentic_retrieval.md) feature.
117-
The agent *will* perform the multimodal vector embedding search, but it will not return images in the response,
118-
so we cannot send the images to the chat completion model.
119116
* This feature *is* compatible with the [reasoning models](./reasoning.md) feature, as long as you use a model that [supports image inputs](https://learn.microsoft.com/azure/ai-services/openai/how-to/reasoning?tabs=python-secure%2Cpy#api--feature-support).

tests/test_searchmanager.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,3 +717,73 @@ async def mock_list_index_names(self):
717717
profiles = indexes[0].vector_search.profiles
718718
assert any(p.name == "images_embedding_profile" for p in profiles), "Should have an image embedding profile"
719719
assert any(p.name == "embedding3-profile" for p in profiles), "Should have a text embedding profile"
720+
721+
722+
@pytest.mark.asyncio
723+
async def test_create_agent_field_names_with_acls_and_images(monkeypatch, search_info):
724+
"""Covers create_agent logic adding oids/groups/images and creating knowledge source (lines 443-447,449,457)."""
725+
726+
# Provide a SearchInfo configured for agentic retrieval and image search
727+
search_info_agent = SearchInfo(
728+
endpoint=search_info.endpoint,
729+
credential=search_info.credential,
730+
index_name=search_info.index_name,
731+
use_agentic_retrieval=True,
732+
agent_name="test-agent",
733+
agent_max_output_tokens=1024,
734+
azure_openai_searchagent_model="gpt-4o-mini",
735+
azure_openai_searchagent_deployment="gpt-4o-mini",
736+
azure_openai_endpoint="https://openaidummy.openai.azure.com/",
737+
azure_vision_endpoint="https://visiondummy.cognitiveservices.azure.com/",
738+
)
739+
740+
created_indexes = []
741+
knowledge_sources = []
742+
agents = []
743+
744+
async def mock_list_index_names(self):
745+
for index in []:
746+
yield index # pragma: no cover
747+
748+
async def mock_create_index(self, index):
749+
created_indexes.append(index)
750+
751+
async def mock_create_or_update_knowledge_source(self, knowledge_source, *args, **kwargs):
752+
knowledge_sources.append(knowledge_source)
753+
return knowledge_source
754+
755+
async def mock_create_or_update_agent(self, agent, *args, **kwargs):
756+
agents.append(agent)
757+
return agent
758+
759+
monkeypatch.setattr(SearchIndexClient, "list_index_names", mock_list_index_names)
760+
monkeypatch.setattr(SearchIndexClient, "create_index", mock_create_index)
761+
monkeypatch.setattr(SearchIndexClient, "create_or_update_knowledge_source", mock_create_or_update_knowledge_source)
762+
monkeypatch.setattr(SearchIndexClient, "create_or_update_agent", mock_create_or_update_agent)
763+
764+
manager = SearchManager(search_info_agent, use_acls=True, search_images=True)
765+
766+
# Act
767+
await manager.create_index()
768+
769+
# Assert index created
770+
assert len(created_indexes) == 1, "Index should be created before agent creation"
771+
# Assert index has images and ACL fields
772+
index = created_indexes[0]
773+
assert any(field.name == "images" for field in index.fields), "Index should have images field"
774+
assert any(field.name == "oids" for field in index.fields), "Index should have oids field"
775+
assert any(field.name == "groups" for field in index.fields), "Index should have groups field"
776+
777+
# Assert knowledge source was created with expected selected fields
778+
assert len(knowledge_sources) == 1, "Knowledge source should be created"
779+
ks = knowledge_sources[0]
780+
selected = ks.search_index_parameters.source_data_select.split(",")
781+
# Required baseline fields
782+
for f in ["id", "sourcepage", "sourcefile", "content", "category", "oids", "groups", "images/url"]:
783+
assert f in selected, f"Missing field {f} in knowledge source selection"
784+
785+
# Assert agent created referencing the knowledge source
786+
assert len(agents) == 1, "Agent should be created"
787+
agent = agents[0]
788+
assert agent.name == "test-agent"
789+
assert any(ks_ref.name == ks.name for ks_ref in agent.knowledge_sources), "Agent should reference knowledge source"

0 commit comments

Comments
 (0)