fix(stt): xAI 400 при format=true без language — убираем поле format
Smoke на IFT: xAI отвечает 400 "Field 'language' is required when 'format' is true" → бэк маппит в 502 upstream_error. Проверено curl: без поля format эндпоинт /v1/stt работает (200), язык определяется автоматически. Убрано поле format из multipart xAI-адаптера, eunit обновлён (полный прогон: 1211 тестов зелёные). Refs EventHub/EventHubBack#79
This commit is contained in:
@@ -125,8 +125,9 @@ env_int(Name, Default) ->
|
||||
%%%===================================================================
|
||||
|
||||
call_provider(xai, Url, Key, Audio, CType) ->
|
||||
%% xAI: multipart; опциональные поля до поля file, file — последним.
|
||||
Body = build_multipart([{<<"format">>, <<"true">>}], Audio, <<"voice.dat">>, CType),
|
||||
%% xAI: multipart без опциональных полей — язык определяется авто
|
||||
%% (format=true требует явный language и отключает автоопределение).
|
||||
Body = build_multipart([], Audio, <<"voice.dat">>, CType),
|
||||
post_and_parse(xai, Url, Key, Body);
|
||||
call_provider(openai, Url, Key, Audio, CType) ->
|
||||
Model = case env_bin("STT_MODEL") of
|
||||
|
||||
@@ -56,13 +56,10 @@ test_xai_success() ->
|
||||
?assertEqual(?XAI_URL, Url),
|
||||
?assertEqual([{"authorization", "Bearer test-key"}], Headers),
|
||||
?assertMatch("multipart/form-data; boundary=" ++ _, ContentType),
|
||||
?assertMatch({_, _}, binary:match(Body, <<"name=\"format\"">>)),
|
||||
?assertMatch({_, _}, binary:match(Body, <<"name=\"file\"">>)),
|
||||
?assertMatch({_, _}, binary:match(Body, <<"audio-bytes">>)),
|
||||
%% Поле file — последнее (требование xAI).
|
||||
{PosFormat, _} = binary:match(Body, <<"name=\"format\"">>),
|
||||
{PosFile, _} = binary:match(Body, <<"name=\"file\"">>),
|
||||
?assert(PosFormat < PosFile).
|
||||
%% Без поля format — язык определяется авто (format=true требует language).
|
||||
?assertEqual(nomatch, binary:match(Body, <<"name=\"format\"">>)).
|
||||
|
||||
test_openai_adapter() ->
|
||||
os:putenv("STT_PROVIDER", "openai"),
|
||||
|
||||
Reference in New Issue
Block a user