Skip to content

Commit 9023ffc

Browse files
committed
Bug fixes for deployment
1 parent 2a54f4a commit 9023ffc

25 files changed

+1287
-215
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"isBackground": true,
66
"label": "func: host start",
77
"options": {
8-
"cwd": "${workspaceFolder}/ai_search_with_adi_function_app"
8+
"cwd": "${workspaceFolder}/ai_search_with_image_processing"
99
},
1010
"problemMatcher": "$func-python-watch",
1111
"type": "func"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ It is intended that the plugins and skills provided in this repository, are adap
1111
## Components
1212

1313
- `./text_2_sql` contains an three Multi-Shot implementations for Text2SQL generation and querying which can be used to answer questions backed by a database as a knowledge base. A **prompt based** and **vector based** approach are shown, both of which exhibit great performance in answering sql queries. Additionally, a further iteration on the vector based approach is shown which uses a **query cache** to further speed up generation. With these plugins, your RAG application can now access and pull data from any SQL table exposed to it to answer questions.
14-
- `./adi_function_app` contains code for linking **Azure Document Intelligence** with AI Search to process complex documents with charts and images, and uses **multi-modal models (gpt4o)** to interpret and understand these. With this custom skill, the RAG application can **draw insights from complex charts** and images during the vector search. This function app also contains a **Semantic Text Chunking** method that aims to intelligently group similar sentences, retaining figures and tables together, whilst separating out distinct sentences.
14+
- `./image_processing` contains code for linking **Azure Document Intelligence** with AI Search to process complex documents with charts and images, and uses **multi-modal models (gpt4o)** to interpret and understand these. With this custom skill, the RAG application can **draw insights from complex charts** and images during the vector search. This function app also contains a **Semantic Text Chunking** method that aims to intelligently group similar sentences, retaining figures and tables together, whilst separating out distinct sentences.
1515
- `./deploy_ai_search` provides an easy Python based utility for deploying an index, indexer and corresponding skillset for AI Search and for Text2SQL.
1616

1717
The above components have been successfully used on production RAG projects to increase the quality of responses.

adi_function_app/.env

Lines changed: 0 additions & 12 deletions
This file was deleted.

deploy_ai_search/src/deploy_ai_search/text_2_sql_column_value_store.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121
import os
2222
from text_2_sql_core.utils.database import DatabaseEngine
23+
from text_2_sql_core.connectors.factory import ConnectorFactory
2324

2425

2526
class Text2SqlColumnValueStoreAISearch(AISearch):
@@ -43,25 +44,9 @@ def __init__(
4344
os.environ["Text2Sql__DatabaseEngine"].upper()
4445
]
4546

46-
self.parsing_mode = BlobIndexerParsingMode.JSON_LINES
47-
48-
@property
49-
def excluded_fields_for_database_engine(self):
50-
"""A method to get the excluded fields for the database engine."""
51-
52-
all_engine_specific_fields = ["Warehouse", "Database", "Catalog"]
53-
if self.database_engine == DatabaseEngine.SNOWFLAKE:
54-
engine_specific_fields = ["Warehouse", "Database"]
55-
elif self.database_engine == DatabaseEngine.TSQL:
56-
engine_specific_fields = ["Database"]
57-
elif self.database_engine == DatabaseEngine.DATABRICKS:
58-
engine_specific_fields = ["Catalog"]
47+
self.database_connector = ConnectorFactory.get_database_connector()
5948

60-
return [
61-
field
62-
for field in all_engine_specific_fields
63-
if field not in engine_specific_fields
64-
]
49+
self.parsing_mode = BlobIndexerParsingMode.JSON_LINES
6550

6651
def get_index_fields(self) -> list[SearchableField]:
6752
"""This function returns the index fields for sql index.
@@ -123,7 +108,7 @@ def get_index_fields(self) -> list[SearchableField]:
123108
fields = [
124109
field
125110
for field in fields
126-
if field.name not in self.excluded_fields_for_database_engine
111+
if field.name not in self.database_connector.excluded_engine_specific_fields
127112
]
128113

129114
return fields
@@ -238,7 +223,7 @@ def get_indexer(self) -> SearchIndexer:
238223
field_mapping
239224
for field_mapping in indexer.output_field_mappings
240225
if field_mapping.target_field_name
241-
not in self.excluded_fields_for_database_engine
226+
not in self.database_connector.excluded_engine_specific_fields
242227
]
243228

244229
return indexer

deploy_ai_search/src/deploy_ai_search/text_2_sql_schema_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def get_indexer(self) -> SearchIndexer:
346346
field_mapping
347347
for field_mapping in indexer.output_field_mappings
348348
if field_mapping.target_field_name
349-
not in self.excluded_fields_for_database_engine
349+
not in self.database_connector.excluded_engine_specific_fields
350350
]
351351

352352
return indexer
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ To get started, perform the following steps:
44

55
1. Setup Azure OpenAI in your subscription with **gpt-4o-mini** & an embedding model, an Python Function App, AI Search and a storage account.
66
2. Clone this repository and deploy the AI Search rag documents indexes from `deploy_ai_search`.
7-
3. Run `uv sync` within the adi_function_app directory to install dependencies.
7+
3. Run `uv sync` within the image_processing directory to install dependencies.
88
4. Configure the environment variables of the function app based on the provided sample
99
5. Package your Azure Function and upload to your Function App
1010
6. Upload a document for indexing or send a direct HTTP request to the Azure Function.
File renamed without changes.

0 commit comments

Comments
 (0)