From 51729aee02376b43c7ad91c6f972254cb0dc47c8 Mon Sep 17 00:00:00 2001 From: Yamac Ay Date: Fri, 18 Sep 2026 10:58:26 +0200 Subject: [PATCH] docs: add orchestration fallback --- .../examples/orchestration-service2.ipynb | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/packages/gen/docs/gen_ai_hub/examples/orchestration-service2.ipynb b/packages/gen/docs/gen_ai_hub/examples/orchestration-service2.ipynb index 52a6e21..fb3a32f 100644 --- a/packages/gen/docs/gen_ai_hub/examples/orchestration-service2.ipynb +++ b/packages/gen/docs/gen_ai_hub/examples/orchestration-service2.ipynb @@ -207,6 +207,59 @@ "print(result.final_result.choices[0].message.content)" ] }, + { + "cell_type": "markdown", + "id": "077b1f69", + "metadata": {}, + "source": [ + "(orchestration_fallback)=\n", + "### Using Fallback Configurations\n", + "\n", + "You can provide multiple `ModuleConfig` objects to `OrchestrationConfig` instead of a single one.\n", + "The configurations are tried in order: if a call with one configuration fails, the next one is used as fallback.\n", + "\n", + "This works for both regular and streaming calls.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "827c4812", + "metadata": {}, + "outputs": [], + "source": [ + "from gen_ai_hub.orchestration_v2 import (SystemMessage, UserMessage, Template, PromptTemplatingModuleConfig,\n", + " LLMModelDetails, ModuleConfig, OrchestrationConfig, OrchestrationService)\n", + "\n", + "working_config = ModuleConfig(\n", + " prompt_templating=PromptTemplatingModuleConfig(\n", + " prompt=Template(template=[UserMessage(content=\"What is the longest river on planet earth?\")]),\n", + " model=LLMModelDetails(name=\"gpt-4o-mini\"),\n", + " )\n", + ")\n", + "\n", + "second_working_config = ModuleConfig(\n", + " prompt_templating=PromptTemplatingModuleConfig(\n", + " prompt=Template(template=[UserMessage(content=\"What is the longest river on planet earth?\")]),\n", + " model=LLMModelDetails(name=\"gpt-4o\"),\n", + " )\n", + ")\n", + "\n", + "broken_config = ModuleConfig(\n", + " prompt_templating=PromptTemplatingModuleConfig(\n", + " prompt=Template(template=[UserMessage(content=\"What is the longest river on planet earth?\")]),\n", + " model=LLMModelDetails(name=\"dummy-model\"),\n", + " )\n", + ")\n", + "\n", + "# broken_config is tried first and will fail, so working_config is used as fallback\n", + "config = OrchestrationConfig(modules=[broken_config, working_config, second_working_config])\n", + "\n", + "service = OrchestrationService(config=config)\n", + "result = service.run()\n", + "print(result.final_result.choices[0].message.content)" + ] + }, { "cell_type": "markdown", "id": "1bd44dc91b57793d",