Azure-Samples / azure-search-openai-demo

A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure AI Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.
https://azure.microsoft.com/products/search
MIT License
5.86k stars 3.99k forks source link

UnboundLocalError: cannot access local variable 'doc_int_parser' where it is not associated with a value #1306

Open amarpatel-xx opened 6 months ago

amarpatel-xx commented 6 months ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Setup cloud resources and load data:

$ azd auth login $ azd env set OPENAI_HOST openai $ azd env set OPENAI_ORGANIZATION $OPENAI_ORGANIZATION $ azd env set OPENAI_API_KEY $OPENAI_API_KEY $ azd up # To deploy the new resources

$ chmod u+x ./scripts/* $ pip install -r requirements-dev.txt # Install the dependencies $ python ./scripts/prepdocs.py --removeall

Any log messages given by the failure

Traceback (most recent call last): File "/Users/amarppatel/workspace/saathratri-app-holder/hotelchatbot/./scripts/prepdocs.py", line 425, in ingestion_strategy = loop.run_until_complete(setup_file_strategy(azd_credential, args)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/Users/amarppatel/workspace/saathratri-app-holder/hotelchatbot/./scripts/prepdocs.py", line 87, in setup_file_strategy ".docx": FileProcessor(doc_int_parser, sentence_text_splitter), ^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'doc_int_parser' where it is not associated with a value

Expected/desired behavior

No error and the data in the backend should be deleted along with the index.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?) macOS Darwin

azd version?

run azd version and copy paste here. azd version 1.6.1

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

pamelafox commented 6 months ago

Hm, did you run "azd up" a while ago? If you ran it today, it should set up your Document Intelligence environment variables, in AZURE_DOCUMENTINTELLIGENCE_SERVICE, but it seems like it's missing. You can delete this lines for now:

        ".docx": FileProcessor(doc_int_parser, sentence_text_splitter),
        ".pptx": FileProcessor(doc_int_parser, sentence_text_splitter),
        ".xlsx": FileProcessor(doc_int_parser, sentence_text_splitter),
        ".png": FileProcessor(doc_int_parser, sentence_text_splitter),
        ".jpg": FileProcessor(doc_int_parser, sentence_text_splitter),
        ".jpeg": FileProcessor(doc_int_parser, sentence_text_splitter),
        ".tiff": FileProcessor(doc_int_parser, sentence_text_splitter),
        ".bmp": FileProcessor(doc_int_parser, sentence_text_splitter),
        ".heic": FileProcessor(doc_int_parser, sentence_text_splitter),