Skip to main content

An LLM CLI plugin for Cloudflare Workers AI models.

Project description

llm-cloudflare

A plugin for the llm CLI that allows you to use the text generation models (LLMs) running on globally on Cloudflare Workers AI, including models like Llama 3.1, Mistral 7B, Gemma and a number of task-specific fine tunes.

llm-cloudflare is useful for:

  • Using and building with LLMs that may not efficiently run on your local machine (limited GPU, memory, etc) vs. having Workers AI run it on a GPU near you.
  • Validating the performance of and/or comparing multiple models.
  • Experimenting without needing to download models ahead-of-time.

Usage

Prerequisite: You'll need the llm CLI installed first.

Install and setup the plugin:

# Install the plugin from pip
llm install llm-cloudflare

# Provide a valid Workers AI token
# Docs: https://developers.cloudflare.com/workers-ai/get-started/rest-api/#1-get-api-token-and-account-id
llm keys set cloudflare

# Set your Cloudflare account ID
# Docs: https://developers.cloudflare.com/workers-ai/get-started/rest-api/#1-get-api-token-and-account-id
export CLOUDFLARE_ACCOUNT_ID="33charlonghexstringhere"

Use it by specifying a Workers AI model:

llm -m "@cf/meta/llama-3.1-8b-instruct" "Write a Cloudflare Worker in ESM format that returns an empty JSON object as a response. Show only the code."

You can set a Workers AI model as the default model in llm:

# Set Llama 3.1 8B as the default
llm models default "@cf/meta/llama-3.1-8b-instruct" 
# See what model is set as the default
llm models default
# @cf/meta/llama-3.1-8b-instruct

Available models

This plugin provides access to the text generation models (LLMs) provided by Workers AI.

To see what models are available, invoke llm models. Models prefixed with Cloudflare Workers AI are provided by this plugin.

The supported models are generated by scripts. New models thus rely on this plugin being updated periodically.

In the future, this plugin may also add support for Workers AI's embedding models for use with llm embed.

Credits

Credit to @hex for https://github.com/hex/llm-perplexity, which heavily inspired the design of this plugin.

License

Copyright Cloudflare, Inc (2024). Apache-2.0 licensed. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_cloudflare-0.5.5.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_cloudflare-0.5.5-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file llm_cloudflare-0.5.5.tar.gz.

File metadata

  • Download URL: llm_cloudflare-0.5.5.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for llm_cloudflare-0.5.5.tar.gz
Algorithm Hash digest
SHA256 aaea45d419cdbd5f8265c2e121a219d6a0bda3d7503fbe76f01efe1df549b4f6
MD5 b2ec0ce87a04c709b8fb954fd8d747b1
BLAKE2b-256 d21643e01fe3511eef56165560c638a8f389ec8e6e9e1e36879518db681af9e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_cloudflare-0.5.5.tar.gz:

Publisher: workflow.yml on elithrar/llm-cloudflare

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_cloudflare-0.5.5-py3-none-any.whl.

File metadata

  • Download URL: llm_cloudflare-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for llm_cloudflare-0.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2d75668da6713bea0a16211dddba0a20b0b64165edfbcafeebada8ffa6c4431d
MD5 d94fb8b26e3c2e4bf3fbebb0a95e9af6
BLAKE2b-256 aaa2928d37c613a78fd0f8c5a66b31e0d25d2e1924516ab82e43cce7350392d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_cloudflare-0.5.5-py3-none-any.whl:

Publisher: workflow.yml on elithrar/llm-cloudflare

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page