53 lines
1.9 KiB
PowerShell
53 lines
1.9 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[string]$Model = "doubao-seed-2-0-lite-260215"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$runtimeDirectory = Join-Path $scriptDirectory "runtime"
|
|
$environmentFile = Join-Path $runtimeDirectory "local-rtc.env"
|
|
$apiKeyFile = Join-Path $runtimeDirectory "ark-api-key"
|
|
$utf8NoBom = [System.Text.UTF8Encoding]::new($false)
|
|
|
|
if (-not (Test-Path -LiteralPath $environmentFile -PathType Leaf)) {
|
|
throw "Run .\deploy\local-rtc\configure.ps1 before configuring Ark summaries."
|
|
}
|
|
|
|
$secureKey = Read-Host "Ark API Key (input is hidden)" -AsSecureString
|
|
$pointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureKey)
|
|
try {
|
|
$apiKey = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($pointer)
|
|
}
|
|
finally {
|
|
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($pointer)
|
|
}
|
|
if ([string]::IsNullOrWhiteSpace($apiKey)) {
|
|
throw "Ark API Key is required."
|
|
}
|
|
|
|
$selectedModel = Read-Host "Ark content Model ID or Endpoint ID [$Model]"
|
|
if ([string]::IsNullOrWhiteSpace($selectedModel)) {
|
|
$selectedModel = $Model
|
|
}
|
|
$selectedModel = $selectedModel.Trim()
|
|
if ([string]::IsNullOrWhiteSpace($selectedModel)) {
|
|
throw "Ark content model is required."
|
|
}
|
|
|
|
$settings = [ordered]@{}
|
|
foreach ($line in Get-Content -LiteralPath $environmentFile) {
|
|
if ($line -match '^([^#=][^=]*)=(.*)$') {
|
|
$settings[$matches[1].Trim()] = $matches[2]
|
|
}
|
|
}
|
|
$settings["CONTENT_GENERATOR"] = "ark"
|
|
$settings["ARK_CONTENT_MODEL"] = $selectedModel
|
|
|
|
$environmentContent = ($settings.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join "`n"
|
|
[IO.File]::WriteAllText($apiKeyFile, $apiKey.Trim(), $utf8NoBom)
|
|
[IO.File]::WriteAllText($environmentFile, $environmentContent + "`n", $utf8NoBom)
|
|
|
|
Write-Host "Ark summary configuration updated. Existing RTC and voice credentials were not changed." -ForegroundColor Green
|
|
Write-Host "Next: .\deploy\local-rtc\start.ps1" -ForegroundColor Green
|