|
1265 | 1265 | For more information on how to use GraphQL at Cloudflare, refer to the [Cloudflare GraphQL Analytics API](https://developers.cloudflare.com/analytics/graphql-api). |
1266 | 1266 | It contains a full overview of Cloudflare's GraphQL features and keywords. |
1267 | 1267 |
|
| 1268 | +## Cloudflare AI |
| 1269 | + |
| 1270 | +See https://blog.cloudflare.com/workers-ai-update-stable-diffusion-code-llama-workers-ai-in-100-cities/ for the introduction, |
| 1271 | +along with https://developers.cloudflare.com/workers-ai/models/ for the nitty gritty details. |
| 1272 | + |
| 1273 | +There are two examples for AI calls included with the code. |
| 1274 | + |
| 1275 | +```bash |
| 1276 | +$ python examples/example_ai_images.py A happy llama running through an orange cloud > /tmp/image.png |
| 1277 | +$ |
| 1278 | +$ file /tmp/image.png |
| 1279 | +/tmp/image.png: PNG image data, 1024 x 1024, 8-bit/color RGB, non-interlaced |
| 1280 | +$ |
| 1281 | +``` |
| 1282 | + |
| 1283 | +```bash |
| 1284 | +$ python examples/example_ai_translate.py I\'ll have an order of the moule frites |
| 1285 | +Je vais avoir une commande des frites de moule |
| 1286 | +$ |
| 1287 | +``` |
| 1288 | + |
| 1289 | +This is presently work-in-progress because of the non-Python calling method. The syntax could change in the future. |
| 1290 | +The examples will be updated. |
| 1291 | + |
| 1292 | +They can also be called via `cli4`. |
| 1293 | + |
| 1294 | +```bash |
| 1295 | +$ cli4 --image --post text="I'll have an order of the moule frites" source_lang=english target_lang=french /accounts/:AccountID/ai/run/@cf/meta/m2m100-1.2b |
| 1296 | +{'translated_text': 'Je vais avoir une commande des frites de moule'} |
| 1297 | +$ |
| 1298 | +``` |
| 1299 | + |
| 1300 | +Presently you will need the following in your `cloudflare.cfg` file. |
| 1301 | + |
| 1302 | +```bash |
| 1303 | +$ cat ~/.cloudflare/cloudflare.cfg |
| 1304 | +[CloudFlare] |
| 1305 | +global_request_timeout = 120 |
| 1306 | +max_request_retries = 1 |
| 1307 | +extras = |
| 1308 | + /accounts/:id/ai/run/@cf/meta/llama-2-7b-chat-fp16 |
| 1309 | + /accounts/:id/ai/run/@cf/meta/llama-2-7b-chat-int8 |
| 1310 | + /accounts/:id/ai/run/@cf/mistral/mistral-7b-instruct-v0.1 |
| 1311 | + /accounts/:id/ai/run/@cf/openai/whisper |
| 1312 | + /accounts/:id/ai/run/@cf/meta/m2m100-1.2b |
| 1313 | + /accounts/:id/ai/run/@cf/huggingface/distilbert-sst-2-int8 |
| 1314 | + /accounts/:id/ai/run/@cf/microsoft/resnet-50 |
| 1315 | + /accounts/:id/ai/run/@cf/stabilityai/stable-diffusion-xl-base-1.0 |
| 1316 | + /accounts/:id/ai/run/@cf/baai/bge-base-en-v1.5 |
| 1317 | + /accounts/:id/ai/run/@cf/baai/bge-large-en-v1.5 |
| 1318 | + /accounts/:id/ai/run/@cf/baai/bge-small-en-v1.5 |
| 1319 | + |
| 1320 | +$ |
| 1321 | +``` |
| 1322 | + |
| 1323 | +Along with a version of the library above `2.14.1`. |
| 1324 | + |
1268 | 1325 | ## Implemented API calls |
1269 | 1326 |
|
1270 | 1327 | The **--dump** argument to cli4 will produce a list of all the call implemented within the library. |
|
0 commit comments