diff --git a/docs/my-website/docs/tutorials/model_fallbacks.md b/docs/my-website/docs/tutorials/model_fallbacks.md new file mode 100644 index 0000000000..b524a647c0 --- /dev/null +++ b/docs/my-website/docs/tutorials/model_fallbacks.md @@ -0,0 +1,32 @@ +# Basic Model Fallbacks w/ LiteLLM + +Here's how you can implement model fallbacks across 3 LLM providers (OpenAI, Anthropic, Azure) using LiteLLM. + +## 1. Install LiteLLM +```python +!pip install litellm +``` + +## 2. Complete Code +```python +import litellm +from litellm import embedding, completion + +# set ENV variables +os.environ["OPENAI_API_KEY"] = "" +os.environ["ANTHROPIC_API_KEY"] = "" +os.environ["AZURE_API_KEY"] = "" +os.environ["AZURE_API_BASE"] = "" +os.environ["AZURE_API_VERSION"] = "" + +model_fallback_list = ["claude-instant-1", "gpt-3.5-turbo", "chatgpt-test"] + +user_message = "Hello, how are you?" +messages = [{ "content": user_message,"role": "user"}] + +for model in model_fallback_list: + try: + response = completion(model=model, messages=messages) + except Exception as e: + print(f"error occurred: {traceback.format_exc()}") +``` \ No newline at end of file diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js index f6e98008fb..552384fda5 100644 --- a/docs/my-website/sidebars.js +++ b/docs/my-website/sidebars.js @@ -18,7 +18,7 @@ const sidebars = { // But you can create a sidebar manually tutorialSidebar: [ { type: "doc", id: "index" }, // NEW - 'tutorials/ab_test_llms', + 'tutorials/compare_llms', { type: "category", label: "Completion()", @@ -30,32 +30,32 @@ const sidebars = { items: ["embedding/supported_embedding"], }, 'completion/supported', - { - type: "category", - label: "Providers", - link: { - type: 'generated-index', - title: 'Providers', - description: 'Learn how to deploy + call models from different providers on LiteLLM', - slug: '/providers', - }, - items: ["providers/huggingface"], - }, + // { + // type: "category", + // label: "Providers", + // link: { + // type: 'generated-index', + // title: 'Providers', + // description: 'Learn how to deploy + call models from different providers on LiteLLM', + // slug: '/providers', + // }, + // items: ["providers/huggingface"], + // }, "token_usage", "exception_mapping", - // 'debugging/hosted_debugging', 'debugging/local_debugging', { type: 'category', label: 'Tutorials', items: [ + "tutorials/model_fallbacks", + 'tutorials/ab_test_llms', 'tutorials/huggingface_tutorial', 'tutorials/TogetherAI_liteLLM', - 'tutorials/compare_llms', 'tutorials/finetuned_chat_gpt', 'tutorials/text_completion', 'tutorials/litellm_Test_Multiple_Providers', - "tutorials/first_playground" + "tutorials/first_playground", ], }, {