From fb1015130ceead925166b6a2961dcad23a8766f4 Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Mon, 22 Apr 2024 14:30:42 +1000 Subject: [PATCH] update example to use kwargs --- examples/workers/ai/demo.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/workers/ai/demo.py b/examples/workers/ai/demo.py index 00f68eeaf..ba29c427e 100644 --- a/examples/workers/ai/demo.py +++ b/examples/workers/ai/demo.py @@ -1,19 +1,21 @@ import os import sys from cloudflare import Cloudflare -from cloudflare.types.workers.ai_run_params import Translation +from cloudflare.types.workers.ai_run_response import Translation account_id = os.getenv("CLOUDFLARE_ACCOUNT_ID") if account_id is None: sys.exit("CLOUDFLARE_ACCOUNT_ID is not defined") + client = Cloudflare() -input=Translation( +t = client.workers.ai.run( + "@cf/meta/m2m100-1.2b", + account_id=account_id, text="I'll have an order of the moule frites", - source_lang="english", target_lang="french", + source_lang="english", ) -t = client.workers.ai.run("@cf/meta/m2m100-1.2b", account_id=account_id, body=input) -print(t) +print(t['translated_text'])