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Â
#SAPCHANNEL