Skip to content

Commit 9bf7170

Browse files
authored
Update instructions to better make use AI Search or File Search. Updated documentation (#130)
* Update instructions to better make use AI Search or File Search * Fix documentation
1 parent bf8cabf commit 9bf7170

File tree

6 files changed

+34
-25
lines changed

6 files changed

+34
-25
lines changed

.github/workflows/azure-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
AZURE_LOG_ANALYTICS_WORKSPACE_NAME: ${{ vars.AZURE_LOG_ANALYTICS_WORKSPACE_NAME }}
3838
USE_CONTAINER_REGISTRY: ${{ vars.USE_CONTAINER_REGISTRY }}
3939
USE_APPLICATION_INSIGHTS: ${{ vars.USE_APPLICATION_INSIGHTS }}
40-
USE_SEARCH_SERVICE: ${{ vars.USE_SEARCH_SERVICE }}
40+
USE_AZURE_AI_SEARCH_SERVICE: ${{ vars.USE_AZURE_AI_SEARCH_SERVICE }}
4141
AZURE_AI_AGENT_NAME: ${{ vars.AZURE_AI_AGENT_NAME }}
4242
AZURE_EXISTING_AGENT_ID: ${{ vars.AZURE_EXISTING_AGENT_ID }}
4343
AZURE_AI_AGENT_DEPLOYMENT_NAME: ${{ vars.AZURE_AI_AGENT_DEPLOYMENT_NAME }}

.github/workflows/template-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
AZURE_STORAGE_ACCOUNT_NAME: ${{ vars.AZURE_STORAGE_ACCOUNT_NAME }}
3434
AZURE_LOG_ANALYTICS_WORKSPACE_NAME: ${{ vars.AZURE_LOG_ANALYTICS_WORKSPACE_NAME }}
3535
USE_APPLICATION_INSIGHTS: ${{ vars.USE_APPLICATION_INSIGHTS }}
36-
USE_SEARCH_SERVICE: ${{ vars.USE_SEARCH_SERVICE }}
36+
USE_AZURE_AI_SEARCH_SERVICE: ${{ vars.USE_AZURE_AI_SEARCH_SERVICE }}
3737
AZURE_AI_AGENT_NAME: ${{ vars.AZURE_AI_AGENT_NAME }}
3838
AZURE_EXISTING_AGENT_ID: ${{ vars.AZURE_EXISTING_AGENT_ID }}
3939
AZURE_AI_AGENT_DEPLOYMENT_NAME: ${{ vars.AZURE_AI_AGENT_DEPLOYMENT_NAME }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ When you start a deployment, most parameters will have default values. You can c
108108
| **Azure Region** | Select a region with quota which supports your selected model. | |
109109
| **Model** | Choose from the [list of models supported by Azure AI Agent Service](https://learn.microsoft.com/azure/ai-services/agents/concepts/model-region-support) for your selected region. | gpt-4o-mini |
110110
| **Model Format** | Choose from OpenAI or Microsoft, depending on your model. | OpenAI |
111-
| **Model Deployment Capacity** | Configure capacity for your model. Recommended value is 100k. | 30k |
111+
| **Model Deployment Capacity** | Configure capacity for your model. | 80k |
112112
| **Embedding Model** | Choose from text-embedding-3-large, text-embedding-3-small, and text-embedding-ada-002. This may only be deployed if Azure AI Search is enabled. | text-embedding-3-small |
113-
| **Embedding Model Capacity** | Configure capacity for your embedding model. | 30k |
113+
| **Embedding Model Capacity** | Configure capacity for your embedding model. | 50k |
114114
| **Knowledge Retrieval** | Choose from OpenAI's file search or including Azure AI Search Index. | OpenAI's file search |
115115

116116
For a detailed description of customizable fields and instructions, view the [deployment customization guide](docs/deploy_customization.md).

azure.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pipeline:
5555
- AZURE_LOG_ANALYTICS_WORKSPACE_NAME
5656
- USE_CONTAINER_REGISTRY
5757
- USE_APPLICATION_INSIGHTS
58-
- USE_SEARCH_SERVICE
58+
- USE_AZURE_AI_SEARCH_SERVICE
5959
- AZURE_AI_AGENT_NAME
6060
- AZURE_AI_AGENT_ID
6161
- AZURE_AI_AGENT_DEPLOYMENT_NAME

docs/deploy_customization.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@
33

44
This document describes how to customize the deployment of the Agents Chat with Azure AI Foundry. Once you follow the steps here, you can run `azd up` as described in the [Deploying](./../README.md#deploying-steps) steps.
55

6-
* [Disabling resources](#disabling-resources)
6+
* [Use existing resources](#use-existing-resources)
7+
* [Enabling and disabling resources provision](#enabling-and-disabling-resources-provision)
78
* [Customizing resource names](#customizing-resource-names)
89
* [Customizing model deployments](#customizing-model-deployments)
910

10-
## Disabling resources
11+
## Use existing resources
12+
Be default, this template provisions a new resource group along with other resources. If you already have provisioned Azure AI Foundry and Azure AI Foundry Project, you might reuse these resources by setting:
1113

12-
Disabling a resource will stop that resource from being created and deployed to your Azure Project.
14+
```shell
15+
azd env set AZURE_EXISTING_AIPROJECT_RESOURCE_ID "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>"
16+
```
17+
18+
Notices that Application Insight and AI Search will not be created in this scenario.
19+
20+
21+
## Enabling and disabling resources provision
22+
23+
By default, provisioning Application Insights is enabled, and AI Search is disabled. The default setting can be changed by:
1324

14-
* To disable AI Search, run `azd env set USE_SEARCH_SERVICE false`
25+
* To enable AI Search, run `azd env set USE_AZURE_AI_SEARCH_SERVICE true`
1526
* To disable Application Insights, run `azd env set USE_APPLICATION_INSIGHTS false`
16-
* To disable Container Registry, run `azd env set USE_CONTAINER_REGISTRY false`
1727

1828
Once you disable these resources, they will not be deployed when you run `azd up`.
1929

@@ -22,9 +32,8 @@ Once you disable these resources, they will not be deployed when you run `azd up
2232
By default, this template will use a naming convention with unique strings to prevent naming collisions within Azure.
2333
To override default naming conventions, the following keys can be set:
2434

25-
* `AZURE_EXISTING_AIPROJECT_RESOURCE_ID` - An existing AI Project Resource ID be used. If specified, resources for AI Foundry Project and Azure AI service will not be created.
26-
* `AZURE_AIPROJECT_NAME` - The name of the AI Foundry Project
27-
* `AZURE_AISERVICES_NAME` - The name of the Azure AI service
35+
* `AZURE_AIPROJECT_NAME` - The name of the Azure AI Foundry project
36+
* `AZURE_AISERVICES_NAME` - The name of the Azure AI Foundry
2837
* `AZURE_STORAGE_ACCOUNT_NAME` - The name of the Storage Account
2938
* `AZURE_APPLICATION_INSIGHTS_NAME` - The name of the Application Insights instance
3039
* `AZURE_LOG_ANALYTICS_WORKSPACE_NAME` - The name of the Log Analytics workspace used by Application Insights

src/gunicorn.conf.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
AzureAISearchTool,
1919
FilePurpose,
2020
FileSearchTool,
21+
Tool,
2122
)
2223
from azure.ai.projects.models import ConnectionType
2324
from azure.identity.aio import DefaultAzureCredential
@@ -120,9 +121,9 @@ def _get_file_path(file_name: str) -> str:
120121
file_name))
121122

122123

123-
async def get_available_toolset(
124+
async def get_available_tool(
124125
project_client: AIProjectClient,
125-
creds: AsyncTokenCredential) -> AsyncToolSet:
126+
creds: AsyncTokenCredential) -> Tool:
126127
"""
127128
Get the toolset and tool definition for the agent.
128129
@@ -145,11 +146,9 @@ async def get_available_toolset(
145146
if conn_id:
146147
await create_index_maybe(project_client, creds)
147148

148-
ai_search = AzureAISearchTool(
149+
return AzureAISearchTool(
149150
index_connection_id=conn_id,
150151
index_name=os.environ.get('AZURE_AI_SEARCH_INDEX_NAME'))
151-
152-
toolset.add(ai_search)
153152
else:
154153
logger.info(
155154
"agent: index was not initialized, falling back to file search.")
@@ -169,21 +168,22 @@ async def get_available_toolset(
169168
)
170169
logger.info("agent: file store and vector store success")
171170

172-
file_search_tool = FileSearchTool(vector_store_ids=[vector_store.id])
173-
toolset.add(file_search_tool)
174-
175-
return toolset
171+
return FileSearchTool(vector_store_ids=[vector_store.id])
176172

177173

178174
async def create_agent(ai_client: AIProjectClient,
179175
creds: AsyncTokenCredential) -> Agent:
180176
logger.info("Creating new agent with resources")
181-
toolset = await get_available_toolset(ai_client, creds)
182-
177+
tool = await get_available_tool(ai_client, creds)
178+
toolset = AsyncToolSet()
179+
toolset.add(tool)
180+
181+
instructions = "Use AI Search always. Avoid to use base knowledge." if isinstance(tool, AzureAISearchTool) else "Use File Search always. Avoid to use base knowledge."
182+
183183
agent = await ai_client.agents.create_agent(
184184
model=os.environ["AZURE_AI_AGENT_DEPLOYMENT_NAME"],
185185
name=os.environ["AZURE_AI_AGENT_NAME"],
186-
instructions="You are helpful assistant",
186+
instructions=instructions,
187187
toolset=toolset
188188
)
189189
return agent

0 commit comments

Comments
 (0)