Index Lookup Error in Azure AI Studio Prompt Flow

Prabhakar Reddy 0 Reputation points
2024-12-24T17:04:53.8066667+00:00

I am building a straightforward RAG prompt flow within Azure AI Studio. I have loaded the data and created the indexes successfully, and I am able to use the data in the Chat Playground to generate responses. However, when using the "Index Lookup" within a prompt flow, the step fails with the error "Run failed: Exception: Exception occurred in search_function_construction." Below is the detailed error stack:

I have re-created all resources step by step but continue to encounter this error. Any assistance would be greatly appreciated. Additionally, a screenshot of the error is attached. index_lookup_error

Detailed error

Traceback (most recent call last):
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 864, in _resolve_forward_ref
    obj = _typing_extra.eval_type_backport(obj, globalns=self._types_namespace)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 279, in eval_type_backport
    return _eval_type_backport(value, globalns, localns, type_params)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 303, in _eval_type_backport
    return _eval_type(value, globalns, localns, type_params)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 332, in _eval_type
    return typing._eval_type(  # type: ignore
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/typing.py", line 292, in _eval_type
    return t._evaluate(globalns, localns, recursive_guard)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/typing.py", line 554, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
NameError: name 'AzureSearch' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/promptflow_vectordb/tool/utils/profiling.py", line 18, in measure_execution_time
    yield
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/promptflow_vectordb/tool/common_index_lookup.py", line 56, in _get_search_func
    search_func = build_search_func(index, top_k, query_type)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/promptflow_vectordb/tool/common_index_lookup_extensions/utils.py", line 46, in build_search_func
    store = index.as_langchain_vectorstore(credential=DefaultAzureCredential())
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/azureml/rag/mlindex.py", line 197, in as_langchain_vectorstore
    azuresearch = _get_azuresearch_module_instance(langchain_pkg_version)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/azureml/rag/utils/acs.py", line 21, in _get_azuresearch_module_instance
    azuresearch.AzureSearchVectorStoreRetriever.model_rebuild()
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/main.py", line 563, in model_rebuild
    return _model_construction.complete_model_class(
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 577, in complete_model_class
    schema = cls.__get_pydantic_core_schema__(cls, handler)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/main.py", line 671, in __get_pydantic_core_schema__
    return handler(source)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_schema_generation_shared.py", line 83, in __call__
    schema = self._handler(source_type)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 655, in generate_schema
    schema = self._generate_schema_inner(obj)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 924, in _generate_schema_inner
    return self._model_schema(obj)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 739, in _model_schema
    {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 739, in <dictcomp>
    {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 1115, in _generate_md_field_schema
    common_field = self._common_field_schema(name, field_info, decorators)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 1308, in _common_field_schema
    schema = self._apply_annotations(
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 2107, in _apply_annotations
    schema = get_inner_schema(source_type)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_schema_generation_shared.py", line 83, in __call__
    schema = self._handler(source_type)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 2088, in inner_handler
    schema = self._generate_schema_inner(obj)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 918, in _generate_schema_inner
    return self.generate_schema(self._resolve_forward_ref(obj))
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/pydantic/_internal/_generate_schema.py", line 866, in _resolve_forward_ref
    raise PydanticUndefinedAnnotation.from_name_error(e) from e
pydantic.errors.PydanticUndefinedAnnotation: name 'AzureSearch' is not defined
For further information visit https://errors.pydantic.dev/2.9/u/undefined-annotation
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/promptflow/tracing/_trace.py", line 557, in wrapped
    output = func(*args, **kwargs)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/promptflow_vectordb/core/logging/utils.py", line 98, in wrapper
    res = func(*args, **kwargs)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/promptflow_vectordb/tool/common_index_lookup.py", line 170, in search
    search_func = _get_search_func(mlindex_content, top_k, query_type)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/promptflow_vectordb/tool/common_index_lookup.py", line 56, in _get_search_func
    search_func = build_search_func(index, top_k, query_type)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/promptflow_vectordb/tool/utils/profiling.py", line 21, in measure_execution_time
    raise Exception(error_msg) from e
Exception: Exception occured in search_function_construction.

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,003 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Prabhakar Reddy 0 Reputation points
    2024-12-24T19:32:31.7566667+00:00

    Looks like the latest prompt flow runtime has some issues. So, I tried a few previous build versions from the list below and found version 20240326.v2 to work.

    https://mcr.microsoft.com/v2/azureml/promptflow/promptflow-runtime/tags/list

    You can change the settings by editing the advance compute settings

    advance-compute-setting-tochangebaseimage

    or directly editing the flow.dag.yaml code

    flow-dag-yaml


  2. AshokPeddakotla-MSFT 35,576 Reputation points
    2024-12-26T04:37:18.8866667+00:00

    Prabhakar Reddy I'm glad that your issue is resolved and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer, they can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.

    Error Message:

    I am building a straightforward RAG prompt flow within Azure AI Studio. I have loaded the data and created the indexes successfully, and I am able to use the data in the Chat Playground to generate responses. However, when using the "Index Lookup" within a prompt flow, the step fails with the error "Run failed: Exception: Exception occurred in search_function_construction." Below is the detailed error stack:

    Solution:

    I tried a few previous build versions from the list below and found version 20240326.v2 to work.

    https://mcr.microsoft.com/v2/azureml/promptflow/promptflow-runtime/tags/list

    You can change the settings by editing the advance compute settings

    advance-compute-setting-tochangebaseimage

    or directly editing the flow.dag.yaml code

    flow-dag-yaml

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.