The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.
Settings: Microsoft Azure is set up service by service (#139)
riverisbuildingb12dbdce341b
diff --git a/.changeset/azure-services.md b/.changeset/azure-services.mdnew file mode 100644index 0000000..b663eab--- /dev/null+++ b/.changeset/azure-services.md@@ -0,0 +1,5 @@+---+"openfilm": patch+---++Settings › Providers › Microsoft Azure sets up each Azure service on its own, since Azure has no one key for all of them: Azure AI Speech (voice-over) takes its resource's region and its key in two fields, instead of one `<region>:<key>` to type.diff --git a/packages/openfilm/studio/ui/src/components/settings/ProvidersSection.tsx b/packages/openfilm/studio/ui/src/components/settings/ProvidersSection.tsxindex 76b2265..cadde23 100644--- a/packages/openfilm/studio/ui/src/components/settings/ProvidersSection.tsx+++ b/packages/openfilm/studio/ui/src/components/settings/ProvidersSection.tsx@@ -11,7 +11,7 @@import React from 'react';import { ChevronRight, ExternalLink, Plus } from 'lucide-react';import { useT } from '@/i18n';-import { providerGroups, useProviders, type OwnProvider, type ProviderVerb, type ProvidersHook } from '@/lib/providers';+import { AZURE_SERVICES, azureKey, providerGroups, useProviders, type OwnProvider, type ProviderVerb, type ProvidersHook } from '@/lib/providers';import { customProblem } from './CustomServices';import { ProviderMark } from './ProviderMark';import { SettingsButton, SettingsField, SettingsGroup, SettingsInset, SettingsItem, SettingsPage, SettingsStatus, settingsError, settingsLink } from './ui';@@ -86,14 +86,18 @@ function KeyRow({ provider, hook }: { provider: OwnProvider; hook: ProvidersHookconst t = useT();const [adding, setAdding] = React.useState(false);const [draft, setDraft] = React.useState('');+ /* Microsoft Azure: each service its own region and key (AZURE_SERVICES), kept as `<region>:<key>` */+ const azure = provider.id === 'azure';+ const [region, setRegion] = React.useState('');const saving = hook.busy === provider.id;+ const key = azure ? azureKey(region, draft) : draft.trim() ? draft : null;- const close = () => { setAdding(false); setDraft(''); };+ const close = () => { setAdding(false); setDraft(''); setRegion(''); };const save = async () => {- if (!draft.trim() || saving) return;- if (await hook.saveKey(provider.id, draft)) close();+ if (!key || saving) return;+ if (await hook.saveKey(provider.id, key)) close();};- const pasteLabel = t('settings.providers.pasteKey').replaceAll('{name}', provider.name);+ const pasteLabel = azure ? t('settings.providers.key') : t('settings.providers.pasteKey').replaceAll('{name}', provider.name);return (<Row@@ -116,10 +120,31 @@ function KeyRow({ provider, hook }: { provider: OwnProvider; hook: ProvidersHookbelow={adding && !provider.source ? (<form className="pl-[34px]" onSubmit={(e) => { e.preventDefault(); void save(); }}><SettingsInset>+ {azure ? (+ <div className="flex flex-col gap-0.5">+ <span className="text-[14px] font-medium text-[var(--text)]">{AZURE_SERVICES[0]!.name}</span>+ <span className="text-[13px] text-[var(--text-faint)]">{t('settings.providers.azureNote')}</span>+ </div>+ ) : null}<div className="flex items-center gap-2">+ {azure ? (+ <div className="w-[160px] shrink-0">+ <SettingsField+ autoFocus+ autoComplete="off"+ spellCheck={false}+ value={region}+ onChange={(e) => setRegion(e.target.value)}+ onKeyDown={(e) => { if (e.key === 'Escape') { e.preventDefault(); close(); } }}+ placeholder={t('settings.providers.region')}+ aria-label={t('settings.providers.region')}+ className="font-mono placeholder:font-sans"+ />+ </div>+ ) : null}<SettingsFieldtype="password"- autoFocus+ autoFocus={!azure}autoComplete="off"spellCheck={false}value={draft}@@ -130,7 +155,7 @@ function KeyRow({ provider, hook }: { provider: OwnProvider; hook: ProvidersHookclassName="flex-1 font-mono placeholder:font-sans"/><SettingsButton variant="quiet" onClick={close}>{t('settings.providers.cancel')}</SettingsButton>- <SettingsButton type="submit" variant="primary" disabled={!draft.trim() || saving}>{t('settings.providers.save')}</SettingsButton>+ <SettingsButton type="submit" variant="primary" disabled={!key || saving}>{t('settings.providers.save')}</SettingsButton></div>{hook.problem && hook.problemFor === provider.id ? <p className={settingsError} role="alert">{hook.problem}</p> : null}{/* the environment has a key for it: connect with that one, nothing to paste */}diff --git a/packages/openfilm/studio/ui/src/i18n/en.ts b/packages/openfilm/studio/ui/src/i18n/en.tsindex 0894471..4a7b5be 100644--- a/packages/openfilm/studio/ui/src/i18n/en.ts+++ b/packages/openfilm/studio/ui/src/i18n/en.ts@@ -1761,6 +1761,9 @@ export const en = {and: 'and',keyNote: 'Your key pays the service directly. It stays on this computer and goes only to its own service.',getKey: 'Get your {name} key',+ key: 'Key',+ region: 'Region (eastus, …)',+ azureNote: "Voice-over. Each Azure service has its own key, and the region of the resource it is in: both are on the resource's Keys and Endpoint page.",pasteKey: 'Paste your {name} API key',save: 'Save',cancel: 'Cancel',diff --git a/packages/openfilm/studio/ui/src/i18n/es.ts b/packages/openfilm/studio/ui/src/i18n/es.tsindex e1f02a9..9abc224 100644--- a/packages/openfilm/studio/ui/src/i18n/es.ts+++ b/packages/openfilm/studio/ui/src/i18n/es.ts@@ -1760,6 +1760,9 @@ export const es: Words = {and: 'y',keyNote: 'Tu clave paga directamente al servicio. Se queda en este equipo y solo se envía a su propio servicio.',getKey: 'Obtener una clave de {name}',+ key: 'Clave',+ region: 'Región (eastus, …)',+ azureNote: "Locución. Cada servicio de Azure tiene su propia clave y la región de su recurso: las dos están en la página Claves y punto de conexión del recurso.",pasteKey: 'Pega tu clave de API de {name}',save: 'Guardar',cancel: 'Cancelar',diff --git a/packages/openfilm/studio/ui/src/i18n/ja.ts b/packages/openfilm/studio/ui/src/i18n/ja.tsindex fea83b0..dd6cbc3 100644--- a/packages/openfilm/studio/ui/src/i18n/ja.ts+++ b/packages/openfilm/studio/ui/src/i18n/ja.ts@@ -1760,6 +1760,9 @@ export const ja: Words = {and: 'と',keyNote: 'キーはサービスに直接支払います。キーはこのコンピューターに保存され、そのサービス以外には送信されません。',getKey: '{name} のキーを取得',+ key: 'キー',+ region: 'リージョン(eastus など)',+ azureNote: "ナレーション。Azure のサービスはそれぞれ独自のキーと、リソースのリージョンを使います。どちらもリソースの「キーとエンドポイント」ページにあります。",pasteKey: '{name} の API キーを貼り付け',save: '保存',cancel: 'キャンセル',diff --git a/packages/openfilm/studio/ui/src/i18n/ko.ts b/packages/openfilm/studio/ui/src/i18n/ko.tsindex ae4c449..013906c 100644--- a/packages/openfilm/studio/ui/src/i18n/ko.ts+++ b/packages/openfilm/studio/ui/src/i18n/ko.ts@@ -1759,6 +1759,9 @@ export const ko: Words = {and: '및',keyNote: '내 키로 서비스에 직접 결제합니다. 키는 이 컴퓨터에만 저장되며 해당 서비스로만 전송됩니다.',getKey: '{name} 키 받기',+ key: '키',+ region: '지역(eastus 등)',+ azureNote: "내레이션. Azure의 각 서비스는 자체 키와 리소스가 있는 지역을 씁니다. 둘 다 리소스의 '키 및 엔드포인트' 페이지에 있습니다.",pasteKey: '{name} API 키 붙여넣기',save: '저장',cancel: '취소',diff --git a/packages/openfilm/studio/ui/src/i18n/zh-CN.ts b/packages/openfilm/studio/ui/src/i18n/zh-CN.tsindex 0359505..99b6c2c 100644--- a/packages/openfilm/studio/ui/src/i18n/zh-CN.ts+++ b/packages/openfilm/studio/ui/src/i18n/zh-CN.ts@@ -1761,6 +1761,9 @@ export const zhCN: Words = {and: '和',keyNote: '你的密钥直接向该服务付费。它只保存在这台电脑上,且只会发送给对应的服务。',getKey: '获取 {name} 密钥',+ key: '密钥',+ region: '区域(如 eastus)',+ azureNote: "配音。Azure 的每项服务各有自己的密钥和资源所在区域,两者都在资源的“密钥和终结点”页面里。",pasteKey: '粘贴你的 {name} API 密钥',save: '保存',cancel: '取消',diff --git a/packages/openfilm/studio/ui/src/lib/providers.test.ts b/packages/openfilm/studio/ui/src/lib/providers.test.tsindex f38c51a..c795240 100644--- a/packages/openfilm/studio/ui/src/lib/providers.test.ts+++ b/packages/openfilm/studio/ui/src/lib/providers.test.ts@@ -1,6 +1,6 @@import { test } from 'node:test';import assert from 'node:assert/strict';-import { couldMake, offered, providerGroups, type OwnProvider, type ProviderVerb, type ProvidersState } from './providers.ts';+import { azureKey, couldMake, offered, providerGroups, type OwnProvider, type ProviderVerb, type ProvidersState } from './providers.ts';const own = (id: string, name: string, verbs: ProviderVerb[], source: OwnProvider['source'] = null): OwnProvider =>({ id, name, verbs, models: {}, keysUrl: '', env: '', source, last4: null });@@ -31,3 +31,10 @@ test('Providers lists the recommended ones first, in their order, and the rest uassert.equal(providerGroups([...all, p('groq', 'Groq', 'file')]).open, true);assert.equal(providerGroups([p('openai', 'OpenAI', 'env')]).open, false, 'a connected recommended one opens nothing');});++test("an Azure service's region and key go to the server as <region>:<key>, once the region is one", () => {+ assert.equal(azureKey(' EastUS ', ' a1b2c3d4e5 '), 'eastus:a1b2c3d4e5');+ assert.equal(azureKey('', 'a1b2c3d4e5'), null);+ assert.equal(azureKey('east us', 'a1b2c3d4e5'), null);+ assert.equal(azureKey('eastus', ' '), null);+});diff --git a/packages/openfilm/studio/ui/src/lib/providers.ts b/packages/openfilm/studio/ui/src/lib/providers.tsindex 06d6ddc..3e78187 100644--- a/packages/openfilm/studio/ui/src/lib/providers.ts+++ b/packages/openfilm/studio/ui/src/lib/providers.ts@@ -70,6 +70,18 @@ export function providerGroups<P extends Pick<OwnProvider, 'id' | 'name' | 'sourreturn { recommended, more, open: more.some((p) => p.source) };}+/**+ * Microsoft Azure's services, each set up with its own key and its resource's region (they are not one key, as+ * Google's are): Azure AI Speech makes the voice-over. More go here as OpenFilm uses them.+ */+export const AZURE_SERVICES = [{ id: 'speech', name: 'Azure AI Speech', verbs: ['tts'] as ProviderVerb[] }];++/** An Azure service's key as the server takes it: `<region>:<key>`; null while the region is not one (eastus, …). */+export function azureKey(region: string, key: string): string | null {+ const place = region.trim().toLowerCase();+ return /^[a-z0-9]+$/.test(place) && key.trim() ? `${place}:${key.trim()}` : null;+}+/** Whether any provider here, connected or not, can make `verb`. */export const offered = (state: ProvidersState, verb: ProviderVerb) => state.providers.some((p) => p.verbs.includes(verb));