From 52a9696303af8223bdeef28786d953d63837c2d3 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Fri, 29 Dec 2023 12:10:32 +0530 Subject: [PATCH] (docs) cloudflare --- .../docs/providers/cloudflare_workers.md | 58 +++++++++++++++++++ docs/my-website/sidebars.js | 1 + 2 files changed, 59 insertions(+) create mode 100644 docs/my-website/docs/providers/cloudflare_workers.md diff --git a/docs/my-website/docs/providers/cloudflare_workers.md b/docs/my-website/docs/providers/cloudflare_workers.md new file mode 100644 index 000000000..34c201cbf --- /dev/null +++ b/docs/my-website/docs/providers/cloudflare_workers.md @@ -0,0 +1,58 @@ +# Cloudflare Workers AI +https://developers.cloudflare.com/workers-ai/models/text-generation/ + +## API Key +```python +# env variable +os.environ['CLOUDFLARE_API_KEY'] = "3dnSGlxxxx" +os.environ['CLOUDFLARE_ACCOUNT_ID'] = "03xxxxx" +``` + +## Sample Usage +```python +from litellm import completion +import os + +os.environ['CLOUDFLARE_API_KEY'] = "3dnSGlxxxx" +os.environ['CLOUDFLARE_ACCOUNT_ID'] = "03xxxxx" + +response = completion( + model="cloudflare/@cf/meta/llama-2-7b-chat-int8", + messages=[ + {"role": "user", "content": "hello from litellm"} + ], +) +print(response) +``` + +## Sample Usage - Streaming +```python +from litellm import completion +import os + +os.environ['CLOUDFLARE_API_KEY'] = "3dnSGlxxxx" +os.environ['CLOUDFLARE_ACCOUNT_ID'] = "03xxxxx" + +response = completion( + model="cloudflare/@hf/thebloke/codellama-7b-instruct-awq", + messages=[ + {"role": "user", "content": "hello from litellm"} + ], + stream=True +) + +for chunk in response: + print(chunk) +``` + +## Supported Models +All models listed here https://developers.cloudflare.com/workers-ai/models/text-generation/ are supported + +| Model Name | Function Call | +|-----------------------------------|----------------------------------------------------------| +| @cf/meta/llama-2-7b-chat-fp16 | `completion(model="mistral/mistral-tiny", messages)` | +| @cf/meta/llama-2-7b-chat-int8 | `completion(model="mistral/mistral-small", messages)` | +| @cf/mistral/mistral-7b-instruct-v0.1 | `completion(model="mistral/mistral-medium", messages)` | +| @hf/thebloke/codellama-7b-instruct-awq | `completion(model="codellama/codellama-medium", messages)` | + + diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js index 9cb74ebf1..b2cd0fd9d 100644 --- a/docs/my-website/sidebars.js +++ b/docs/my-website/sidebars.js @@ -75,6 +75,7 @@ const sidebars = { "providers/anyscale", "providers/perplexity", "providers/vllm", + "providers/cloudflare_workers", "providers/deepinfra", "providers/ai21", "providers/nlp_cloud",