Skip to content

Commit

Permalink
Split Image Processing for multiple stage processing and fix bugs (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenConstable9 authored Jan 23, 2025
1 parent 2a013d8 commit 76bb605
Show file tree
Hide file tree
Showing 55 changed files with 2,591 additions and 2,201 deletions.
16 changes: 16 additions & 0 deletions .funcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.git*
.vscode
__azurite_db*__.json
__blobstorage__
__queuestorage__
local.settings.json
test
.venv
.github/*
.devcontainer/*
.ruff_cache/*
deploy_ai_search_indexes/*
text_2_sql/*
documentation/*
images/
__pycache__
2 changes: 1 addition & 1 deletion .github/workflows/ci-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- "*" # Run on all branches

env:
MIN_PYTHON_VERSION: 3.11
MIN_PYTHON_VERSION: 3.12

jobs:
job-pre-commit-check:
Expand Down
14 changes: 8 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ repos:
args: [--fix, --ignore, UP007]
exclude: samples

# - repo: https://github.com/astral-sh/uv-pre-commit
# # uv version.
# rev: 0.5.5
# hooks:
# # Update the uv lockfile
# - id: uv-lock
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.5.20
hooks:
# Update the uv lockfile
- id: uv-lock
- id: uv-export
args: [--frozen, --no-hashes, --no-editable, --no-sources, --verbose, --no-group, dev, --directory, image_processing, -o, src/image_processing/requirements.txt]
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12
3.11
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"azureFunctions.deploySubpath": "image_processing/src/image_processing",
"azureFunctions.projectLanguage": "Python",
"azureFunctions.projectLanguageModel": 2,
"azureFunctions.projectRuntime": "~4",
"azureFunctions.pythonVenv": ".venv",
"azureFunctions.scmDoBuildDuringDeployment": true,
"debug.internalConsoleOptions": "neverOpen"
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"isBackground": true,
"label": "func: host start",
"options": {
"cwd": "${workspaceFolder}/ai_search_with_adi_function_app"
"cwd": "${workspaceFolder}/image_processing/src/image_processing"
},
"problemMatcher": "$func-python-watch",
"type": "func"
Expand Down
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ It is intended that the plugins and skills provided in this repository, are adap
## Components

- `./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.
- `./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.
- `./deploy_ai_search` provides an easy Python based utility for deploying an index, indexer and corresponding skillset for AI Search and for Text2SQL.
- `./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.
- `./deploy_ai_search_indexes` provides an easy Python based utility for deploying an index, indexer and corresponding skillset for AI Search and for Text2SQL.

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

_The code provided in this repo is a sample of the implementation and should be adjusted before being used in production._

## High Level Implementation

The following diagram shows a workflow for how the Text2SQL and AI Search plugin would be incorporated into a RAG application. Using the plugins available, alongside the Function Calling capabilities of LLMs, the LLM can do Chain of Thought reasoning to determine the steps needed to answer the question. This allows the LLM to recognise intent and therefore pick appropriate data sources based on the intent of the question, or a combination of both.

![High level workflow for a plugin driven RAG application](./images/Plugin%20Based%20RAG%20Flow.png "High Level Workflow")
> [!WARNING]
>
> - The code provided in this repo is a accelerator of the implementation and should be review / adjusted before being used in production.
## Contributing

Expand Down
12 changes: 0 additions & 12 deletions adi_function_app/.env

This file was deleted.

10 changes: 0 additions & 10 deletions adi_function_app/GETTING_STARTED.md

This file was deleted.

Loading

0 comments on commit 76bb605

Please sign in to comment.