Skip to content

Commit c07b006

Browse files
authored
Merge branch 'master' into 59-streaming-support-for-n8n-pipeline
Signed-off-by: owndev <69784886+owndev@users.noreply.github.com>
2 parents 76ccd8b + f931ca7 commit c07b006

2 files changed

Lines changed: 605 additions & 196 deletions

File tree

docs/azure-ai-integration.md

Lines changed: 156 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ The repository includes functions specifically designed for **Azure AI**, suppor
2424
Configure the following environment variables to enable Azure AI support:
2525

2626
```bash
27+
# Custom prefix for pipeline display name (default: "Azure AI")
28+
# The colon ":" will be added automatically between prefix and model name
29+
# Examples: "Azure AI" → "Azure AI: gpt-4o", "My Azure" → "My Azure: gpt-4o"
30+
AZURE_AI_PIPELINE_PREFIX="Azure AI"
31+
2732
# API key or token for Azure AI
2833
AZURE_AI_API_KEY="your-api-key"
2934

@@ -46,71 +51,177 @@ USE_PREDEFINED_AZURE_AI_MODELS=false
4651
# If true, use "Authorization: Bearer" instead of "api-key" header
4752
AZURE_AI_USE_AUTHORIZATION_HEADER=false
4853

49-
# Azure Search / RAG Configuration (optional)
50-
# Azure Search endpoint for document retrieval
51-
AZURE_SEARCH_ENDPOINT="https://your-search-service.search.windows.net"
54+
# Azure AI Search endpoint for document retrieval (Only for Azure OpenAI)
55+
# IMPORTANT: Azure AI Search only works with Azure OpenAI endpoints in this format:
56+
# https://<deployment>.openai.azure.com/openai/deployments/<model>/chat/completions?api-version=2025-01-01-preview
57+
AZURE_AI_ENDPOINT="https://<deployment>.openai.azure.com/openai/deployments/<model>/chat/completions?api-version=2025-01-01-preview"
58+
59+
# Azure AI Data Sources / RAG Configuration
60+
# Complete JSON configuration for Azure Search - copy exactly and replace placeholder values
61+
AZURE_AI_DATA_SOURCES='[{"type":"azure_search","parameters":{"endpoint":"https://<your-search-service>.search.windows.net","index_name":"<your-index-name>","authentication":{"type":"api_key","key":"<your-search-api-key>"}}}]'
62+
63+
# Enable enhanced citation display for better readability (default: true)
64+
AZURE_AI_ENHANCE_CITATIONS=true
65+
```
5266

53-
# Azure Search index name containing the documents
54-
AZURE_SEARCH_INDEX_NAME="your-index-name"
67+
### Azure AI Search / RAG Integration
5568

56-
# Azure Search project resource ID (optional)
57-
AZURE_SEARCH_PROJECT_RESOURCE_ID="your-project-resource-id"
69+
The pipeline supports **Azure AI Search** integration for **Retrieval-Augmented Generation (RAG)**. When configured, the pipeline automatically includes a `data_sources` field in requests to Azure AI, enabling document-based AI responses that can cite and reference your indexed content.
5870

59-
# Azure Search API key (if using api_key authentication)
60-
AZURE_SEARCH_KEY="your-search-api-key"
71+
> [!IMPORTANT]
72+
> **Azure AI Search integration only works with Azure OpenAI endpoints** in this specific format:
73+
> `https://<deployment>.openai.azure.com/openai/deployments/<model>/chat/completions?api-version=2025-01-01-preview`
6174
62-
# Authentication type for Azure Search
63-
AZURE_SEARCH_AUTHENTICATION_TYPE="system_assigned_managed_identity"
75+
#### 📖 Official Documentation
6476

65-
# Semantic configuration name for Azure Search
66-
AZURE_SEARCH_SEMANTIC_CONFIGURATION="azureml-default"
77+
For detailed information about Azure AI Search configuration, please refer to:
6778

