Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions infra/core/ai/cognitiveservices.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ param location string = resourceGroup().location
param tags object = {}
@description('The custom subdomain name used to access the API. Defaults to the value of the name parameter.')
param customSubDomainName string = aiServiceName
param disableLocalAuth bool = false
param disableLocalAuth bool = true
param deployments array = []
param appInsightsId string
param appInsightConnectionString string
Expand Down Expand Up @@ -51,16 +51,13 @@ resource aiServiceConnection 'Microsoft.CognitiveServices/accounts/connections@2
parent: account
properties: {
category: 'AzureOpenAI'
authType: 'ApiKey'
authType: 'AAD'
isSharedToAll: true
target: account.properties.endpoints['OpenAI Language Model Instance API']
metadata: {
ApiType: 'azure'
ResourceId: account.id
}
credentials: {
key: account.listKeys().key1
}
}
}

Expand Down
1 change: 1 addition & 0 deletions scripts/resolve_model_quota.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ MissingParams=()
[[ -z "$Location" ]] && MissingParams+=("location")
[[ -z "$Model" ]] && MissingParams+=("model")
[[ -z "$Capacity" ]] && MissingParams+=("capacity")
[[ -z "$Format" ]] && MissingParams+=("format")
[[ -z "$DeploymentType" ]] && MissingParams+=("deployment-type")

if [[ ${#MissingParams[@]} -gt 0 ]]; then
Expand Down
28 changes: 14 additions & 14 deletions scripts/set_default_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -e

# --- Check Required Environment Variables ---
SubscriptionId="${AZURE_SUBSCRIPTION_ID}"
Location="${AZURE_LOCATION}"
SubscriptionId="${envVars[AZURE_SUBSCRIPTION_ID]}"
Location="${envVars[AZURE_LOCATION]}"

Errors=0

Expand Down Expand Up @@ -57,12 +57,12 @@ if [ -n "$resourceId" ]; then
fi

# --- Build Chat Deployment ---
chatDeployment_name="${AZURE_AI_AGENT_DEPLOYMENT_NAME}"
chatDeployment_model_name="${AZURE_AI_AGENT_MODEL_NAME}"
chatDeployment_model_version="${AZURE_AI_AGENT_MODEL_VERSION}"
chatDeployment_model_format="${AZURE_AI_AGENT_MODEL_FORMAT}"
chatDeployment_sku_name="${AZURE_AI_AGENT_DEPLOYMENT_SKU}"
chatDeployment_capacity="${AZURE_AI_AGENT_DEPLOYMENT_CAPACITY}"
chatDeployment_name="${envVars[AZURE_AI_AGENT_DEPLOYMENT_NAME]}"
chatDeployment_model_name="${envVars[AZURE_AI_AGENT_MODEL_NAME]}"
chatDeployment_model_version="${envVars[AZURE_AI_AGENT_MODEL_VERSION]}"
chatDeployment_model_format="${envVars[AZURE_AI_AGENT_MODEL_FORMAT]}"
chatDeployment_sku_name="${envVars[AZURE_AI_AGENT_DEPLOYMENT_SKU]}"
chatDeployment_capacity="${envVars[AZURE_AI_AGENT_DEPLOYMENT_CAPACITY]}"
chatDeployment_capacity_env="AZURE_AI_AGENT_DEPLOYMENT_CAPACITY"

aiModelDeployments=(
Expand All @@ -71,12 +71,12 @@ aiModelDeployments=(

# --- Optional Embed Deployment ---
if [ "$USE_AZURE_AI_SEARCH_SERVICE" == "true" ]; then
embedDeployment_name="${AZURE_AI_EMBED_DEPLOYMENT_NAME}"
embedDeployment_model_name="${AZURE_AI_EMBED_MODEL_NAME}"
embedDeployment_model_version="${AZURE_AI_EMBED_MODEL_VERSION}"
embedDeployment_model_format="${AZURE_AI_EMBED_MODEL_FORMAT}"
embedDeployment_sku_name="${AZURE_AI_EMBED_DEPLOYMENT_SKU}"
embedDeployment_capacity="${AZURE_AI_EMBED_DEPLOYMENT_CAPACITY}"
embedDeployment_name="${envVars[AZURE_AI_EMBED_DEPLOYMENT_NAME]}"
embedDeployment_model_name="${envVars[AZURE_AI_EMBED_MODEL_NAME]}"
embedDeployment_model_version="${envVars[AZURE_AI_EMBED_MODEL_VERSION]}"
embedDeployment_model_format="${envVars[AZURE_AI_EMBED_MODEL_FORMAT]}"
embedDeployment_sku_name="${envVars[AZURE_AI_EMBED_DEPLOYMENT_SKU]}"
embedDeployment_capacity="${envVars[AZURE_AI_EMBED_DEPLOYMENT_CAPACITY]}"
embedDeployment_capacity_env="AZURE_AI_EMBED_DEPLOYMENT_CAPACITY"

aiModelDeployments+=(
Expand Down
24 changes: 12 additions & 12 deletions src/gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
AzureAISearchTool,
FilePurpose,
FileSearchTool,
Tool,
)
from azure.ai.projects.models import ConnectionType
from azure.identity.aio import DefaultAzureCredential
Expand Down Expand Up @@ -120,9 +121,9 @@ def _get_file_path(file_name: str) -> str:
file_name))


async def get_available_toolset(
async def get_available_tool(
project_client: AIProjectClient,
creds: AsyncTokenCredential) -> AsyncToolSet:
creds: AsyncTokenCredential) -> Tool:
"""
Get the toolset and tool definition for the agent.

Expand All @@ -145,11 +146,9 @@ async def get_available_toolset(
if conn_id:
await create_index_maybe(project_client, creds)

ai_search = AzureAISearchTool(
return AzureAISearchTool(
index_connection_id=conn_id,
index_name=os.environ.get('AZURE_AI_SEARCH_INDEX_NAME'))

toolset.add(ai_search)
else:
logger.info(
"agent: index was not initialized, falling back to file search.")
Expand All @@ -169,21 +168,22 @@ async def get_available_toolset(
)
logger.info("agent: file store and vector store success")

file_search_tool = FileSearchTool(vector_store_ids=[vector_store.id])
toolset.add(file_search_tool)

return toolset
return FileSearchTool(vector_store_ids=[vector_store.id])


async def create_agent(ai_client: AIProjectClient,
creds: AsyncTokenCredential) -> Agent:
logger.info("Creating new agent with resources")
toolset = await get_available_toolset(ai_client, creds)

tool = await get_available_tool(ai_client, creds)
toolset = AsyncToolSet()
toolset.add(tool)

instructions = "Use AI Search always. Avoid to use base knowledge." if isinstance(tool, AzureAISearchTool) else "Use File Search always. Avoid to use base knowledge."

agent = await ai_client.agents.create_agent(
model=os.environ["AZURE_AI_AGENT_DEPLOYMENT_NAME"],
name=os.environ["AZURE_AI_AGENT_NAME"],
instructions="You are helpful assistant",
instructions=instructions,
toolset=toolset
)
return agent
Expand Down
Loading