UiPath Documentation
getting-started
latest
false
スタート アップ ガイド - 開発者向け
  • はじめに
    • 概要
    • 環境の設定
  • UiPath Agents の利用を開始する
  • LangGraph を使用した UiPath Agents の利用を開始する
    • はじめに
    • 環境をセットアップする
    • エージェントを構築する
    • ツールを追加する
    • エージェントを評価する
    • Studio Web に接続
  • Studio Web でローコード エージェントを構築する
  • UiPath エージェントにツールを追加する
  • Getting Started with UiPath Maestro Flow
重要 :
このコンテンツは機械翻訳によって処理されています。 新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。

ツールを追加する

コーディング エージェントと UiPath のスキルを使用して、LangGraph エージェントにツールを追加します。

手順 7 - ライブ検索ツールを追加する​

現在、エージェントは雰囲気から推測しています:ドラゴンやゴブリンについて言っていることは、実際のものと照合されていません。分類器の精度を向上させるために、ティアの推奨事項を確定する前にクエスト情報を検証するツールを追加しましょう。これを行うために、ツールは Open5e API を使用して、5eシステムリファレンスドキュメント(SRD)で公開されているクリーチャーを検索します。

これは標準の LangGraph であり、UiPath 固有のトリックではありません。 @toolで修飾されたプレーンな Python 関数をモデルにバインドし、実行時にモデルがその関数を呼び出す価値があるかどうかを判断します。コーディング エージェントがそのバインド構文を接続します。

コーディング エージェントに依頼してください。

Update main.py to add one Python tool to the existing LangGraph agent: a function that looks up a monster's challenge rating from the Open5e SRD API and uses it to inform the difficulty tier.

Tool behavior:
- Query GET https://api.open5e.com/v2/creatures/ using the `requests` library (already available as a transitive dependency; add it directly with `uv add requests` only if the import fails), with query parameters: name__icontains=<creature name or type the model supplies>, document__key__in=srd-2024, limit=10, fields=key,name,type,size,challenge_rating,alignment
- Set a 10-second timeout on the request, and call raise_for_status() before reading the response body — this is a live external API call, so it should fail fast with a clear error instead of hanging or raising a confusing KeyError if Open5e is slow or returns a non-200 response.
- If the response has zero results, return that as-is — nothing further to do.
- If the response has more than one result, return the full list and let the agent pick the best match rather than guessing which one is correct.
- Bind the tool with the standard LangChain @tool decorator. Let the model decide when to call it based on the tool's description — don't force a call on every input.
- Name the tool function `get_challenge_rating`.
- In the tool's docstring, describe what counts as a creature in the abstract — don't include a named example creature (e.g., avoid phrasing like "e.g. goblin, young red dragon"). A concrete example name in the docstring can get echoed back by the model as a spurious lookup for a creature that isn't actually in the quest.

Update the system prompt so that:
- The agent calls this tool whenever the quest description names or strongly implies a specific creature.
- Only call the tool for creatures explicitly named or strongly implied in the quest description — never for other creatures used as a comparison or reference point.
- When a `challenge_rating` comes back, the agent uses it to inform the tier classification and cites it explicitly in the `reasoning` output field. Do not fabricate or guess a challenge rating from memory — only cite one that actually came from the tool's response.
- If no tool call happens, or the tool returns zero results, the agent classifies using its existing judgment, same as before.
- Don't add new output fields. The State schema stays `tier` and `reasoning` only — the challenge rating goes into the reasoning text, not a new field.

Only touch main.py.

Don't run any uip codedagent commands or otherwise verify that the agent runs — I will do this myself.
Update main.py to add one Python tool to the existing LangGraph agent: a function that looks up a monster's challenge rating from the Open5e SRD API and uses it to inform the difficulty tier.

Tool behavior:
- Query GET https://api.open5e.com/v2/creatures/ using the `requests` library (already available as a transitive dependency; add it directly with `uv add requests` only if the import fails), with query parameters: name__icontains=<creature name or type the model supplies>, document__key__in=srd-2024, limit=10, fields=key,name,type,size,challenge_rating,alignment
- Set a 10-second timeout on the request, and call raise_for_status() before reading the response body — this is a live external API call, so it should fail fast with a clear error instead of hanging or raising a confusing KeyError if Open5e is slow or returns a non-200 response.
- If the response has zero results, return that as-is — nothing further to do.
- If the response has more than one result, return the full list and let the agent pick the best match rather than guessing which one is correct.
- Bind the tool with the standard LangChain @tool decorator. Let the model decide when to call it based on the tool's description — don't force a call on every input.
- Name the tool function `get_challenge_rating`.
- In the tool's docstring, describe what counts as a creature in the abstract — don't include a named example creature (e.g., avoid phrasing like "e.g. goblin, young red dragon"). A concrete example name in the docstring can get echoed back by the model as a spurious lookup for a creature that isn't actually in the quest.

Update the system prompt so that:
- The agent calls this tool whenever the quest description names or strongly implies a specific creature.
- Only call the tool for creatures explicitly named or strongly implied in the quest description — never for other creatures used as a comparison or reference point.
- When a `challenge_rating` comes back, the agent uses it to inform the tier classification and cites it explicitly in the `reasoning` output field. Do not fabricate or guess a challenge rating from memory — only cite one that actually came from the tool's response.
- If no tool call happens, or the tool returns zero results, the agent classifies using its existing judgment, same as before.
- Don't add new output fields. The State schema stays `tier` and `reasoning` only — the challenge rating goes into the reasoning text, not a new field.

Only touch main.py.

Don't run any uip codedagent commands or otherwise verify that the agent runs — I will do this myself.
注:

このプロンプトがなぜこれほど具体的であるのか。手順 5 と同様に、ファイルのスコープ設定と、何も実行または検証しないようにという指示は意図的なものであり、このラボの次のコマンドはツールを直接実行するため、検証はユーザーに任されています。

プロンプトを自分の作業に合わせるときには、コーディング エージェントがコードを完全に実行できるように、最後の 2 つの文を削除することをお勧めします。

重要:

コーディング エージェントは非決定論的です。生成されたツール コードは、ここに示す例とは異なります。それは予想通りです。重要なのは、 main.py まだエラーなしで実行され、クリーチャーに名前が付けられたときにのみツールを呼び出すことです。

このツールでは、入力フィールドや出力フィールドの追加や変更は行われないため、今回は再実行 uip codedagent init 必要はありません。入力/出力モデルが変更された場合にのみ再実行してください。

手順 6 のドラゴンの例を再実行します。

uip codedagent run agent '{"description": "Slay the ancient red dragon terrorizing the countryside"}'
uip codedagent run agent '{"description": "Slay the ancient red dragon terrorizing the countryside"}'

今回はトレースを見てください: エージェントは SRD ルックアップを呼び出し、実際のチャレンジの評価を返し、単に Legendary をアサートするのではなく、推論にそれを引用します。これが、テキスト分類器と、自分自身を検証できるエージェントの違いです。


ツールを接続すると、エージェントがツールを正しく使用し、さまざまな入力で高いスコアを獲得していることをテストする準備が整います。

  • 手順 7 - ライブ検索ツールを追加する​

このページは役に立ちましたか?

接続

ヘルプ リソース サポート

学習する UiPath アカデミー

質問する UiPath フォーラム

最新情報を取得