Skip to main content

アシスタント (非推奨)

アシスタント API は、大規模言語モデル (LLM) アプリケーションの一種であるアシスタントの構築を簡素化します。このトピックでは、アシスタント API が提供する、アシスタントの作成、リスト化、取得、更新、削除などの管理メソッドについて説明します。

アシスタント API は非推奨になりました。代替として Responses API に移行してください。Responses API には、複数の組み込みツールが含まれており、マルチターンコンテキスト管理をサポートしています。
特徴:アシスタント API の特徴と基本的な使用方法の詳細については、「アシスタント API の概要」をご参照ください。
永続性:すべてのアシスタントインスタンスは Alibaba Cloud Model Studio サーバーに保存され、有効期限はありません。assistant.id を使用してアシスタントを取得できます。
エージェントアプリケーションとアシスタントは、特徴と使用方法が異なる 2 種類の LLM アプリケーションです。
  • エージェントアプリケーション:コンソールでのみエージェントアプリケーションの作成、表示、更新、削除が可能です。アプリケーション呼び出し API を使用して呼び出すことができます。
  • アシスタント:アシスタント API を使用してのみ、アシスタントの作成、表示、更新、削除、呼び出しが可能です。

アシスタントの作成

新しいアシスタントを作成します。
  • HTTP
  • SDK
コード例
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/assistants' \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "model": "qwen-max",
    "name": "Intelligent assistant",
    "description": "This is an intelligent assistant",
    "instructions": "You are an intelligent assistant that can call different tools based on user query and then give responses. Please use tools when needed.",
    "tools": [
        {
            "type": "code_interpreter"
        }
    ],
    "metadata": {}
}'
リクエストパラメーター
パラメーター名説明タイプ必須
modelアシスタントが使用するモデル。strはい
nameアシスタントの名前。strいいえ
descriptionアシスタントの説明。strいいえ
instructionsアシスタント内の LLM のシステムプロンプト。strいいえ
toolsアシスタントが呼び出すことができるツールのリスト。カスタムプラグインの認証情報を渡します。
{
 "type": "${plugin_id}",
     "auth": {  # このフィールドはユーザーレベルの認証にのみ使用されます。
         "type": "user_http",
         "user_token": "bearer-token",
         }
 }
Optional[List[Dict]]いいえ (デフォルト:[])
metadataアシスタントに関連するその他のパラメーター。このパラメーターは、他の関連パラメーターを格納するために使用されます。Dictいいえ
temperatureランダム性と多様性の度合いを制御します。floatいいえ
top_p生成時の核サンプリング法の確率しきい値。floatいいえ
top_k生成時のサンプリングのためのサンプル候補セットのサイズ。integerいいえ
レスポンス
{
    "id": "asst_49079f4b-d1e8-4015-a12e-2dcdd1f18d84",
    "object": "assistant",
    "created_at": 1711713885724,
    "model": "qwen-max",
    "name": "Intelligent Assistant",
    "description": "This is an intelligent assistant.",
    "instructions": "You are an intelligent assistant. You can call different tools based on user needs to provide answers. Use tools as needed.",
    "tools": [
        {
            "type": "code_interpreter"
        }
    ],
    "metadata": {},
    "temperature": null,
    "top_p": null,
    "top_k": null,
    "max_tokens": null,
    "request_id": "b1778226-3865-9006-9e95-56329a710322"
}
レスポンスパラメーターアシスタントオブジェクト。

アシスタントのリスト

アシスタントのリストを返します。
  • HTTP
  • SDK
コード例
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/assistants?limit=2&order=desc' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
リクエストパラメーター

入力パラメーター名

入力パラメーターの説明

タイプ

必須

limit

アシスタントの数

int

いいえ

order

作成時間によるソート順。

str

いいえ (デフォルト:desc)

レスポンス
{
    "object": "list",
    "data": [
        {
            "id": "asst_0678aa33-43e2-4268-95e6-b0010f9f7937",
            "object": "assistant",
            "created_at": 1711435564909,
            "model": "qwen-max",
            "name": "Intelligent Assistant",
            "description": "This is an intelligent assistant.",
            "instructions": "You are an intelligent assistant. You can call different tools based on user needs to provide answers. Use tools as needed.",
            "tools": [
                {
                    "type": "search"
                },
                {
                    "type": "text_to_image"
                },
                {
                    "type": "code_interpreter"
                }
            ],
            "metadata": {}
        },
        {
            "id": "asst_7af23142-52bc-4218-aa98-dfdb1128f19c",
            "object": "assistant",
            "created_at": 1711422620443,
            "model": "qwen-max",
            "name": "helpful assistant",
            "description": "",
            "instructions": "You are a helpful assistant.",
            "tools": [
                {
                    "type": "text_to_image"
                }
            ],
            "file_ids": [],
            "metadata": {}
        }
    ],
    "first_id": "asst_0678aa33-43e2-4268-95e6-b0010f9f7937",
    "last_id": "asst_7af23142-52bc-4218-aa98-dfdb1128f19c",
    "has_more": true,
    "request_id": "bc257359-ce86-9547-98be-d804effba8d1"
}
レスポンスパラメーターアシスタントオブジェクトのリスト。

リトリーバルエージェント

  • HTTP
  • SDK
コード例
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/assistants/asst_0678aa33-43e2-4268-95e6-b0010f9f7937' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
リクエストパラメーター

入力パラメーター名

入力パラメーターの説明

タイプ

必須

assistant_id

取得するアシスタントの ID。

str

はい

