Skip to content

Commit a210295

Browse files
CopilotGermey
andauthored
sync localization provider spec
Co-authored-by: Germey <8678661+Germey@users.noreply.github.com>
1 parent f07378a commit a210295

7 files changed

Lines changed: 477 additions & 16 deletions

File tree

go/provider_localization.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/provider_localization_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package acedatacloud
2+
3+
import "testing"
4+
5+
func TestLocalizationTranslateAcceptsMarkdownInput(t *testing.T) {
6+
body := LocalizationTranslateRequest{
7+
Input: "# Title",
8+
Locale: "de",
9+
Extension: "md",
10+
}.toBody()
11+
if body["input"] != "# Title" || body["locale"] != "de" || body["extension"] != "md" {
12+
t.Fatalf("unexpected localization body: %#v", body)
13+
}
14+
}

python/src/acedatacloud/resources/providers/localization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ def __init__(self, transport: Any) -> None:
5252
def translate(
5353
self,
5454
*,
55-
input: dict[str, Any],
55+
input: str | dict[str, Any],
5656
locale: LocalizationLocale,
57-
extension: Literal["json", "md"],
57+
extension: Literal["md", "json"],
5858
model: Literal["gpt-3.5", "gpt-4"] | None = None,
5959
callback_url: str | None = None,
6060
**extra: Any,
@@ -81,9 +81,9 @@ def __init__(self, transport: Any) -> None:
8181
async def translate(
8282
self,
8383
*,
84-
input: dict[str, Any],
84+
input: str | dict[str, Any],
8585
locale: LocalizationLocale,
86-
extension: Literal["json", "md"],
86+
extension: Literal["md", "json"],
8787
model: Literal["gpt-3.5", "gpt-4"] | None = None,
8888
callback_url: str | None = None,
8989
**extra: Any,

python/tests/test_providers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,24 @@ def test_extra_parameters_pass_through(client):
224224
assert transport.request.call_args.kwargs["json"]["brand_new_flag"] is True
225225

226226

227+
def test_localization_accepts_markdown_input(client):
228+
input_hint = typing.get_type_hints(type(client.localization).translate)["input"]
229+
assert str in typing.get_args(input_hint)
230+
231+
transport = Mock()
232+
transport.request.return_value = {"locale": "de", "data": "# Titel"}
233+
client.localization._transport = transport
234+
235+
client.localization.translate(input="# Title", locale="de", extension="md")
236+
237+
assert transport.request.call_args.args == ("POST", "/localization/translate")
238+
assert transport.request.call_args.kwargs["json"] == {
239+
"input": "# Title",
240+
"locale": "de",
241+
"extension": "md",
242+
}
243+
244+
227245
@pytest.mark.parametrize("name", GENERATED)
228246
def test_every_provider_has_a_callable_method(client, name):
229247
provider = getattr(client, name)

scripts/specs/f7322d41-51dc-48b2-8584-dabc632b5031.json

Lines changed: 408 additions & 1 deletion
Large diffs are not rendered by default.

typescript/src/resources/providers/localization.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import { Transport } from '../../runtime/transport';
99

1010

1111
export interface LocalizationTranslateOptions {
12-
/** Please provide the content that needs to be translated. */
13-
input: Record<string, unknown>;
14-
/** The target language area to be translated to. */
12+
/** Localization Translate Input */
13+
input: string | Record<string, unknown>;
14+
/** Localization Translate Locale */
1515
locale: "en" | "de" | "pt" | "es" | "fr" | "zh-CN" | "zh-TW" | "it" | "ko" | "ja" | "ru" | "pl" | "fi" | "sv" | "el" | "uk" | "ar" | "sr";
16-
/** The file type of the input text (such as `json` or `md`). */
17-
extension: "json" | "md";
18-
/** The large language model used for translation is `gpt-3.5` by default. */
16+
/** Localization Translate Extension */
17+
extension: "md" | "json";
18+
/** Localization Translate Model */
1919
model?: "gpt-3.5" | "gpt-4";
2020
callbackUrl?: string;
2121
/** Any parameter added upstream before the SDK is regenerated. */
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Localization } from '../src/resources/providers/localization';
2+
3+
describe('Localization provider', () => {
4+
it('serializes markdown string input', async () => {
5+
const request = jest.fn().mockResolvedValue({ locale: 'de', data: '# Titel' });
6+
const localization = new Localization({ request } as any);
7+
8+
await localization.translate({
9+
input: '# Title',
10+
locale: 'de',
11+
extension: 'md',
12+
});
13+
14+
expect(request).toHaveBeenCalledWith('POST', '/localization/translate', {
15+
json: {
16+
input: '# Title',
17+
locale: 'de',
18+
extension: 'md',
19+
},
20+
});
21+
});
22+
});

0 commit comments

Comments
 (0)