Generative AI has broken out of research labs and is now transforming the way business is done. SAP is moving at full speed to embrace this trend and has launched an agent called Joule. In this blog series, I’ll provide a “super-fast hands-on” guide to help you quickly call default models of SAP AI Core and expand them into practical AI agents for real-world business use, so you can understand how these agents work behind the scenes.
生成 AI は研究室の外へ飛び出し、今やビジネス現場の常識を塗り替えています。SAPは全速力でその波に乗っており、JouleというAgentを公開しました。このブログシリーズでは、Agentが裏側でどうなっているかを理解するため、SAP AI Core の既定モデルを最速で呼び出し、実務で使える AI Agentへ拡張する“秒速ハンズオン”をお届けします。
What You’ll Learn in This Series / 本シリーズで学べること
How to spin up a custom AI agent on SAP AI Core in minutes
SAP AI Core 上でカスタム AI エージェントを “秒速” で動かす方法
Hands‑on with LangChain, Google Search Tool, RAG, and Streamlit
LangChain・Google 検索ツール・RAG・Streamlit を使った実装
Exposing the agent as a REST API and rebuilding the UI in SAPUI5/Fiori
エージェントを REST API 化し、UI を SAPUI5/Fiori に載せ替える手順
Time Commitment / 学習時間
Each part is designed to be completed in 10–15 minutes.
各章は 10–15 分 で読める&手を動かせるを予定しています。
️ Series Roadmap / 連載ロードマップ
Part 0 Prologue / プロローグPart 1 Env Setup: SAP AICore & AI Launchpad / 環境構築: SAP AI CoreとAI LaunchpadPart 2 Building a Chat Model with LangChain / LangChain でチャットモデルを構築Part 3 Agent Tools: Integrating Google Search / Agentツール: Google 検索を統合 [current blog / 現在のブログ]Part 4 RAG Basics ①: File Upload & HANA Cloud VectorEngine / RAG 基礎 ①: ファイルアップロード & HANA Cloud ベクターエンジンPart 5 RAG Basics ②: Retriever Tool / RAG 基礎 ②: Retriever Toolの構築Part 6 Streamlit UI Prototype / Streamlit でチャットUIPart 7 Expose as a REST API / AI Agent を REST API 化Part 8 Rebuild the UI with SAPUI5 / SAPUI5 でチャットUI を再構築
Note / 注記
Subsequent blogs will be published soon.
続編は順次公開予定です。
If you enjoyed this post, please give it a kudos! Your support really motivates me. Also, if there’s anything you’d like to know more about, feel free to leave a comment!
Agent Tools: Integrating Google Search
Agentツール: Google 検索を統合
1 | Overview / 概要
AI Agent is more than just chat models. Following the ReAct (Reason + Act) paradigm proposed by Yao et al. in 2022, LLMs are now able to both generate reasoning processes and perform concrete actions, such as calling external tools. For example, by executing actions like Google Search or database queries and then passing those results back to the LLM, the next step of reasoning is always backed by up-to-date information.
This approach helps to suppress hallucinations and enables the development of AI Agent that generate much more accurate responses.
AI Agent は、単なるチャットモデルではありません。2022年に Yao らが提唱した ReAct(Reason + Act)パラダイムに従い、LLMが推論過程を生成し、さらに具体的な行動(ツール呼び出し)も実行できるようになりました。例えば、Google 検索やデータベース参照などの行動を実行し、その結果を再び LLM に渡すことで、次の思考が常に最新情報に基づくものになります。この仕組みによって、ハルシネーションを抑え、より精度の高い生成が期待できる AI Agent が実現しました。
LangChain the “ReAct agent” pattern is already built‑in. We just register tools (like google_search) and LangChain decides, at runtime, whether the model should think or act.
LangChain には “ReAct Agent” パターンが標準搭載されています。google_search などのツールを登録するだけで、実行時にモデルが「思考すべきか/行動すべきか」を自律的に判断します。
2 | Prerequisites / 事前準備
BTP sub-account / BTP サブアカウントSAP AI Core instance / SAP AI Core インスタンスSAP AI LaunchPad Subscription / SAP AI LaunchpadのサブスクリプションPython 3.13 and pip / Python 3.13環境 & pipVSCode, BAS or any IDE / VSCodeやBASなどのIDE
3 | Step 1 – Get a Google API Key / Google API キーを取得する
LangChain needs your Google API key and Custom Search Engine (CSE) ID so the agent can legally query Google. Think of it as giving your assistant a badge to enter the web.
Official docs : LangChain already provides a ready‑made Google Search Tool page.
公式ドキュメント : LangChain の Google Search Tool 解説ページ
Open the Google Cloud Console. / Google Cloud コンソールを開きます。Select or create a project, and click “Create credentials → API key”. A dialog shows your new key.
プロジェクトを選択または新規作成して 「認証情報を作成 → API キー」 をクリックします。ダイアログに新しいキーが表示されます。
Tip: rename the key to something memorable. / 後で識別しやすいようにキー名を変更しておくと便利です。 Go to the Programmable Search Engine create page. / Programmable Search Engine の作成画面へ移動します。Enter any name, set Search the entire web, and click “Create.”
任意の検索エンジン名を入力し、検索対象を「ウェブ全体」に設定して 「作成」 をクリックします。 A screen with an HTML snippet appears.
すると下記のような HTML スニペットと管理画面が表示されます。<script async src=”https://cse.google.com/cse.js?cx=GOOGLE_CSE_ID”>
</script>
<div class=”gcse-search”></div>
Add both values to your project‑root .env file and keep them out of source code.
2 つの値をプロジェクト直下の .env に追記し、ソースコードへベタ書きしないようにしましょう。GOOGLE_CSE_ID = “your GOOGLE_CSE_ID”
GOOGLE_API_KEY = “your GOOGLE_API_KEY”
Your notebook can now authenticate to Google when the agent calls google_search!
Agentが google_search ツールを呼び出す際に Google へ認証できる準備が整いました!
4 | Step 2 – Add the Google Search Tool to LangChain / Google検索ツールを実装する
We wrap Google’s JSON API inside a LangChain Tool so the agent can call google_search the same way it calls the LLM.
Google の JSON API を LangChain Tool にラップし、エージェントが LLM と同じ感覚で google_search を呼べるようにします。
Open the notebook from Part 2, and add the following cell.
Part 2 のノートブックを開きます。そして、次のセルを追加します。
# Notebook Cell 3
from langchain.tools import Tool
from langchain_community.utilities import GoogleSearchAPIWrapper
search = GoogleSearchAPIWrapper(k=5) # return top‑5 results
google_tool = Tool.from_function(
name=”google_search”,
description=”Search Google and return the first results”,
func=search.run
)
What exactly happens in this step? / このステップで何をしているか?
GoogleSearchAPIWrapper: A class that returns a search result string based on the query entered by the agent.
GoogleSearchAPIWrapper: Agent が入力した検索クエリに応じて、検索結果の文字列を返すクラスです。
Tool.from_function: converts any Python function into a LangChain Tool by attaching a human‑readable name and description.
Tool.from_function: 任意の Python 関数に name と description を付けて LangChain Tool 化します。
description: Agents refer to the description of each tool to determine when and how to use it.
Think of it as an “instruction manual” for the model.
description: Agent は各ツールの説明文を読むことで、「いつ・どのようにツールを使うか」を判断します。これは、モデルにとっての“取扱説明書”のような役割を果たします。
5 | Step 3 – Build a LangChain Agent / LangChain エージェントを構築
We combine the chat model from Part 2 with the Google tool to form an Agent that can decide on‑the‑fly whether it needs external information.
Part 2 で作った チャットモデル と Google ツール を合体させ、必要に応じて外部情報を取りに行く Agent を作成します。
# Notebook Cell 4
from langchain.agents import initialize_agent, AgentType
agent = initialize_agent(
tools=[google_tool],
llm=chat_llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True,
)
agent.invoke(“Who won the Tokyo Marathon in 2025, and what was the finishing time?”)
What exactly happens in this step? / このステップで何をしているか?
initialize_agent: wires your LLM, tools, and optional memory into a single Agent object.
initialize_agent: LLM・ツール群・メモリをまとめて 1 つの Agent に組み上げます。tools=[google_tool]: hands the agent a toolbox—right now it contains only Google Search, but you can append more later.
tools=[google_tool]: Agentにツールボックスを渡します。現時点では Google Search だけですが、後で追加可能です。agent=AgentType.OPENAI_FUNCTIONS: Since we’re using OpenAI’s LLM in this case, we’ll choose the function calling specification that is compatible with OpenAI models.
今回は OpenAI の LLM を使用するため、OpenAI モデルに対応したツール呼び出し(Function Calling)の仕様を選択します。
Expect to see a printed google_search call, followed by the champion’s name and time!
google_search 呼び出しログとともに、優勝者とタイムが表示されれば OK です!
6 | Challenge – Add the original Tool! / チャレンジ – オリジナルツールを追加しよう
Let’s create an agent that draws omikuji (a Japanese fortune) while following LangChain’s “How to create tools” guide.
LangChain の「ツールの作り方(How to create tools)」を参考にしながら、おみくじを引く Agent を作ってみましょう。
# Notebook Cell 5
import random
def omikuji(_: str) -> str:
return random.choice([
“XXXXXX”
])
omikuji_tool = Tool.from_function(
name=”xxxxxx”,
description=”……”,
# ?????
)
omikuji_agent = initialize_agent(
tools=XXXXXXXX,
llm=chat_llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True,
)
omikuji_agent.invoke(“おみくじを引いてください”)
If agent.invoke(“おみくじを引いてください”) returns one of the predefined results, it’s a pass!
agent.invoke(“おみくじを引いてください”) が、指定した結果のいずれかを返せば合格です!
Have fun customizing! / 自分だけのツールをどんどん追加して遊んでみましょう。
7 | Next Up / 次回予告
Part 4 RAG Basics ①: File Upload & HANA Cloud VectorEngine / RAG 基礎 ①: ファイルアップロード & HANA Cloud ベクターエンジン
In Part 4 we upload PDFs, vectorise them in HANA Cloud Vector Engine, and let the agent answer with your own documents — the first step toward full‑blown RAG.
Part 4 では PDF をアップロードし HANA Cloud Vector Engine にベクトル化。エージェントが自社文書を引用して回答する RAG の第一歩に進みます。
Disclaimer / 免責事項
Disclaimer – All the views and opinions in the blog are my own and is made in my personal capacity and that SAP shall not be responsible or liable for any of the contents published in this blog.
免責事項 – 本ブログに記載された見解および意見はすべて私個人のものであり、私の個人的な立場で発信しています。SAP は本ブログの内容について一切の責任を負いません。
Generative AI has broken out of research labs and is now transforming the way business is done. SAP is moving at full speed to embrace this trend and has launched an agent called Joule. In this blog series, I’ll provide a “super-fast hands-on” guide to help you quickly call default models of SAP AI Core and expand them into practical AI agents for real-world business use, so you can understand how these agents work behind the scenes.生成 AI は研究室の外へ飛び出し、今やビジネス現場の常識を塗り替えています。SAPは全速力でその波に乗っており、JouleというAgentを公開しました。このブログシリーズでは、Agentが裏側でどうなっているかを理解するため、SAP AI Core の既定モデルを最速で呼び出し、実務で使える AI Agentへ拡張する“秒速ハンズオン”をお届けします。 What You’ll Learn in This Series / 本シリーズで学べることHow to spin up a custom AI agent on SAP AI Core in minutesSAP AI Core 上でカスタム AI エージェントを “秒速” で動かす方法Hands‑on with LangChain, Google Search Tool, RAG, and StreamlitLangChain・Google 検索ツール・RAG・Streamlit を使った実装Exposing the agent as a REST API and rebuilding the UI in SAPUI5/Fioriエージェントを REST API 化し、UI を SAPUI5/Fiori に載せ替える手順Time Commitment / 学習時間Each part is designed to be completed in 10–15 minutes.各章は 10–15 分 で読める&手を動かせるを予定しています。
Series Roadmap / 連載ロードマップPart 0 Prologue / プロローグPart 1 Env Setup: SAP AICore & AI Launchpad / 環境構築: SAP AI CoreとAI LaunchpadPart 2 Building a Chat Model with LangChain / LangChain でチャットモデルを構築Part 3 Agent Tools: Integrating Google Search / Agentツール: Google 検索を統合 [current blog / 現在のブログ]Part 4 RAG Basics ①: File Upload & HANA Cloud VectorEngine / RAG 基礎 ①: ファイルアップロード & HANA Cloud ベクターエンジンPart 5 RAG Basics ②: Retriever Tool / RAG 基礎 ②: Retriever Toolの構築Part 6 Streamlit UI Prototype / Streamlit でチャットUIPart 7 Expose as a REST API / AI Agent を REST API 化Part 8 Rebuild the UI with SAPUI5 / SAPUI5 でチャットUI を再構築Note / 注記Subsequent blogs will be published soon.続編は順次公開予定です。If you enjoyed this post, please give it a kudos! Your support really motivates me. Also, if there’s anything you’d like to know more about, feel free to leave a comment!Agent Tools: Integrating Google SearchAgentツール: Google 検索を統合1 | Overview / 概要AI Agent is more than just chat models. Following the ReAct (Reason + Act) paradigm proposed by Yao et al. in 2022, LLMs are now able to both generate reasoning processes and perform concrete actions, such as calling external tools. For example, by executing actions like Google Search or database queries and then passing those results back to the LLM, the next step of reasoning is always backed by up-to-date information.This approach helps to suppress hallucinations and enables the development of AI Agent that generate much more accurate responses.AI Agent は、単なるチャットモデルではありません。2022年に Yao らが提唱した ReAct(Reason + Act)パラダイムに従い、LLMが推論過程を生成し、さらに具体的な行動(ツール呼び出し)も実行できるようになりました。例えば、Google 検索やデータベース参照などの行動を実行し、その結果を再び LLM に渡すことで、次の思考が常に最新情報に基づくものになります。この仕組みによって、ハルシネーションを抑え、より精度の高い生成が期待できる AI Agent が実現しました。LangChain the “ReAct agent” pattern is already built‑in. We just register tools (like google_search) and LangChain decides, at runtime, whether the model should think or act.LangChain には “ReAct Agent” パターンが標準搭載されています。google_search などのツールを登録するだけで、実行時にモデルが「思考すべきか/行動すべきか」を自律的に判断します。 2 | Prerequisites / 事前準備BTP sub-account / BTP サブアカウントSAP AI Core instance / SAP AI Core インスタンスSAP AI LaunchPad Subscription / SAP AI LaunchpadのサブスクリプションPython 3.13 and pip / Python 3.13環境 & pipVSCode, BAS or any IDE / VSCodeやBASなどのIDE 3 | Step 1 – Get a Google API Key / Google API キーを取得するLangChain needs your Google API key and Custom Search Engine (CSE) ID so the agent can legally query Google. Think of it as giving your assistant a badge to enter the web.Official docs : LangChain already provides a ready‑made Google Search Tool page.公式ドキュメント : LangChain の Google Search Tool 解説ページOpen the Google Cloud Console. / Google Cloud コンソールを開きます。Select or create a project, and click “Create credentials → API key”. A dialog shows your new key.プロジェクトを選択または新規作成して 「認証情報を作成 → API キー」 をクリックします。ダイアログに新しいキーが表示されます。Tip: rename the key to something memorable. / 後で識別しやすいようにキー名を変更しておくと便利です。 Go to the Programmable Search Engine create page. / Programmable Search Engine の作成画面へ移動します。Enter any name, set Search the entire web, and click “Create.”任意の検索エンジン名を入力し、検索対象を「ウェブ全体」に設定して 「作成」 をクリックします。 A screen with an HTML snippet appears.すると下記のような HTML スニペットと管理画面が表示されます。<script async src=”https://cse.google.com/cse.js?cx=GOOGLE_CSE_ID”>
</script>
<div class=”gcse-search”></div>Add both values to your project‑root .env file and keep them out of source code.2 つの値をプロジェクト直下の .env に追記し、ソースコードへベタ書きしないようにしましょう。GOOGLE_CSE_ID = “your GOOGLE_CSE_ID”
GOOGLE_API_KEY = “your GOOGLE_API_KEY”Your notebook can now authenticate to Google when the agent calls google_search!Agentが google_search ツールを呼び出す際に Google へ認証できる準備が整いました! 4 | Step 2 – Add the Google Search Tool to LangChain / Google検索ツールを実装するWe wrap Google’s JSON API inside a LangChain Tool so the agent can call google_search the same way it calls the LLM.Google の JSON API を LangChain Tool にラップし、エージェントが LLM と同じ感覚で google_search を呼べるようにします。Open the notebook from Part 2, and add the following cell.Part 2 のノートブックを開きます。そして、次のセルを追加します。# Notebook Cell 3
from langchain.tools import Tool
from langchain_community.utilities import GoogleSearchAPIWrapper
search = GoogleSearchAPIWrapper(k=5) # return top‑5 results
google_tool = Tool.from_function(
name=”google_search”,
description=”Search Google and return the first results”,
func=search.run
)What exactly happens in this step? / このステップで何をしているか?GoogleSearchAPIWrapper: A class that returns a search result string based on the query entered by the agent.GoogleSearchAPIWrapper: Agent が入力した検索クエリに応じて、検索結果の文字列を返すクラスです。Tool.from_function: converts any Python function into a LangChain Tool by attaching a human‑readable name and description.Tool.from_function: 任意の Python 関数に name と description を付けて LangChain Tool 化します。description: Agents refer to the description of each tool to determine when and how to use it.Think of it as an “instruction manual” for the model.description: Agent は各ツールの説明文を読むことで、「いつ・どのようにツールを使うか」を判断します。これは、モデルにとっての“取扱説明書”のような役割を果たします。 5 | Step 3 – Build a LangChain Agent / LangChain エージェントを構築We combine the chat model from Part 2 with the Google tool to form an Agent that can decide on‑the‑fly whether it needs external information.Part 2 で作った チャットモデル と Google ツール を合体させ、必要に応じて外部情報を取りに行く Agent を作成します。# Notebook Cell 4
from langchain.agents import initialize_agent, AgentType
agent = initialize_agent(
tools=[google_tool],
llm=chat_llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True,
)
agent.invoke(“Who won the Tokyo Marathon in 2025, and what was the finishing time?”)What exactly happens in this step? / このステップで何をしているか?initialize_agent: wires your LLM, tools, and optional memory into a single Agent object.initialize_agent: LLM・ツール群・メモリをまとめて 1 つの Agent に組み上げます。tools=[google_tool]: hands the agent a toolbox—right now it contains only Google Search, but you can append more later.tools=[google_tool]: Agentにツールボックスを渡します。現時点では Google Search だけですが、後で追加可能です。agent=AgentType.OPENAI_FUNCTIONS: Since we’re using OpenAI’s LLM in this case, we’ll choose the function calling specification that is compatible with OpenAI models.今回は OpenAI の LLM を使用するため、OpenAI モデルに対応したツール呼び出し(Function Calling)の仕様を選択します。Expect to see a printed google_search call, followed by the champion’s name and time!google_search 呼び出しログとともに、優勝者とタイムが表示されれば OK です! 6 | Challenge – Add the original Tool! / チャレンジ – オリジナルツールを追加しようLet’s create an agent that draws omikuji (a Japanese fortune) while following LangChain’s “How to create tools” guide.LangChain の「ツールの作り方(How to create tools)」を参考にしながら、おみくじを引く Agent を作ってみましょう。# Notebook Cell 5
import random
def omikuji(_: str) -> str:
return random.choice([
“XXXXXX”
])
omikuji_tool = Tool.from_function(
name=”xxxxxx”,
description=”……”,
# ?????
)
omikuji_agent = initialize_agent(
tools=XXXXXXXX,
llm=chat_llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True,
)
omikuji_agent.invoke(“おみくじを引いてください”)If agent.invoke(“おみくじを引いてください”) returns one of the predefined results, it’s a pass!agent.invoke(“おみくじを引いてください”) が、指定した結果のいずれかを返せば合格です!Have fun customizing! / 自分だけのツールをどんどん追加して遊んでみましょう。 7 | Next Up / 次回予告Part 4 RAG Basics ①: File Upload & HANA Cloud VectorEngine / RAG 基礎 ①: ファイルアップロード & HANA Cloud ベクターエンジンIn Part 4 we upload PDFs, vectorise them in HANA Cloud Vector Engine, and let the agent answer with your own documents — the first step toward full‑blown RAG.Part 4 では PDF をアップロードし HANA Cloud Vector Engine にベクトル化。エージェントが自社文書を引用して回答する RAG の第一歩に進みます。 Disclaimer / 免責事項Disclaimer – All the views and opinions in the blog are my own and is made in my personal capacity and that SAP shall not be responsible or liable for any of the contents published in this blog.免責事項 – 本ブログに記載された見解および意見はすべて私個人のものであり、私の個人的な立場で発信しています。SAP は本ブログの内容について一切の責任を負いません。 Read More Technology Blogs by SAP articles
#SAP
#SAPTechnologyblog