レスポンス
{
    "id": "asst_0678aa33-43e2-4268-95e6-b0010f9f7937",
    "object": "assistant",
    "created_at": 1711435564909,
    "model": "qwen-max",
    "name": "Intelligent Assistant",
    "description": "This is an intelligent assistant.",
    "instructions": "You are an intelligent assistant. You can call different tools based on user needs to provide answers. Use tools as needed.",
    "tools": [
        {
            "type": "search"
        },
        {
            "type": "text_to_image"
        },
        {
            "type": "code_interpreter"
        }
    ],
    "metadata": {},
    "request_id": "f0ec05b0-8813-984c-81b5-1166ae3478d1"
}
レスポンスパラメーター取得した アシスタントオブジェクト。

アシスタントの更新

  • HTTP
  • SDK
コード例
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/assistants/asst_0678aa33-43e2-4268-95e6-b0010f9f7937' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "instructions": "You are a search assistant",
    "name": "New Application-assistantAPI",
    "description": "",
    "model": "qwen-max"
}'
リクエストパラメーター

入力パラメーター名

入力パラメーターの説明

タイプ

必須

assistant_id

取得するエージェントの ID

str

はい

*

その他のオプションの入力パラメーター。

str

いいえ

model

アシスタントが使用するモデルの ID。

str

はい

name

アシスタントの名前。

str

いいえ

description

アシスタントの説明。

str

いいえ

instructions

アシスタント内の LLM のシステムプロンプト。

str

いいえ

tools

アシスタントが呼び出すことができるツールのリスト。ツールは Alibaba Cloud Model Studio に登録されている必要があります。

Optional[List[Dict]]

いいえ (デフォルト:[])

metadata

アシスタントの他の関連パラメーターを格納します。

Dict

いいえ

レスポンス
{
    "id": "asst_0678aa33-43e2-4268-95e6-b0010f9f7937",
    "object": "assistant",
    "created_at": 1711435564909,
    "model": "qwen-max",
    "name": "New-Application-assistantAPI",
    "description": "",
    "instructions": "You are a search assistant.",
    "tools": [
        {
            "type": "search"
        },
        {
            "type": "text_to_image"
        },
        {
            "type": "code_interpreter"
        }
    ],
    "metadata": {},
    "request_id": "b0993831-a98b-9e71-b235-75174df9046e"
}
レスポンスパラメーター更新された アシスタントオブジェクト。

アシスタントの削除

  • HTTP
  • SDK
コード例
curl --location --request DELETE 'https://dashscope-intl.aliyuncs.com/api/v1/assistants/asst_0678aa33-43e2-4268-95e6-b0010f9f7937' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
リクエストパラメーター

入力パラメーター名

説明

タイプ

必須

assistant_id

取得するアシスタントの ID。

str

はい

レスポンス
{
    "id": "asst_0678aa33-43e2-4268-95e6-b0010f9f7937",
    "object": "assistant.deleted",
    "deleted": true,
    "request_id": "6af9320f-0430-9d01-b92f-d1beb6424dc5"
}
レスポンスパラメーター削除されたアシスタントのステータスを出力します。

アシスタントオブジェクト

モデルを呼び出し、ツールを使用できる Assistant オブジェクト。 アシスタントオブジェクトの例
{
    "id": "asst_49079f4b-d1e8-4015-a12e-2dcdd1f18d84",
    "object": "assistant",
    "created_at": 1711713885724,
    "model": "qwen-max",
    "name": "Intelligent Assistant",
    "description": "This is an intelligent assistant.",
    "instructions": "You are an intelligent assistant. You can call different tools based on user needs to provide answers. Use tools as needed.",
    "tools": [
        {
            "type": "code_interpreter"
        }
    ],
    "metadata": {},
    "temperature": null,
    "top_p": null,
    "top_k": null,
    "max_tokens": null,
    "request_id": "b1778226-3865-9006-9e95-56329a710322"
}

パラメーター名

データ型

説明

id

string

アシスタントの一意の識別子。アシスタント ID です。

object

string

オブジェクトタイプ。常に assistant です。

created_at

integer

アシスタントが作成されたときの 13 桁の Unix タイムスタンプ (ミリ秒単位)。

model

string

アシスタントが使用するモデルの名前。利用可能なすべてのモデルは、「アシスタント API の概要」で表示するか、詳細については「モデルリスト」をご参照ください。

name

string

アシスタントの名前。

description

string

アシスタントの説明。

instructions

string

アシスタントが使用するシステム命令。

tools

array

アシスタントで有効になっているツールのリスト。ツールは、公式プラグイン (`code_interpreter`、`quark_search`、`text_to_image` など)、検索拡張生成 (RAG)、または関数呼び出しにすることができます。

metadata

dict

構造化されたフォーマットで格納されたアシスタントオブジェクトに関する追加情報。

temperature

float

サンプリング温度。0 から 2 の間の値です。1 などの高い値は出力をよりランダムにし、0.2 などの低い値は出力をより集中的かつ決定論的にします。

top_p

float

温度サンプリングの代替で、核サンプリングと呼ばれます。このサンプリング方法では、LLM は累積確率質量が `top_p` であるトークンの結果を選択します。値が 0.1 の場合、確率質量のトップ 10% を構成するトークンのみが考慮されることを意味します。

このパラメーターまたは temperature のいずれかを調整しますが、両方を調整しないでください。

top_k

integer

`top_p` と同様ですが、サンプルは累積確率質量に関係なく、最も確率の高い k 個のトークンから選択されます。

このパラメーターと temperature または top_p を同時に調整しないでください。

max_tokens

integer

アシスタントが一度に生成できるトークンの最大数。

request_id

string

アシスタントに関連付けられた呼び出しの一意の識別子。

エラーコード

モデルの呼び出しが失敗し、エラーメッセージが返された場合は、「エラーメッセージ」でトラブルシューティング情報をご参照ください。