From 41183158e72bb4142cba5842cb11e32b0a93bbc2 Mon Sep 17 00:00:00 2001 From: Yamac Ay Date: Tue, 8 Sep 2026 12:52:59 +0200 Subject: [PATCH 1/2] fix docs of harmonized integration --- .../docs/gen_ai_hub/examples/gen_ai_hub.ipynb | 206 +++++++++--------- 1 file changed, 106 insertions(+), 100 deletions(-) diff --git a/packages/gen/docs/gen_ai_hub/examples/gen_ai_hub.ipynb b/packages/gen/docs/gen_ai_hub/examples/gen_ai_hub.ipynb index 2a6ecb3f..8f827d12 100644 --- a/packages/gen/docs/gen_ai_hub/examples/gen_ai_hub.ipynb +++ b/packages/gen/docs/gen_ai_hub/examples/gen_ai_hub.ipynb @@ -19,16 +19,16 @@ ] }, { - "metadata": {}, "cell_type": "raw", + "id": "56352a2c6587b70e", + "metadata": {}, "source": [ "As of now, there are integrations with three types of native client SDKs (OpenAI, Google, Amazon).\n", "\n", "The following contains at least one example per SDK. Note: Some providers share the same interface and can be consumed using the same api. For example, Anthropic Claude and Amazon Nova can be used with the Amazon api.\n", "\n", "The list of the available models can be found here: [](supported_models)" - ], - "id": "56352a2c6587b70e" + ] }, { "cell_type": "markdown", @@ -58,8 +58,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "f3361412ae0479ce", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.native.openai import completions\n", "\n", @@ -70,9 +72,7 @@ " temperature=0\n", ")\n", "print(response)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -85,8 +85,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "c48708a4a05d33bb", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.native.openai import chat\n", "\n", @@ -99,14 +101,14 @@ "response = chat.completions.create(**kwargs)\n", "\n", "print(response)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "code", + "execution_count": null, "id": "ddb67637b98c53b5", "metadata": {}, + "outputs": [], "source": [ "#example where model_name is passed with model_version parameter\n", "\n", @@ -119,13 +121,14 @@ "\n", "response = chat.completions.create(model_name='gpt-4o-mini', model_version=\"latest\", messages=messages)\n", "print(response)" - ], - "outputs": [], - "execution_count": null + ] }, { - "metadata": {}, "cell_type": "code", + "execution_count": null, + "id": "73277283655f9e8a", + "metadata": {}, + "outputs": [], "source": [ "#example where deployment_id is passed instead of model_name parameter\n", "\n", @@ -138,28 +141,28 @@ "\n", "response = chat.completions.create(deployment_id=\"dcef02e219ae4916\", messages=messages)\n", "print(response)" - ], - "id": "73277283655f9e8a", - "outputs": [], - "execution_count": null + ] }, { - "metadata": {}, "cell_type": "markdown", + "id": "ab5d20c9c0316f09", + "metadata": {}, "source": [ - "(responses_api)=\n", + "(responses_api)=\n", "#### Responses API\n", "\n", "`Responses` equivalent to `openai.Responses`.\n", "Below is an example usage of Responses in generative AI hub sdk.\n", "\n", "see https://developers.openai.com/api/docs/guides/migrate-to-responses" - ], - "id": "ab5d20c9c0316f09" + ] }, { - "metadata": {}, "cell_type": "code", + "execution_count": null, + "id": "3b0dd159b95cecf1", + "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.native.openai import responses\n", "\n", @@ -169,10 +172,7 @@ " input=\"What is the capital of France?\",\n", ")\n", "print(response.output_text)" - ], - "id": "3b0dd159b95cecf1", - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -187,8 +187,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "15c782df8d446d3a", "metadata": {}, + "outputs": [], "source": [ "from pydantic import BaseModel\n", "from gen_ai_hub.proxy.native.openai import chat, responses\n", @@ -213,9 +215,7 @@ " text_format=Person\n", ")\n", "print(response.output_parsed) # Fully typed Person" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -235,8 +235,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "a433664b7e7cdc", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.native.google_genai import Client\n", "from gen_ai_hub.proxy import get_proxy_client\n", @@ -253,9 +255,7 @@ "response = client.models.generate_content(model=\"gemini-2.0-flash\",\n", " contents=\"Explain the theory of relativity in simple terms.\")\n", "print(response)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -267,8 +267,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "147a33eb04a093c0", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.native.google_genai import Client\n", "from gen_ai_hub.proxy import get_proxy_client\n", @@ -285,9 +287,7 @@ "\n", "for chunk in response_stream:\n", " print(\"Chunk: \", chunk.text)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -299,8 +299,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "eb1aa581bf7a45cf", "metadata": {}, + "outputs": [], "source": [ "from google.genai import types\n", "from gen_ai_hub.proxy.native.google_genai import Client\n", @@ -326,9 +328,7 @@ " config=types.GenerateContentConfig(tools=[get_current_weather]),\n", ")\n", "response" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -348,8 +348,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "78fcab8a1acdf8bb", "metadata": {}, + "outputs": [], "source": [ "import json\n", "from gen_ai_hub.proxy.native.amazon import Session\n", @@ -369,9 +371,7 @@ "response = bedrock.invoke_model(body=body)\n", "response_body = json.loads(response.get(\"body\").read())\n", "print(response_body)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -383,8 +383,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "2a9e5a9cbde6328c", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.native.amazon import Session\n", "\n", @@ -404,9 +406,7 @@ " inferenceConfig={\"maxTokens\": 512, \"temperature\": 0.5, \"topP\": 0.9},\n", ")\n", "print(response)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -434,8 +434,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "a69126ffa4e667d0", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.native.openai import embeddings\n", "\n", @@ -444,14 +446,14 @@ " model_name=\"text-embedding-ada-002\"\n", ")\n", "print(response.data)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "code", + "execution_count": null, "id": "1e4d8abd6de01ef2", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.native.openai import embeddings\n", "# example with encoding format passed as parameter\n", @@ -461,9 +463,7 @@ " encoding_format='base64'\n", ")\n", "print(response.data)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -475,8 +475,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "9f92b5579e675194", "metadata": {}, + "outputs": [], "source": [ "import json\n", "from gen_ai_hub.proxy.native.amazon import Session\n", @@ -491,22 +493,22 @@ ")\n", "response_body = json.loads(response.get(\"body\").read())\n", "print(response_body)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "code", + "execution_count": null, "id": "ee16f8afd84ab9ec", "metadata": {}, - "source": [], "outputs": [], - "execution_count": null + "source": [] }, { "cell_type": "code", + "execution_count": null, "id": "a653390de3119ddf", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.native.openai import embeddings\n", "# example with encoding format passed as parameter\n", @@ -516,9 +518,7 @@ " encoding_format='base64'\n", ")\n", "print(response.data)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -549,11 +549,14 @@ }, { "cell_type": "code", + "execution_count": null, "id": "63312fa4e955b44b", "metadata": {}, + "outputs": [], "source": [ "from langchain_core.prompts import PromptTemplate\n", "from langchain_core.output_parsers import StrOutputParser\n", + "from gen_ai_hub.proxy.core import get_proxy_client\n", "from gen_ai_hub.proxy.langchain import init_llm\n", "\n", "template = \"\"\"Question: {question}\n", @@ -561,29 +564,30 @@ "prompt = PromptTemplate(template=template, input_variables=['question'])\n", "question = 'What is a supernova?'\n", "\n", - "llm = init_llm('gpt-5-nano', max_tokens=300)\n", + "proxy_client = get_proxy_client('gen-ai-hub')\n", + "llm = init_llm('gpt-5-nano', proxy_client=proxy_client, max_tokens=300)\n", "chain = prompt | llm | StrOutputParser()\n", "response = chain.invoke({'question': question})\n", "print(response)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "code", + "execution_count": null, "id": "1567181d179fab0e", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.langchain import init_embedding_model\n", + "from gen_ai_hub.proxy.core import get_proxy_client\n", "\n", "text = 'Every decoding is another encoding.'\n", "\n", - "embeddings = init_embedding_model('text-embedding-ada-002')\n", + "proxy_client = get_proxy_client('gen-ai-hub')\n", + "embeddings = init_embedding_model('text-embedding-ada-002', proxy_client=proxy_client)\n", "response = embeddings.embed_query(text)\n", "print(response)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -595,8 +599,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "2af160b0ad2ee60d", "metadata": {}, + "outputs": [], "source": [ "from langchain import PromptTemplate\n", "\n", @@ -619,9 +625,7 @@ "question = \"What NFL team won the Super Bowl in the year Justin Bieber was born?\"\n", "\n", "print(llm_chain.invoke({'question': question}))" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -633,8 +637,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "e9cdb2eee2fe33f4", "metadata": {}, + "outputs": [], "source": [ "from langchain.prompts.chat import (\n", " AIMessagePromptTemplate,\n", @@ -665,9 +671,7 @@ "\n", "response = chain.invoke({'text': 'I love planking.'})\n", "print(response.content)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -679,8 +683,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "28db422fdb96cff9", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.langchain import ChatOpenAI\n", "from gen_ai_hub.proxy import get_proxy_client\n", @@ -695,9 +701,7 @@ "\n", "message = HumanMessage(content=\"Tell me about a person named John who is 30\")\n", "print(chat_model.invoke([message]))" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -709,8 +713,10 @@ }, { "cell_type": "code", + "execution_count": null, "id": "e000701b370d9f1f", "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.langchain import OpenAIEmbeddings\n", "from gen_ai_hub.proxy import get_proxy_client\n", @@ -727,9 +733,7 @@ "\n", "response = embedding_model.embed_query('Every decoding is another encoding.')\n", "print(response)" - ], - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", @@ -753,18 +757,21 @@ ] }, { - "metadata": {}, "cell_type": "markdown", + "id": "2e3700dfa4ca1ed8", + "metadata": {}, "source": [ "### Example of usage RPTClient for the regression task\n", "\n", "This is simple example of `RPTClient` usage with minimall fields in body and with pydantic models usage." - ], - "id": "2e3700dfa4ca1ed8" + ] }, { - "metadata": {}, "cell_type": "code", + "execution_count": null, + "id": "464856504d307aa8", + "metadata": {}, + "outputs": [], "source": [ "from gen_ai_hub.proxy.native.sap import RPTRequest, PredictionConfig, TargetColumn, RPTClient\n", "\n", @@ -819,24 +826,24 @@ "#example with model_version\n", "response = client.predict(body=body, model_name=\"sap-rpt-1-small\", model_version=\"latest\")\n", "print(response.predictions)" - ], - "id": "464856504d307aa8", - "outputs": [], - "execution_count": null + ] }, { - "metadata": {}, "cell_type": "markdown", + "id": "29f1b61cce92ab63", + "metadata": {}, "source": [ "### Example of usage RPTClient for the classification task\n", "\n", "This example shows the possibility to use just dictionary for `RPTClient`." - ], - "id": "29f1b61cce92ab63" + ] }, { - "metadata": {}, "cell_type": "code", + "execution_count": null, + "id": "ac9f2b7e705eb61", + "metadata": {}, + "outputs": [], "source": [ "example_request_by_columns_dict = {\n", " \"prediction_config\": {\n", @@ -876,28 +883,27 @@ "\n", "response = client.predict(body=example_request_by_columns_dict, model_name=\"sap-rpt-1-small\")\n", "print(response.predictions)" - ], - "id": "ac9f2b7e705eb61", - "outputs": [], - "execution_count": null + ] }, { - "metadata": {}, "cell_type": "markdown", + "id": "240f50b4599701f3", + "metadata": {}, "source": [ "### Example of async usage of RPTClient\n", "\n", "The `RPTClient` also supports asynchronous calls by `apredict` method." - ], - "id": "240f50b4599701f3" + ] }, { - "metadata": {}, "cell_type": "code", - "source": "await client.apredict(body=example_request_by_columns_dict, model_name=\"sap-rpt-1-small\")", + "execution_count": null, "id": "7ec3315cb2c29efa", + "metadata": {}, "outputs": [], - "execution_count": null + "source": [ + "await client.apredict(body=example_request_by_columns_dict, model_name=\"sap-rpt-1-small\")" + ] } ], "metadata": { From 39e4a276d40398e6985bb65308bbb0a3fd74c383 Mon Sep 17 00:00:00 2001 From: Yamac Ay Date: Tue, 8 Sep 2026 13:04:54 +0200 Subject: [PATCH 2/2] add release notes --- packages/gen/RELEASE_NOTES.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/gen/RELEASE_NOTES.md b/packages/gen/RELEASE_NOTES.md index 18bcbdba..77c484ce 100644 --- a/packages/gen/RELEASE_NOTES.md +++ b/packages/gen/RELEASE_NOTES.md @@ -1,6 +1,22 @@ # Release Notes ## 7.2.0 +### Breaking Changes +- `init_llm()` and `init_embedding_model()` now require both a model name and `proxy_client` to be passed explicitly. + - **Model name**: was optional in 6.10.0; omitting it now raises a `ValueError`. + - **`proxy_client`**: the fallback to a default proxy client is no longer present in the non-custom model path. Without it, attributes such as `deployment_class` are not available and the deployment lookup fails. + + Update your code to pass both explicitly: + ```python + # before (6.10.0) + llm = init_llm() + + # after (7.2.0+) + from gen_ai_hub.proxy.core import get_proxy_client + proxy_client = get_proxy_client('gen-ai-hub') + llm = init_llm('gpt-4o', proxy_client=proxy_client) + ``` + ### Features - Added Support for LLM Batch Service, see [](batch_service)