-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5196fe9
commit fb10151
Showing
1 changed file
with
7 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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']) |