68-
# Azure Search embedding endpoint (optional)
69-
AZURE_SEARCH_EMBEDDING_ENDPOINT="your-embedding-endpoint"
79+
- 📚 [Azure AI Search with Azure OpenAI - Official Guide](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/use-your-data-quickstart?tabs=api-key%2Ctypescript-keyless%2Cpython-new&pivots=rest-api)
80+
- 🔧 [Data Sources API Reference](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/references/on-your-data?tabs=rest#data-source)
81+
- 🔍 [Azure Search Parameters Reference](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/references/azure-search?tabs=rest)
7082

71-
# Azure Search embedding API key (optional)
72-
AZURE_SEARCH_EMBEDDING_KEY="your-embedding-key"
83+
#### ⚙️ Configuration
7384

74-
# Query type for Azure Search
75-
AZURE_SEARCH_QUERY_TYPE="vectorSimpleHybrid"
85+
Configure Azure AI Search by setting the `AZURE_AI_DATA_SOURCES` environment variable with your Azure Search configuration.
7686

77-
# Whether to limit search to indexed documents only
78-
AZURE_SEARCH_IN_SCOPE=false
87+
**Simple Example:**
7988

80-
# Role information for Azure Search responses
81-
AZURE_SEARCH_ROLE_INFORMATION="You are an AI assistant."
89+
```bash
90+
AZURE_AI_DATA_SOURCES='[{"type":"azure_search","parameters":{"endpoint":"https://my-search.search.windows.net","index_name":"my-index","authentication":{"type":"api_key","key":"your-search-api-key"}}}]'
91+
```
8292

83-
# Azure Search strictness level (1-5)
84-
AZURE_SEARCH_STRICTNESS=5
93+
> [!TIP]
94+
> **Copy the JSON exactly as shown above** - this is the complete configuration that goes into the `AZURE_AI_DATA_SOURCES` field. Just replace:
95+
>
96+
> - `my-search` with your Azure Search service name
97+
> - `my-index` with your search index name
98+
> - `your-search-api-key` with your actual Azure Search API key
99+
100+
#### 📋 Complete Configuration Template
101+
102+
```json
103+
[
104+
{
105+
"type": "azure_search",
106+
"parameters": {
107+
"endpoint": "https://YOUR-SEARCH-SERVICE.search.windows.net",
108+
"index_name": "YOUR-INDEX-NAME",
109+
"authentication": {
110+
"type": "api_key",
111+
"key": "YOUR-SEARCH-API-KEY"
112+
}
113+
}
114+
}
115+
]
116+
```
85117

86-
# Number of top documents to retrieve
87-
AZURE_SEARCH_TOP_N_DOCUMENTS=20
118+
#### 🔧 Advanced Configuration Options
119+
120+
For advanced use cases, you can include additional parameters:
121+
122+
```json
123+
[
124+
{
125+
"type": "azure_search",
126+
"parameters": {
127+
"endpoint": "https://YOUR-SEARCH-SERVICE.search.windows.net",
128+
"index_name": "YOUR-INDEX-NAME",
129+
"authentication": {
130+
"type": "api_key",
131+
"key": "YOUR-SEARCH-API-KEY"
132+
},
133+
"query_type": "vectorSimpleHybrid",
134+
"semantic_configuration": "default",
135+
"top_n_documents": 20,
136+
"strictness": 3,
137+
"role_information": "You are an AI assistant that helps with questions based on the provided documents."
138+
}
139+
}
140+
]
88141
```
89142

90-
### Azure Search / RAG Integration
143+
#### 🚀 Quick Setup Steps
144+
145+
1. **Create Azure Search Service** - Set up an Azure Search service in the Azure portal
146+
2. **Create and populate index** - Upload your documents to a search index
147+
3. **Get API key** - Copy the API key from your Azure Search service
148+
4. **Configure pipeline** - Add the `AZURE_AI_DATA_SOURCES` environment variable
149+
5. **Use Azure OpenAI endpoint** - Ensure you're using the correct Azure OpenAI URL format
150+
151+
#### ⚠️ Common Issues
152+
153+
- **Wrong endpoint format**: Make sure you're using Azure OpenAI URLs, not regular Azure AI endpoints
154+
- **Invalid JSON**: Copy the JSON template exactly and only change the placeholder values
155+
- **Missing API key**: Ensure your Azure Search API key has proper permissions
156+
- **Index not found**: Verify your index name matches exactly (case-sensitive)
157+
158+
#### Enhanced Citation Display
159+
160+
The pipeline automatically enhances Azure AI Search responses to make citations and source documents more accessible and readable. When Azure AI Search is configured, the pipeline transforms the raw citation data into a user-friendly format.
161+
162+
**Original Azure AI Response:**
163+
164+
```json
165+
{
166+
"choices": [
167+
{
168+
"message": {
169+
"content": "**Docker container actions** are a type of GitHub Actions [doc1]...",
170+
"context": {
171+
"citations": [
172+
{
173+
"content": "environment variable. The token can be used to authenticate...",
174+
"title": "README.md",
175+
"chunk_id": "0"
176+
}
177+
]
178+
}
179+
}
180+
}
181+
]
182+
}
183+
```
91184

92-
The pipeline now supports **Azure Search** integration for **Retrieval-Augmented Generation (RAG)**. When configured, the pipeline will automatically include a `data_sources` field in requests to Azure AI, enabling document-based AI responses.
185+
**Enhanced Response with Collapsible Citations:**
93186

94-
#### Configuration
187+
```html
188+
**Docker container actions** are a type of GitHub Actions [doc1]...
95189

96-
Configure Azure Search by setting the following environment variables:
190+
<details>
191+
<summary>📚 Sources and References</summary>
97192

98-
- **AZURE_SEARCH_ENDPOINT**: Your Azure Search service endpoint
99-
- **AZURE_SEARCH_INDEX_NAME**: Name of the search index containing your documents
100-
- **AZURE_SEARCH_AUTHENTICATION_TYPE**: Authentication method (`system_assigned_managed_identity` or `api_key`)
101-
- **AZURE_SEARCH_KEY**: API key (if using `api_key` authentication)
193+
<details>
194+
<summary>[doc1] - README.md</summary>
195+
196+
📁 **File:** `README.md`
197+
📄 **Chunk ID:** 0
198+
**Content:**
199+
> environment variable. The token can be used to authenticate the workflow when accessing GitHub resources...
200+
201+
</details>
202+
203+
<details>
204+
<summary>[doc2] - Documentation.md</summary>
205+
206+
📁 **File:** `Documentation.md`
207+
📄 **Chunk ID:** 1
208+
**Content:**
209+
> Docker container actions contain all their dependencies in the container and are therefore very consistent...
210+
211+
</details>
212+
213+
</details>
214+
```
102215

103-
#### Optional Settings
216+
**Enhanced Citation Features:**
104217

105-
- **AZURE_SEARCH_PROJECT_RESOURCE_ID**: Project resource ID
106-
- **AZURE_SEARCH_SEMANTIC_CONFIGURATION**: Semantic configuration name
107-
- **AZURE_SEARCH_EMBEDDING_ENDPOINT**: Embedding service endpoint
108-
- **AZURE_SEARCH_EMBEDDING_KEY**: Embedding service API key
109-
- **AZURE_SEARCH_QUERY_TYPE**: Query type (`vectorSimpleHybrid`, `vector`, `semantic`)
110-
- **AZURE_SEARCH_IN_SCOPE**: Limit to indexed documents only
111-
- **AZURE_SEARCH_ROLE_INFORMATION**: Role information for responses
112-
- **AZURE_SEARCH_STRICTNESS**: Strictness level (1-5)
113-
- **AZURE_SEARCH_TOP_N_DOCUMENTS**: Number of documents to retrieve
218+
- **Collapsible interface** with expandable sections for clean presentation
219+
- **Two-level organization** - main sources section and individual document details
220+
- **Complete content display** - full document content, not just previews
221+
- **Document references** with clear [doc1], [doc2] labels for easy cross-referencing
222+
- **Source metadata** including file paths, URLs, and chunk IDs for precise tracking
223+
- **Streaming support** with citations properly formatted for both streaming and non-streaming responses
224+
- **Space efficient** - collapsed by default to avoid overwhelming the main response
114225

115226
> [!TIP]
116227
> To use **Azure OpenAI** and other **Azure AI** models **simultaneously**, you can use the following URL: `https://<your project>.services.ai.azure.com/models/chat/completions?api-version=2024-05-01-preview`

0 commit comments

Comments
 (0)