0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[ODC]AI Modelを直接呼ぶ方法(とAgentic Appとの違い)

0
Posted at

以下の記事中で、Agentic Appを使ったAI利用機能作成手順を確認した。
その中で、ドキュメントとODC Studioを見ていると、ODC Portalに登録したAI ModelをAgentic App外からも呼べそうなのに気づいた。

そこで、AI Modelを直接呼ぶ方法について確認してみる。

環境情報

ODC Studio (Version 1.6.7)
ODC Personal Edition

AI Model

ODC PortalのINTEGRATE > AI modelsページで管理するAIサービス。
PEには2種類のTrialモデルが最初から登録されている。

Agentic Appが提供するService ActionはこのAI Modelを呼び出すフレームワークを提供している。

しかし、AI ModelをODC Portalに登録すると、以下のように、AI Model呼び出しのためのServer Actionが自動作成される。そのため、Agentic Appを経由せずに直接呼び出すことも可能。

image.png

利用方法

先頭にリンクしたAgentic Appと同じ呼び出しを行う手順を確認する。

上の記事では、System PromptとUser PromptをAI Modelに渡していた。
それと同じことをするために、まず、Local VariableにRequestMessages(AI Modelから参照できる)のList型を用意する。

image.png

このListに、System Promptを登録する。
ポイントは、

  • Roleとして"system"を選択(RoleのDescriptionに選択可能な値が列挙されている)
  • Content[0].ContentTypeとして"TextContent"を選択。こちらも選択可能な値はDescriptionに記載されている
  • Content[0].ContentTextにはシステムプロンプト(内容は上記記事参照)
    image.png

次にUser Promptを登録する。User Promptは名前通りユーザーの入力を渡す。User Promptという名前通りユーザーが入力したテキストを結合してプロンプトを作る。これも実際の内容は上の記事で使ったものを再利用。

  • Roleは"user"
    image.png

用意したMessagesを、Call Action呼び出しの、Request.Messagesに渡す。
image.png

このActionは「ODC Portal上のAI Model名」をManage Dependencies Dialogのsourceで選択すると参照できる。
image.png

Agentic Appの場合と比較して

Agentic Appでは、RoleとContentTypeに渡す値はBuilt-in Static entitiesから参照しているStatic EntityのIdを渡すが、AI Modelを直接呼ぶ場合はDescriptionで指定された文字列になる。
(例:RoleにSystem Promptを意味する値を指定する場合、Agentic AppではEntities.AIRole.System、AI Model呼び出しでは"system"を渡す)
image.png

AI Model直接呼び出しが可能であることは確認できた。やはり、Agentic AppはFrameworkであって、AIエージェント構築に必須ではない、ということになりそう。Frameworkなので、Agentic Appを利用することで共通の構造で構築でき、開発生産性・保守性に幾らかの効果はあるだろう。あとは、費用との見合いになるか。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?