다음을 통해 공유


Bicep을 사용하여 Azure OpenAI 서비스 배포

중요합니다

2026년 1월 기준으로 AI 셸 프로젝트는 더 이상 활발히 유지보수되지 않고 있습니다. 이 프로젝트는 공학적 관점에서 보관된 것으로 간주되어야 합니다.

AIShell에서 openai-gpt 에이전트는 공용 OpenAI 인스턴스 또는 Azure OpenAI 배포와 함께 사용할 수 있습니다. Azure OpenAI Service에는 추가 기능이 있고 관리 효율성이 향상되므로 사용하는 것이 좋습니다. 이 문서에서는 Bicep을 사용하여 Azure OpenAI 서비스의 배포 및 인스턴스에 대한 단계별 지침을 제공합니다.

Azure OpenAI Service에서 AIShell을 사용하려면 다음 Azure 리소스가 필요합니다.

  • Azure OpenAI 서비스 계정 - 여러 모델 배포를 포함하는 리소스입니다.
  • Azure OpenAI 배포 - API를 사용하여 응답을 생성하여 호출할 수 있는 모델 배포입니다.

필수 구성 요소

시작하기 전에 다음 필수 구성 요소가 있는지 확인합니다.

  • 활성 Azure 구독
  • Azure CLI 또는 로컬로 설치된 Azure PowerShell 또는 Azure Cloud Shell에 대한 액세스
  • Azure 구독에서 리소스를 만들 수 있는 적절한 권한

배포 단계

다음 단계에서는 다음 작업을 안내합니다.

  1. Bicep 파일 다운로드 및 수정
  2. Azure OpenAI 서비스 배포
  3. 배포를 사용하도록 에이전트 구성

1. Bicep 파일 다운로드 및 수정

AIShell 리포지토리에서 main.bicep 파일을 다운로드합니다.

./main.bicep 파일 맨 위에 있는 매개 변수를 수정하여 고유한 값을 포함해야 합니다. 꺾쇠 괄호(< >)의 자리 표시자를 고유한 값으로 바꿉니다.

@description('This is the name of your AI Service Account')
param aiserviceaccountname string = '<Insert own account name>'

@description('Custom domain name for the endpoint')
param customDomainName string = '<Insert own unique domain name>'

@description('Name of the deployment')
param modeldeploymentname string = '<Insert own deployment name>'

@description('The model being deployed')
param model string = 'gpt-4'

@description('Version of the model being deployed')
param modelversion string = 'turbo-2024-04-09'

@description('Capacity for specific model used')
param capacity int = 80

@description('Location for all resources.')
param location string = resourceGroup().location

@allowed([
  'S0'
])
param sku string = 'S0'

이 배포의 경우 Bicep 파일은 다음 기본값을 사용합니다.

  • Azure OpenAI 계정의 위치가 리소스 그룹의 위치로 설정됩니다.
  • AI 모델은 버전 gpt-4turbo-2024-04-09.

특정 요구 사항에 맞게 이러한 설정을 변경할 수 있습니다. 사용 가능한 모델에 대한 자세한 내용은 azure OpenAI Service 모델참조하세요. 사용하는 모델을 기반으로 배포의 용량을 수정해야 할 수도 있습니다. 용량 설정에 대한 자세한 내용은 Azure OpenAI Service 할당량 및 제한참조하세요.

2. Azure OpenAI 서비스 배포

Bicep 파일 매개 변수를 수정한 후에는 사용자 고유의 Azure OpenAI 인스턴스를 배포할 준비가 된 것입니다. Azure CLI 또는 Azure PowerShell을 사용하여 Bicep 파일을 배포할 수 있습니다.

Azure CLI를 사용하여 배포

다음 Azure CLI 명령을 사용하여 Azure OpenAI 서비스를 배포합니다. 다음 명령은 Bash 세션에서 실행될 예정입니다. 꺾쇠 괄호(< >)의 자리 표시자를 고유한 값으로 바꿉니다.

로컬 또는 Azure Cloud Shell에서 명령을 실행할 수 있습니다. 로컬로 실행하는 경우 az login 사용하여 Azure 계정에 로그인하고 az account set --subscription <subscription name>사용하여 구독을 설정해야 합니다.

az deployment group create \
    --resource-group '<resource group name>' \
    --template-file ./main.bicep

