Stratify AI is a project-requirement analysis assistant. It helps teams strategically evaluate solution options from two critical dimensions at the same time: technical feasibility and financial impact.
Given a user query, the Copilot Studio orchestrator decomposes it into technology and finance prompts, calls backend RAG APIs, runs a reasoning-based guardrail validation to verify grounding, and presents a consolidated recommendation with citations. This repository includes the FastAPI ingestion/retrieval services and the exported Copilot solution package so the full workflow can be run locally end-to-end.
The solution provides project requirement analysis through two perspectives:
- Technology analysis
- Financial analysis
End-to-end architecture (flow view)
Execution sequence (interaction view)
High-level flow:
- End user asks a project requirement question in Copilot Studio.
- Copilot Studio orchestration logic decomposes the request into two prompts:
tech_promptfinance_prompt
- Copilot invokes two flow actions:
POST_API_Respone_TechPOST_API_Respone_Finance
- Each flow sends
POSTrequest to local retrieval API endpoint (through ngrok). - Backend performs hybrid retrieval (vector + semantic) on Azure AI Search.
- Retrieved chunks are passed to Azure OpenAI for grounded answer generation.
- A reasoning-based guardrail validator breaks answers into claims and checks each claim against retrieved context.
- Backend response is returned to Copilot, parsed, and displayed in adaptive card sections for technology and finance.
ingestion/: Ingestion API to create/clear index and ingest blob documents into Azure AI Search.retrieval/: Retrieval API used by Copilot Studio flows for technology/finance responses.demo-files/: Sample documents for testing ingestion.copilot-export/StratifyAgent_1_0_0_1_managed.zip: Exported Copilot Studio managed solution package.
- Solution unique name:
StratifyAgent - Solution display name:
Stratify AI - Solution version:
1.0.0.1 - Package type:
Managed - Copilot name:
Stratify AI - Main topic (display name):
Data Orchestrator - Identity topic (display name):
Agent Identification - AI Builder model used for prompt decomposition:
Orch_Two_domain_prompts - Flow IDs used by topic:
- Finance flow:
4100834b-0c13-f111-8341-7ced8daf54b2 - Tech flow:
95bffa7c-470f-f111-8341-7ced8daf0540
- Finance flow:
- Environment variables expected by both flows:
sai_var_ngrok_api_base_url(example value of an ngrok URL)sai_var_ngrok_api_method_name(default/get-response)
- Visual Studio Code
- Python 3.13.x
- Postman (or similar API client)
- ngrok account and CLI
Create resources in one Azure subscription/resource group:
- Azure AI Search
- Azure OpenAI
- One embedding model deployment
- One chat-completion model deployment
- Azure AI Document Intelligence
- Azure Storage Account
- One Blob container for source files
git clone https://github.com/msoumit/stratify-agent.git
cd stratify-agent- Create a blob container (for example
rag-inputs). - Upload files from
demo-files/or your own documents.
Supported file types by current ingestion code:
.pdf.docx
- Create an Azure AI Search service.
- Note endpoint and admin key.
- Choose an index name (example:
stratify-index).
Important:
- Ingestion API can create the index schema via
POST /create-index. - Schema uses vector
embeddingdimension1536. - Your embedding deployment must output 1536-dimensional vectors (example:
text-embedding-3-small).
- Create Azure OpenAI resource.
- Deploy one embedding model.
- Deploy one chat completion model.
- Capture endpoint, key, and deployment names.
- Create Document Intelligence resource.
- Capture endpoint and key.
- Model used by this project:
prebuilt-layout.
Create .env files from examples.
Create ingestion/.env:
AZURE_SEARCH_ENDPOINT=<your_search_endpoint>
AZURE_SEARCH_ADMIN_KEY=<your_search_key>
AZURE_SEARCH_INDEX=<your_index_name>
AZURE_OPENAI_ENDPOINT=<your_openai_endpoint>
AZURE_OPENAI_API_KEY=<your_openai_key>
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=<your_deployed_model_for_embedding>
AZURE_OPENAI_MODEL_DEPLOYMENT=<your_deployed_model_for_chat_completion>
AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT=<your_di_endpoint>
AZURE_DOCUMENT_INTELLIGENCE_KEY=<your_di_key>
AZURE_DOCUMENT_INTELLIGENCE_MODEL=prebuilt-layout
AZURE_STORAGE_CONNECTION_STRING=<your_storage_account_connection_string>
AZURE_STORAGE_CONTAINER=<your_container>
DEFAULT_CHUNK_SIZE=1200
DEFAULT_CHUNK_OVERLAP=150
EMBEDDING_BATCH_SIZE=64
SEARCH_FILTER_BATCH_SIZE=50
SEARCH_BATCH_SIZE=200Create retrieval/.env:
AZURE_SEARCH_ENDPOINT=<your_search_endpoint>
AZURE_SEARCH_ADMIN_KEY=<your_search_key>
AZURE_SEARCH_INDEX=<your_index_name>
AZURE_OPENAI_ENDPOINT=<your_openai_endpoint>
AZURE_OPENAI_API_KEY=<your_openai_key>
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=<your_deployed_model_for_embedding>
AZURE_OPENAI_MODEL_DEPLOYMENT=<your_deployed_model_for_chat_completion>cd ingestion
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8001 --reloadIn another terminal or Postman:
POST http://localhost:8001/create-indexPOST http://localhost:8001/ingestIngestion behavior:
- Reads documents from blob container
- Parses with Document Intelligence
- Chunks content
- Summarizes tables into text rows
- Generates embeddings
- Replaces prior chunks for same
source_url - Uploads chunks to Azure AI Search
Optional maintenance endpoint:
POST http://localhost:8001/clear-indexcd retrieval
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000 --reloadHealth check:
GET http://localhost:8000/Expected response:
{"response":"hello world v2"}Endpoint:
POST http://localhost:8000/get-response
Content-Type: application/jsonSample request:
{
"prompt": "Should we choose SaaS or open source for our AI chatbot platform?",
"type": "technology"
}type values used by Copilot flows:
technologyfinance
Response shape expected by Copilot topic parsing:
{
"answer": "...",
"citations": [
{
"title": "...",
"source_url": "...",
"chunk_id": "..."
}
],
"guardrail": {
"verdict": "grounded | partially_grounded | not_grounded | unknown",
"confidence": 0.0,
"issues": [],
"notes": null
}
}Copilot flows must call your local retrieval API through public HTTPS URL.
ngrok http 8000Copy HTTPS forwarding URL, for example:
https://xxxx-xx-xx-xx-xx.ngrok-free.app
- Open Power Platform / Copilot Studio environment.
- Import solution package from:
copilot-export/StratifyAgent_1_0_0_1_managed.zip
- Complete import.
Set these values in the target environment:
sai_var_ngrok_api_base_url= your current ngrok HTTPS base URL- Example:
https://xxxx-xx-xx-xx-xx.ngrok-free.app
- Example:
sai_var_ngrok_api_method_name=/get-response
These two variables are consumed by both flow actions.
Both flows send this payload to retrieval API:
{
"prompt": "<text>",
"type": "technology|finance"
}The flow returns apiresponse as stringified HTTP body and the topic parses it into structured fields.
After updating variables and confirming flows, publish the Copilot agent.
- Run ingestion and complete index ingestion.
- Run retrieval API locally.
- Start ngrok for port
8000. - Update imported solution environment variables with current ngrok URL.
- Publish Copilot.
- Ask project requirement question in Copilot chat.
- Verify adaptive card contains:
- Technical Analysis section
- Financial Analysis section
- Guardrail verdict and confidence for both
- Source links from citations
If you ingest the sample documents from demo-files/, use these prompts to validate end-to-end behavior in Copilot.
-
SaaS vs custom build
Tell me from technical standpoint should we go for SaaS Product available in 3rd Party vendor or build in house custom tool? Please consider financial aspect for both cases and suggest which option is better in both technical feasibility, governance and time to build vs cost.
-
Data center refresh vs cloud migration (5-year)
We have a hardware refresh coming up within the next year and our current data center hosts around 220 VMs with 40 TB of data. From a long-term strategic perspective, should we modernize our on-prem infrastructure or migrate to cloud? I am particularly concerned about 5-year horizon to check which option will be better in terms of technical feasibility, financial aspect and governance.
-
Managed AI platform vs self-hosted AI infra (5-year)
We are planning to scale AI use cases across the organization, including intelligent search, copilots, and document automation, with projected usage of around 5 million API calls per month. From a 5-year strategic perspective, should we rely on a managed AI platform like Azure OpenAI, or invest in building our own self-hosted AI infrastructure with dedicated GPU clusters?
- Confirm retrieval API is running on
localhost:8000. - Confirm ngrok session is active.
- Confirm
sai_var_ngrok_api_base_urlpoints to active ngrok URL. - Confirm
sai_var_ngrok_api_method_nameis/get-response. - Check if flows
POST_API_Respone_TechandPOST_API_Respone_Financeare turned on.
- Verify ingestion completed successfully.
- Verify both services use same
AZURE_SEARCH_INDEX. - Check that relevant content exists in uploaded docs.
- Validate Azure Search endpoint/admin key.
- Ensure embedding model is 1536-dimensional.
- Validate Blob container and connection string.
- Validate Document Intelligence endpoint/key.
- Ensure retrieval API returns valid JSON object with exact keys:
answercitationsguardrail
- Avoid non-JSON wrappers in backend response.
This project was built by:
- Soumit Mukherjee
- Sourav Paul
- Soumyadeep Mukherjee
We acknowledge the support of Microsoft Copilot Studio, Power Automate, and Azure AI services used in this solution.
This project is licensed under the MIT License. See LICENSE for details.