# Get the endpoint and key of the deployment
az cognitiveservices account show \
    --name '<account name>'
    --resource-group '<resource group name>' | jq -r .properties.endpoint

az cognitiveservices account keys list \
    --name '<account name>' \
    --resource-group  '<resource group name>' | jq -r .key1

Azure PowerShell을 사용하여 배포

다음 Azure PowerShell 명령을 사용하여 Azure OpenAI 서비스를 배포합니다. 꺾쇠 괄호(< >)의 자리 표시자를 고유한 값으로 바꿉니다.

로컬 또는 Azure Cloud Shell에서 명령을 실행할 수 있습니다. 로컬로 실행하는 경우 Connect-AzAccount 사용하여 Azure 계정에 로그인하고 Set-AzContext -SubscriptionId <subscription id>사용하여 구독을 설정해야 합니다.

$AzResourceGroupDeploymentSplat = @{
    ResourceGroupName = '<resource group name>'
    TemplateFile = './main.bicep'
}
New-AzResourceGroupDeployment @AzResourceGroupDeploymentSplat

# Get the endpoint and key of the deployment
$AzCognitiveServicesAccountSplat = @{
    ResourceGroupName = '<resource group name>'
    Name = '<account name>'
}
Get-AzCognitiveServicesAccount @AzCognitiveServicesAccountSplat  |
    Select-Object -Property Endpoint

Get-AzCognitiveServicesAccountKey @AzCognitiveServicesAccountSplat |
    Select-Object -Property Key1

3. 배포를 사용하도록 에이전트 구성

배포에 대한 엔드포인트와 키가 있으므로 openai-gpt 에이전트를 구성해야 합니다. 구성은 JSON 파일에 저장됩니다.

다음 단계를 사용하여 JSON 구성을 편집합니다.

  1. AIShell을 시작하고 에이전트 목록에서 openai-gpt 에이전트를 선택합니다.

  2. AIShell 명령 프롬프트에서 /agent config 명령을 실행합니다. 이 명령은 JSON 구성 파일을 엽니다.

  3. JSON 파일의 꺾쇠 괄호(< >)에 있는 자리 표시자 값을 Azure OpenAI 배포에서 가져온 엔드포인트 및 키 값으로 바꿉니다. 다음 JSON은 업데이트하려는 구성 설정의 예를 보여줍니다.

    {
      // Declare GPT instances.
      "GPTs": [
          {
            "Name": "ps-az-gpt4",
            "Description": "<insert description here>",
            "Endpoint": "<insert endpoint here>",
            "Deployment": "<insert deployment name here>",
            "ModelName": "gpt-4",
            "Key": "<insert key here>",
            "SystemPrompt": "1. You are a helpful and friendly assistant with expertise in PowerShell scripting and command line.\n2. Assume user is using the operating system `osx` unless otherwise specified.\n3. Use the `code block` syntax in markdown to encapsulate any part in responses that is code, YAML, JSON or XML, but not table.\n4. When encapsulating command line code, use '```powershell' if it's PowerShell command; use '```sh' if it's non-PowerShell CLI command.\n5. When generating CLI commands, never ever break a command into multiple lines. Instead, always list all parameters and arguments of the command on the same line.\n6. Please keep the response concise but to the point. Do not overexplain."
          }
      ],
      // Specify the default GPT instance to use for user query.
      // For example: "ps-az-gpt4"
      "Active": "ps-az-gpt4"
    }
    
  4. JSON 파일을 저장하고 편집기를 닫습니다.

결론

Azure OpenAI 서비스를 성공적으로 배포하고 배포와 통신하도록 openai-gpt 에이전트를 구성했습니다. Azure OpenAI 배포에 대한 모델 학습, 필터 및 설정에 대한 자세한 내용은 Azure OpenAI Service 설명서참조하세요.

메모

Bicep 파일을 사용하여 Azure OpenAI 서비스를 배포하는 방법에 대한 지침에 대해 Sebastian Jensen에게 감사드립니다. 이 문서는 매체에 대한 그의 블로그 게시물에서 영감을 받아 허가와 함께 사용되었습니다. Bicep통해 LLM 배포를 사용하여 Azure OpenAI 서비스를 배포하는 원래 게시물을 잠시 읽어보세요.