すべてのプロダクト
Search
ドキュメントセンター

Alibaba Cloud Model Studio:Runs

最終更新日:Dec 21, 2025

実行は、スレッド上でのエージェントの実行を表します。

ランの作成

実行を作成します。

HTTP

非ストリーミング

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_cc2a3e9d-436b-482b-91c5-377e0f376506/runs' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "assistant_id": "asst_46e95014-ccac-435d-b884-c97ac44a94d9",
    "metadata": {}
}'

ストリーミング

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_cc2a3e9d-436b-482b-91c5-377e0f376506/runs' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "assistant_id": "asst_46e95014-ccac-435d-b884-c97ac44a94d9",
    "metadata": {},
    "stream": true
}'

リクエストパラメーター

パラメーター

説明

タイプ

必須

thread id

実行するスレッドの ID。

string

はい

assistant id

実行するアシスタントの ID です。

string

はい

model

呼び出すモデルの名前です。このパラメーターを指定すると、アシスタントで定義されたモデルがオーバーライドされます。

string

いいえ

instructions

アシスタントで定義された命令をオーバーライドします。

string

いいえ

tools

アシスタントで定義されたツールのリストをオーバーライドします。

説明

カスタムツールの認証情報を渡します

{

"type": "plugin_type", "auth": {"type": "user_http","user_token": "bearer-token", }

}

アシスタントがプラグインを呼び出すと、`{"plugin_type":{"user_token": "bearer-token"}}` のフォーマットでベアラートークンをリクエストヘッダーに追加します。

string

いいえ

metadata

その他の関連パラメーターの説明です。

string

いいえ

stream

ストリーミングモードでレスポンスを返すかどうかを指定します。

boolean

いいえ

temperature

ランダム性と多様性の度合いを制御します。

float

いいえ

top_p

生成時の核サンプリングの確率しきい値です。

float

いいえ

top_k

生成時のサンプリングの候補セットのサイズです。

integer

いいえ

戻り値

非ストリーミング

{
    "id": "run_3de634fa-75d4-4370-adcf-92ba2a60c396",
    "object": "thread.run",
    "created_at": 1711517598169,
    "thread_id": "thread_cc2a3e9d-436b-482b-91c5-377e0f376506",
    "assistant_id": "asst_46e95014-ccac-435d-b884-c97ac44a94d9",
    "status": "in_progress",
    "model": "qwen-max",
    "instructions": "あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出して回答を提供できます。必要に応じてツールを使用してください。",
    "tools": [
        {
            "type": "search"
        },
        {
            "type": "text_to_image"
        }
    ],
    "metadata": {},
    "request_id": "225292ff-9843-95d4-8591-b1377c33e2be"
}

ストリーミング

event:thread.created
data:{"id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","object":"thread","created_at":1714448101977,"metadata":{},"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.run.created
data:{"id":"run_04fba6a3-3ac9-42e8-ba2b-9b5c889a8d58","object":"thread.run","created_at":1714448101996,"thread_id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","status":"queued","required_action":null,"last_error":null,"expires_at":null,"started_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"model":"qwen-max","instructions":"あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出して回答を提供できます。必要に応じてツールを使用してください。","tools":[{"type":"text_to_image"},{"type":"function","function":{"name":"get_current_weather","description":"指定された場所の現在の天気を取得します","parameters":{"type":"object","properties":{"location":{"type":"string","description":"都市と州 (例:カリフォルニア州サンフランシスコ)"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"file_ids":[],"metadata":{},"usage":null,"temperature":null,"top_p":null,"top_k":null,"max_tokens":null,"truncation_strategy":null,"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.run.queued
data:{"id":"run_04fba6a3-3ac9-42e8-ba2b-9b5c889a8d58","object":"thread.run","created_at":1714448101996,"thread_id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","status":"queued","required_action":null,"last_error":null,"expires_at":null,"started_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"model":"qwen-max","instructions":"あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出して回答を提供できます。必要に応じてツールを使用してください。","tools":[{"type":"text_to_image"},{"type":"function","function":{"name":"get_current_weather","description":"指定された場所の現在の天気を取得します","parameters":{"type":"object","properties":{"location":{"type":"string","description":"都市と州 (例:カリフォルニア州サンフランシスコ)"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"file_ids":[],"metadata":{},"usage":null,"temperature":null,"top_p":null,"top_k":null,"max_tokens":null,"truncation_strategy":null,"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.run.in_progress
data:{"id":"run_04fba6a3-3ac9-42e8-ba2b-9b5c889a8d58","object":"thread.run","created_at":1714448101996,"thread_id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","status":"in_progress","required_action":null,"last_error":null,"expires_at":null,"started_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"model":"qwen-max","instructions":"あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出して回答を提供できます。必要に応じてツールを使用してください。","tools":[{"type":"text_to_image"},{"type":"function","function":{"name":"get_current_weather","description":"指定された場所の現在の天気を取得します","parameters":{"type":"object","properties":{"location":{"type":"string","description":"都市と州 (例:カリフォルニア州サンフランシスコ)"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"file_ids":[],"metadata":{},"usage":null,"temperature":null,"top_p":null,"top_k":null,"max_tokens":null,"truncation_strategy":null,"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.run.step.created
data:{"id":"step_52c42910-4993-496d-a7f3-ecd4cf007839","object":"thread.run.step","created_at":1714448102574,"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","thread_id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","run_id":"run_04fba6a3-3ac9-42e8-ba2b-9b5c889a8d58","type":"message_creation","status":"in_progress","step_details":{"type":"message_creation","message_creation":{"message_id":"message_f4f68f6b-6003-4115-8f20-3ea590137502"}},"last_error":null,"expired_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"metadata":{},"usage":null,"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.run.step.in_progress
data:{"id":"step_52c42910-4993-496d-a7f3-ecd4cf007839","object":"thread.run.step","created_at":1714448102574,"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","thread_id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","run_id":"run_04fba6a3-3ac9-42e8-ba2b-9b5c889a8d58","type":"message_creation","status":"in_progress","step_details":{"type":"message_creation","message_creation":{"message_id":"message_f4f68f6b-6003-4115-8f20-3ea590137502"}},"last_error":null,"expired_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"metadata":{},"usage":null,"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.message.created
data:{"id":"message_f4f68f6b-6003-4115-8f20-3ea590137502","object":"thread.message","created_at":1714448102574,"thread_id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","incomplete_details":null,"completed_at":null,"incomplete_at":null,"role":"assistant","content":[],"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","run_id":"run_04fba6a3-3ac9-42e8-ba2b-9b5c889a8d58","file_ids":[],"metadata":{},"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.message.in_progress
data:{"id":"message_f4f68f6b-6003-4115-8f20-3ea590137502","object":"thread.message","created_at":1714448102574,"thread_id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","incomplete_details":null,"completed_at":null,"incomplete_at":null,"role":"assistant","content":[],"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","run_id":"run_04fba6a3-3ac9-42e8-ba2b-9b5c889a8d58","file_ids":[],"metadata":{},"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.message.delta
data:{"id":"message_f4f68f6b-6003-4115-8f20-3ea590137502","object":"thread.message.delta","delta":{"role":"assistant","content":[{"type":"text","text":{"value":"9","annotations":[]}}],"file_ids":[]},"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.message.delta
data:{"id":"message_f4f68f6b-6003-4115-8f20-3ea590137502","object":"thread.message.delta","delta":{"role":"assistant","content":[{"type":"text","text":{"value":"9","annotations":[]}}],"file_ids":[]},"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.message.delta
data:{"id":"message_f4f68f6b-6003-4115-8f20-3ea590137502","object":"thread.message.delta","delta":{"role":"assistant","content":[{"type":"text","text":{"value":"9","annotations":[]}}],"file_ids":[]},"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.message.delta
data:{"id":"message_f4f68f6b-6003-4115-8f20-3ea590137502","object":"thread.message.delta","delta":{"role":"assistant","content":[{"type":"text","text":{"value":" に 998 を掛けると","annotations":[]}}],"file_ids":[]},"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.message.delta
data:{"id":"message_f4f68f6b-6003-4115-8f20-3ea590137502","object":"thread.message.delta","delta":{"role":"assistant","content":[{"type":"text","text":{"value":" 997002 になります。","annotations":[]}}],"file_ids":[]},"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.message.delta
data:{"id":"message_f4f68f6b-6003-4115-8f20-3ea590137502","object":"thread.message.delta","delta":{"role":"assistant","content":[{"type":"text","text":{"value":"","annotations":[]}}],"file_ids":[]},"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.message.completed
data:{"id":"message_f4f68f6b-6003-4115-8f20-3ea590137502","object":"thread.message","created_at":1714448102574,"thread_id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","incomplete_details":null,"completed_at":1714448104154,"incomplete_at":null,"role":"assistant","content":[{"type":"text","text":{"value":"999 に 998 を掛けると 997002 になります。","annotations":[]}}],"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","run_id":"run_04fba6a3-3ac9-42e8-ba2b-9b5c889a8d58","file_ids":[],"metadata":{},"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.run.step.completed
data:{"id":"step_52c42910-4993-496d-a7f3-ecd4cf007839","object":"thread.run.step","created_at":1714448102574,"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","thread_id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","run_id":"run_04fba6a3-3ac9-42e8-ba2b-9b5c889a8d58","type":"message_creation","status":"completed","step_details":{"type":"message_creation","message_creation":{"message_id":"message_f4f68f6b-6003-4115-8f20-3ea590137502"}},"last_error":null,"expired_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1714448104154,"metadata":{},"usage":null,"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:thread.run.completed
data:{"id":"run_04fba6a3-3ac9-42e8-ba2b-9b5c889a8d58","object":"thread.run","created_at":1714448101996,"thread_id":"thread_5b7824dc-dbf9-4538-b214-624ee199caa4","assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","status":"completed","required_action":null,"last_error":null,"expires_at":null,"started_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"model":"qwen-max","instructions":"あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出して回答を提供できます。必要に応じてツールを使用してください。","tools":[{"type":"text_to_image"},{"type":"function","function":{"name":"get_current_weather","description":"指定された場所の現在の天気を取得します","parameters":{"type":"object","properties":{"location":{"type":"string","description":"都市と州 (例:カリフォルニア州サンフランシスコ)"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"file_ids":[],"metadata":{},"usage":{"input_tokens":419,"output_tokens":16,"total_tokens":435},"temperature":null,"top_p":null,"top_k":null,"max_tokens":null,"truncation_strategy":null,"request_id":"f38314af-21c4-945e-acdc-cb9765d1d48f"}

event:done
data:[DONE]

レスポンスパラメーター

ランオブジェクトが返されます。

SDK

ストリーミング

import dashscope
import os
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
stream_iterator = dashscope.Runs.create(
    'thread_id',  # 実際の thread_id に置き換えてください
    # DASHSCOPE_API_KEY 環境変数を設定することを推奨します。設定していない場合は、次の行をご利用の Model Studio API キーに置き換えてください:api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    assistant_id='assistant_id',  # 実際の assistant_id に置き換えてください
    stream=True
)
for event, msg in stream_iterator:
    print(event)
    print(msg)
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.InvalidateParameter;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.threads.runs.AssistantStreamMessage;
import com.alibaba.dashscope.threads.runs.RunParam;
import com.alibaba.dashscope.threads.runs.Runs;
import io.reactivex.Flowable;
import com.alibaba.dashscope.utils.Constants;

public class Main {
    static {
        Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
    }
    public static void main(String[] args) throws ApiException, NoApiKeyException, InputRequiredException, InvalidateParameter, InterruptedException {
        Runs runs = new Runs();
        // DASHSCOPE_API_KEY 環境変数を設定することを推奨します。設定していない場合は、次の行をご利用の Model Studio API キーに置き換えてください:apiKey("sk-xxx")
        RunParam runParam = RunParam.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .assistantId("assistantId")
                .stream(true)
                .build();
        Flowable<AssistantStreamMessage> run = runs.createStream("threadId", runParam);
    }
}

リクエストパラメーター

パラメーター

タイプ

デフォルト値

説明

thread_id

string

-

実行するスレッド。

assistant_id

string

-

アシスタント ID です。

model

string

-

使用するモデルです。

instructions

string

None

このランの命令です。

tools

List[Dict]

[]

アシスタントが使用するツールです。

説明

カスタムツールの認証情報を渡します

{

"type": "plugin_type", "auth": {"type": "user_http","user_token": "bearer-token", }

}

アシスタントがプラグインを呼び出すと、`{"plugin_type":{"user_token": "bearer-token"}}` のフォーマットでベアラートークンをリクエストヘッダーに追加します。

stream

boolean

False

ストリーミング出力を使用するかどうかを制御します。

metadata

Dict

None

アシスタントに関連付けられた情報。

temperature

ランダム性と多様性の度合いを制御します。

float

いいえ

top_p

生成時の核サンプリングの確率しきい値です。

float

いいえ

top_k

生成時のサンプリングの候補セットのサイズです。

integer

いいえ

metadata

その他の関連パラメーターの説明です。

string

いいえ

truncation_strategy

Dict

None

スレッド内のメッセージ切り捨てポリシーを設定します。現在、last_messages のみがサポートされています。デフォルトは次のとおりです:

"truncation_strategy": {

"type": "last_messages",

"last_messages": 10

}

workspace

string

None

Alibaba Cloud Model Studio のワークスペース ID。このパラメーターは、api_key がサブワークスペース API キーである場合にのみ必須です。

api_key

string

None

Model Studio のAPI キー。API キーを環境変数として設定する (このトピックは非公開になり、「API キーの設定」にマージされます) ことを推奨します。

レスポンスの例

ストリーミング出力は、次の例に示すように、イベントとイベントデータを返します:

thread.run.created
{'tools': [{'type': 'quark_search'}], 'required_action': None, 'id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'object': 'thread.run', 'created_at': 1714460227904, 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'status': 'queued', 'last_error': None, 'expires_at': None, 'started_at': None, 'cancelled_at': None, 'failed_at': None, 'completed_at': None, 'model': 'qwen-max', 'instructions': 'あなたは役立つアシスタントです。質問されたときは、可能な限りツールを使用してください。', 'file_ids': [], 'metadata': {}, 'usage': None, 'temperature': None, 'top_p': None, 'top_k': None, 'max_tokens': None, 'truncation_strategy': None, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.queued
{'tools': [{'type': 'quark_search'}], 'required_action': None, 'id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'object': 'thread.run', 'created_at': 1714460227904, 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'status': 'queued', 'last_error': None, 'expires_at': None, 'started_at': None, 'cancelled_at': None, 'failed_at': None, 'completed_at': None, 'model': 'qwen-max', 'instructions': 'あなたは役立つアシスタントです。質問されたときは、可能な限りツールを使用してください。', 'file_ids': [], 'metadata': {}, 'usage': None, 'temperature': None, 'top_p': None, 'top_k': None, 'max_tokens': None, 'truncation_strategy': None, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.in_progress
{'tools': [{'type': 'quark_search'}], 'required_action': None, 'id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'object': 'thread.run', 'created_at': 1714460227904, 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'status': 'in_progress', 'last_error': None, 'expires_at': None, 'started_at': None, 'cancelled_at': None, 'failed_at': None, 'completed_at': None, 'model': 'qwen-max', 'instructions': 'あなたは役立つアシスタントです。質問されたときは、可能な限りツールを使用してください。', 'file_ids': [], 'metadata': {}, 'usage': None, 'temperature': None, 'top_p': None, 'top_k': None, 'max_tokens': None, 'truncation_strategy': None, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.step.created
{'step_details': {'tool_calls': [], 'type': 'tool_calls'}, 'usage': None, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step', 'created_at': 1714460228960, 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'run_id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'type': 'tool_calls', 'status': 'in_progress', 'expired_at': None, 'cancelled_at': None, 'failed_at': None, 'completed_at': None, 'metadata': {}, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200, 'last_error': None}
thread.run.step.in_progress
{'step_details': {'tool_calls': [], 'type': 'tool_calls'}, 'usage': None, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step', 'created_at': 1714460228960, 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'run_id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'type': 'tool_calls', 'status': 'in_progress', 'expired_at': None, 'cancelled_at': None, 'failed_at': None, 'completed_at': None, 'metadata': {}, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200, 'last_error': None}
thread.run.step.delta
{'delta': {'step_details': {'tool_calls': [{'type': 'quark_search', 'quark_search': {'arguments': ''}}], 'type': 'tool_calls'}}, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.step.delta
{'delta': {'step_details': {'tool_calls': [{'type': 'quark_search', 'quark_search': {'arguments': '{"query": "'}}], 'type': 'tool_calls'}}, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.step.delta
{'delta': {'step_details': {'tool_calls': [{'type': 'quark_search', 'quark_search': {'arguments': '今日の北京の天気"}'}}], 'type': 'tool_calls'}}, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.step.delta
{'delta': {'step_details': {'tool_calls': [{'type': 'quark_search', 'quark_search': {'arguments': ''}}], 'type': 'tool_calls'}}, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.step.delta
{'delta': {'step_details': {'tool_calls': [{'type': 'quark_search', 'quark_search': {'arguments': ''}}], 'type': 'tool_calls'}}, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.step.delta
{'delta': {'step_details': {'tool_calls': [{'type': 'quark_search', 'plugin_name': {'output': '{"success": true, "errorCode": null, "errorMsg": null, "data": [{"title": "中国、北京の天気", "url": null, "desc": "リアルタイム天気:晴れ、気温 24 度、体感温度 23 度、西風レベル 1。気温は穏やかで快適です。15 日間の天気予報を表示するには、ここをクリックしてください", "type": "weather_moji", "original": null, "query": null, "source": null}, {"title": "北京市気象局", "url": "http://bj.cma.gov.cn/fzlm/index.html", "desc": "36 時間天気予報 (2024 年 1 月 25 日 05:24:58 に北京市気象局が発表) 今日の日中:最高気温 5°C、晴れのち曇り、北風レベル 3、突風は最大レベル 5、レベル 2 に変わる。今夜:最低気温 -5°C、晴れ、北風レベル 2、レベル 3 に変わる。明日の日中:最高気温 5°C、晴れ、風レベル 3、レベル 1 に変わる...", "type": "structure_web_info", "original": null, "query": null, "source": "北京市気象局"}, {"title": "北京", "url": "https://m.weather.com.cn/mweather/101010100.shtml?_t=1480291523052", "desc": "北京の天気予報、中央気象台からの天気情報をタイムリーかつ正確に発表、北京の今日の天気、北京の週末の天気、北京の 1 週間天気予報、北京の青空予報、北京の天気予報、北京の 40 日間天気予報を便利にクエリ、北京の生活指数、健康指数なども提供...", "type": "normal", "original": null, "query": null, "source": "中国天気"}, {"title": "墨迹天気公式中国語ウェブサイト", "url": "https://m.moji.com/", "desc": "墨迹天気予報アプリは、世界中で約 6 億 5000 万人に利用され、199 か国、20 万以上の都市や地域の天気予報クエリをサポートしています。墨迹天気予報アプリをダウンロードして、晴れ、曇り、雨、雪の状態をリアルタイムで監視し、リアルタイムの空気質と空気質レベル予報も確認できます。", "type": "structure_web_info", "original": null, "query": null, "source": "墨迹天気モバイル版"}, {"title": "北京", "url": "http://sq.weather.com.cn/mweather15d/101010100.shtml?from=singlemessage", "desc": "北京の天気予報、中央気象台からの天気情報をタイムリーかつ正確に発表、北京の今日の天気、北京の週末の天気、北京の 1 週間天気予報、北京の青空予報、北京の天気予報、北京の 40 日間天気予報を便利にクエリ、北京の生活指数、健康指数なども提供...", "type": "structure_web_info", "original": null, "query": null, "source": "中国天気網"}, {"title": "今日頭条ニュース", "url": null, "desc": "中国天気網が 1 日前に報道:予報、警報、レーダー、雲画像、天気図、専門製品、情報、ビデオ、二十四節気、私の空... 恭王府、北京オリンピック公園、オリンピック森林公園、北京石景山遊園地、金海湖、京東大峡谷観光区、明の十三陵、銀山塔林景区、中国航空博物館、北京歓楽谷、北京中国...", "type": "news_uchq", "original": null, "query": null, "source": null}, {"title": "北京", "url": "http://www.weather.com.cn/weather1d/101010100.shtml", "desc": "北京の天気予報、中央気象台からの天気情報をタイムリーかつ正確に発表、北京の今日の天気、北京の週末の天気、北京の 1 週間天気予報、北京の 15 日間...", "type": "structure_web_info", "original": null, "query": null, "source": "中国天気網"}, {"title": "北京 24 時間天気クエリ_北京今日の天気予報クエリ_2345 天気王", "url": "http://waptianqi.2345.com/24hour-54511.htm", "desc": "2345 天気予報は、最新の北京の天気、24 時間の気象状況、その他の情報をタイムリーに提供し、北京の毎日の気象指数も提供します。", "type": "structure_web_info", "original": null, "query": null, "source": "2345 天気王"}, {"title": "北京 15 日間天気詳細", "url": "http://waptianqi.2345.com/beijing-54511.htm", "desc": "2345 天気予報は、北京の天気予報と、北京の未来 15 日間の天気を提供します。2345 天気予報を通じて、北京および周辺地域の今後 15 日間および 30 日間の天気予報に関する詳細情報 (気温、空気質、降水量、風力、気圧、紫外線強度などを含む) を取得できます!", "type": "structure_web_info", "original": null, "query": null, "source": "2345 天気王"}, {"title": "北京 15 日間天気予報", "url": "https://m.tianqi.com/beijing/15/", "desc": "北京天気予報 15 日間詳細:12/11 今日 小雪 -2~2 ℃ 12/12 明日 曇りのち小雪 -2~2 ℃ 12/13 明後日 小雪 -5~0 ℃ 12/14 木曜日 小雪 -5~-1 ℃ 12/15 金曜日 曇り -10~-2 ℃ 12/16 土曜日 晴れ -10~-3 ℃ 12/17 ...", "type": "structure_web_info", "original": null, "query": null, "source": "天気網"}, {"title": "北京天気", "url": "https://t.8684.com/beijing_beijing", "desc": "北京の 1 週間および 15 日間の天気予報、北京天気予報、北京 1 週間天気予報、北京 15 日間天気予報、今週の北京天気予報、来週の北京天気予報、北京 15 日間天気予報クエリ、北京 10 日間天気予報", "type": "structure_web_info", "original": null, "query": null, "source": "8684 天気"}], "requestId": null, "failed": false}'}}], 'type': 'tool_calls'}}, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.step.delta
{'delta': {'step_details': {'tool_calls': [{'quark_search': {'output': ''}}], 'type': 'tool_calls'}}, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.step.delta
{'delta': {'step_details': {'tool_calls': [{'quark_search': {'output': ''}}], 'type': 'tool_calls'}}, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.step.completed
{'step_details': {'tool_calls': [{'type': 'quark_search', 'plugin_name': {'arguments': '{"query": "今日の北京の天気"}', 'output': '{"success": true, "errorCode": null, "errorMsg": null, "data": [{"title": "中国、北京の天気", "url": null, "desc": "リアルタイム天気:晴れ、気温 24 度、体感温度 23 度、西風レベル 1。気温は穏やかで快適です。15 日間の天気予報を表示するには、ここをクリックしてください", "type": "weather_moji", "original": null, "query": null, "source": null}, {"title": "北京市気象局", "url": "http://bj.cma.gov.cn/fzlm/index.html", "desc": "36 時間天気予報 (2024 年 1 月 25 日 05:24:58 に北京市気象局が発表) 今日の日中:最高気温 5°C、晴れのち曇り、北風レベル 3、突風は最大レベル 5、レベル 2 に変わる。今夜:最低気温 -5°C、晴れ、北風レベル 2、レベル 3 に変わる。明日の日中:最高気温 5°C、晴れ、風レベル 3、レベル 1 に変わる...", "type": "structure_web_info", "original": null, "query": null, "source": "北京市気象局"}, {"title": "北京", "url": "https://m.weather.com.cn/mweather/101010100.shtml?_t=1480291523052", "desc": "北京の天気予報、中央気象台からの天気情報をタイムリーかつ正確に発表、北京の今日の天気、北京の週末の天気、北京の 1 週間天気予報、北京の青空予報、北京の天気予報、北京の 40 日間天気予報を便利にクエリ、北京の生活指数、健康指数なども提供...", "type": "normal", "original": null, "query": null, "source": "中国天気"}, {"title": "墨迹天気公式中国語ウェブサイト", "url": "https://m.moji.com/", "desc": "墨迹天気予報アプリは、世界中で約 6 億 5000 万人に利用され、199 か国、20 万以上の都市や地域の天気予報クエリをサポートしています。墨迹天気予報アプリをダウンロードして、晴れ、曇り、雨、雪の状態をリアルタイムで監視し、リアルタイムの空気質と空気質レベル予報も確認できます。", "type": "structure_web_info", "original": null, "query": null, "source": "墨迹天気モバイル版"}, {"title": "北京", "url": "http://sq.weather.com.cn/mweather15d/101010100.shtml?from=singlemessage", "desc": "北京の天気予報、中央気象台からの天気情報をタイムリーかつ正確に発表、北京の今日の天気、北京の週末の天気、北京の 1 週間天気予報、北京の青空予報、北京の天気予報、北京の 40 日間天気予報を便利にクエリ、北京の生活指数、健康指数なども提供...", "type": "structure_web_info", "original": null, "query": null, "source": "中国天気網"}, {"title": "今日頭条ニュース", "url": null, "desc": "中国天気網が 1 日前に報道:予報、警報、レーダー、雲画像、天気図、専門製品、情報、ビデオ、二十四節気、私の空... 恭王府、北京オリンピック公園、オリンピック森林公園、北京石景山遊園地、金海湖、京東大峡谷観光区、明の十三陵、銀山塔林景区、中国航空博物館、北京歓楽谷、北京中国...", "type": "news_uchq", "original": null, "query": null, "source": null}, {"title": "北京", "url": "http://www.weather.com.cn/weather1d/101010100.shtml", "desc": "北京の天気予報、中央気象台からの天気情報をタイムリーかつ正確に発表、北京の今日の天気、北京の週末の天気、北京の 1 週間天気予報、北京の 15 日間...", "type": "structure_web_info", "original": null, "query": null, "source": "中国天気網"}, {"title": "北京 24 時間天気クエリ_北京今日の天気予報クエリ_2345 天気王", "url": "http://waptianqi.2345.com/24hour-54511.htm", "desc": "2345 天気予報は、最新の北京の今日の天気、24 時間の気象状況、その他の情報をタイムリーに提供し、北京の毎日の気象指数も提供します。", "type": "structure_web_info", "original": null, "query": null, "source": "2345 天気王"}, {"title": "北京 15 日間天気詳細", "url": "http://waptianqi.2345.com/beijing-54511.htm", "desc": "2345 天気予報は、北京の天気予報と、北京の未来 15 日間の天気を提供します。2345 天気予報を通じて、北京および周辺地域の今後 15 日間および 30 日間の天気予報に関する詳細情報 (気温、空気質、降水量、風力、気圧、紫外線強度などを含む) を取得できます!", "type": "structure_web_info", "original": null, "query": null, "source": "2345 天気王"}, {"title": "北京 15 日間天気予報", "url": "https://m.tianqi.com/beijing/15/", "desc": "北京天気予報 15 日間詳細:12/11 今日 小雪 -2~2 ℃ 12/12 明日 曇りのち小雪 -2~2 ℃ 12/13 明後日 小雪 -5~0 ℃ 12/14 木曜日 小雪 -5~-1 ℃ 12/15 金曜日 曇り -10~-2 ℃ 12/16 土曜日 晴れ -10~-3 ℃ 12/17 ...", "type": "structure_web_info", "original": null, "query": null, "source": "天気網"}, {"title": "北京天気", "url": "https://t.8684.com/beijing_beijing", "desc": "北京の 1 週間および 15 日間の天気予報、北京天気予報、北京 1 週間天気予報、北京 15 日間天気予報、今週の北京天気予報、来週の北京天気予報、北京 15 日間天気予報クエリ、北京 10 日間天気予報", "type": "structure_web_info", "original": null, "query": null, "source": "8684 天気"}], "requestId": null, "failed": false}'}}], 'type': 'tool_calls'}, 'usage': None, 'id': 'step_f923bd08-1e22-40d9-bf54-373b21fde378', 'object': 'thread.run.step', 'created_at': 1714460228960, 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'run_id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'type': 'tool_calls', 'status': 'in_progress', 'expired_at': None, 'cancelled_at': None, 'failed_at': None, 'completed_at': None, 'metadata': {}, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200, 'last_error': None}
thread.run.step.created
{'step_details': {'message_creation': {'message_id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d'}, 'type': 'message_creation'}, 'usage': None, 'id': 'step_89e631c7-491a-4bff-b1f5-1298f88db531', 'object': 'thread.run.step', 'created_at': 1714460234236, 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'run_id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'type': 'message_creation', 'status': 'in_progress', 'expired_at': None, 'cancelled_at': None, 'failed_at': None, 'completed_at': None, 'metadata': {}, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200, 'last_error': None}
thread.run.step.in_progress
{'step_details': {'message_creation': {'message_id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d'}, 'type': 'message_creation'}, 'usage': None, 'id': 'step_89e631c7-491a-4bff-b1f5-1298f88db531', 'object': 'thread.run.step', 'created_at': 1714460234236, 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'run_id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'type': 'message_creation', 'status': 'in_progress', 'expired_at': None, 'cancelled_at': None, 'failed_at': None, 'completed_at': None, 'metadata': {}, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200, 'last_error': None}
thread.message.created
{'content': [], 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message', 'created_at': 1714460234235, 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'incomplete_details': None, 'completed_at': None, 'incomplete_at': None, 'role': 'assistant', 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'run_id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'file_ids': [], 'metadata': {}, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.in_progress
{'content': [], 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message', 'created_at': 1714460234235, 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'incomplete_details': None, 'completed_at': None, 'incomplete_at': None, 'role': 'assistant', 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'run_id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'file_ids': [], 'metadata': {}, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '今日の'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '北京の天気は'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '晴れで、気温は約 24'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '度、体感温度は 23'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '度、西風レベル 1 で、天気は'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': 'かなり快適です。しかし、北京市気象局から'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': 'より詳細な情報も見つかりました。それによると'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '、日中の最高気温は 5°C、'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '天気は晴れのち曇り、北風レベル 3'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '、突風は最大'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': 'レベル 5 です。夜間の最低気温は -'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '5°C に下がり、晴れが続き、'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '風向きは北寄りに変わり、'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '風力はレベル 2 から 3 に変わります。'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': 'リアルタイムの天気に合わせて服装を調整し、'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': '暖かくしてください。'}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.delta
{'delta': {'content': {'text': {'annotations': [], 'value': ''}, 'type': 'text'}, 'role': 'assistant'}, 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message.delta', 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.message.completed
{'content': [{'text': {'annotations': [], 'value': '今日の北京の天気は晴れで、気温は約 24 度、体感温度は 23 度、西風レベル 1 で、天気はかなり快適です。しかし、北京市気象局からより詳細な情報も見つかりました。それによると、日中の最高気温は 5°C、天気は晴れのち曇り、北風レベル 3、突風は最大レベル 5 です。夜間の最低気温は -5°C に下がり、晴れが続き、風向きは北寄りに変わり、風力はレベル 2 から 3 に変わります。リアルタイムの天気に合わせて服装を調整し、暖かくしてください。'}, 'type': 'text'}], 'id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d', 'object': 'thread.message', 'created_at': 1714460234235, 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'incomplete_details': None, 'completed_at': 1714460245637, 'incomplete_at': None, 'role': 'assistant', 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'run_id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'file_ids': [], 'metadata': {}, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}
thread.run.step.completed
{'step_details': {'message_creation': {'message_id': 'message_93605cd7-fb74-468b-b6fb-4975cd253f8d'}, 'type': 'message_creation'}, 'usage': None, 'id': 'step_89e631c7-491a-4bff-b1f5-1298f88db531', 'object': 'thread.run.step', 'created_at': 1714460234236, 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'run_id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'type': 'message_creation', 'status': 'completed', 'expired_at': None, 'cancelled_at': None, 'failed_at': None, 'completed_at': 1714460245637, 'metadata': {}, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200, 'last_error': None}
thread.run.completed
{'tools': [{'type': 'quark_search'}], 'required_action': None, 'id': 'run_0f314675-06a4-4379-929c-d29cd351a446', 'object': 'thread.run', 'created_at': 1714460227904, 'thread_id': 'thread_28f0b00b-d825-48f5-bb27-f3b171a64d33', 'assistant_id': 'asst_9453fe59-d6eb-498e-aeca-9abecd492e51', 'status': 'completed', 'last_error': None, 'expires_at': None, 'started_at': None, 'cancelled_at': None, 'failed_at': None, 'completed_at': None, 'model': 'qwen-max', 'instructions': 'あなたは役立つアシスタントです。質問されたときは、可能な限りツールを使用してください。', 'file_ids': [], 'metadata': {}, 'usage': {'input_tokens': 1865, 'output_tokens': 139, 'total_tokens': 2004}, 'temperature': None, 'top_p': None, 'top_k': None, 'max_tokens': None, 'truncation_strategy': None, 'request_id': '38fb88b8-196a-9919-8815-f7ed9aa0891f', 'status_code': 200}

レスポンスパラメーター

フィールド

タイプ

説明

status_code

integer

呼び出しの HTTP ステータスコード。値が 200 の場合は呼び出しが成功したことを示します。その他の値は呼び出しが失敗したことを示します。

id

string

ランの ID で、UUID 文字列です。

model

string

ランが使用するモデルの名前です。

instructions

string

アシスタントの機能を示す、アシスタントへの命令。

metadata

object

アシスタントを説明するキーと値のペアです。

status

string

実行のステータス (例:「in_progress」)。

thread_id

string

実行が属するスレッドの ID。

tools

List[Tool]

ランが使用するツールのリストです。

created_at

timestamp

アシスタントが作成された時間です。

gmt_created

datetime

2024-03-22 17:12:31

gmt_modified

datetime

2024-03-22 17:12:31

code

string

リクエストが失敗した場合、このフィールドはエラーコードを示します。リクエストが成功した場合、このフィールドは無視されます。

Python のみ

message

string

リクエストが失敗した場合、このフィールドは失敗の詳細を提供します。リクエストが成功した場合、このフィールドは無視されます。

Python のみ

ランのリスト

スレッドに属する実行のリストを返します。

HTTP

コード例

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_cc2a3e9d-436b-482b-91c5-377e0f376506/runs?limit=20&order=asc' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

リクエストパラメーター

入力パラメーター名

説明

タイプ

必須

thread id

実行リストが属するスレッドの ID。

string

はい

limit

このクエリで返す実行の数。

integer

いいえ

order

作成時間でランをソートする順序です。

string

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

結果

{
    "object": "list",
    "data": [
        {
            "id": "run_3de634fa-75d4-4370-adcf-92ba2a60c396",
            "object": "thread.run",
            "created_at": 1711517598169,
            "thread_id": "thread_cc2a3e9d-436b-482b-91c5-377e0f376506",
            "assistant_id": "asst_46e95014-ccac-435d-b884-c97ac44a94d9",
            "status": "completed",
            "required_action": {},
            "last_error": {},
            "expires_at": 0,
            "started_at": 0,
            "cancelled_at": 0,
            "failed_at": 0,
            "completed_at": 0,
            "model": "qwen-max",
            "instructions": "あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出して回答を提供できます。必要に応じてツールを使用してください。",
            "tools": [
                {
                    "type": "search"
                },
                {
                    "type": "text_to_image"
                }
            ],
            "metadata": {},
            "usage": {
                "prompt_tokens": 66,
                "completion_tokens": 9,
                "total_tokens": 75
            }
        }
    ],
    "first_id": "run_3de634fa-75d4-4370-adcf-92ba2a60c396",
    "last_id": "run_3de634fa-75d4-4370-adcf-92ba2a60c396",
    "has_more": false,
    "request_id": "ff3d2aea-555c-9825-80ca-24029a636641"
}

レスポンスパラメーター

ランオブジェクトのリストが返されます。

SDK

コード例

import dashscope
from dashscope import Runs
import os

dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'

runs = Runs.list(
    'thread_id',
    # DASHSCOPE_API_KEY 環境変数を設定することを推奨します。設定していない場合は、次の行をご利用の Model Studio API キーに置き換えてください:api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    limit=1,
    order='desc'
)
import com.alibaba.dashscope.common.GeneralListParam;
import com.alibaba.dashscope.common.ListResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.InvalidateParameter;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.threads.runs.Run;
import com.alibaba.dashscope.threads.runs.Runs;
import com.alibaba.dashscope.utils.Constants;

public class Main {
    static {
        Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
    }
    public static void main(String[] args) throws ApiException, NoApiKeyException, InputRequiredException, InvalidateParameter, InterruptedException {
        Runs runs = new Runs();
        // DASHSCOPE_API_KEY 環境変数を設定することを推奨します。設定していない場合は、次の行をご利用の Model Studio API キーに置き換えてください:apiKey("sk-xxx")
        GeneralListParam listRuns = GeneralListParam.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .build();
        ListResult<Run> run = runs.list("threadId", listRuns);
    }
}

リクエストパラメーター

パラメーター

タイプ

デフォルト値

説明

thread_id

str

-

リストするスレッドの ID。

limit

int

None

このクエリで返す実行の数。

order

str

None

作成時間でランをソートする順序です。デフォルト値はサーバーの構成によって決まります。

  • desc:降順

  • asc:昇順

workspace

str

None

Alibaba Cloud Model Studio のワークスペース ID。このパラメーターは、api_key がサブワークスペース API キーである場合にのみ必須です。

api_key

str

None

Alibaba Cloud Model Studio のAPI キー。API キーを環境変数として設定する (このメソッドは非公開になり、「API キーの設定」にマージされます) ことを推奨します。

レスポンスパラメーター

フィールド

タイプ

説明

has_more

bool

さらにデータが利用可能かどうかを示します。

  • false:現在のリクエストで返されたデータがすべてのデータです。これ以上データはありません。

  • true:さらにデータがあり、後続のリクエストで取得できます。

last_id

str

レスポンス内の最後の実行の ID。

first_id

str

レスポンス内の最初の実行の ID。

data

list[Run]

実行オブジェクトのリスト。

ランの取得

実行を取得します。

HTTP

コード例

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_cc2a3e9d-436b-482b-91c5-377e0f376506/runs/run_3de634fa-75d4-4370-adcf-92ba2a60c396' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

リクエストパラメーター

パラメーター

説明

タイプ

必須

thread id

取得する実行が属するスレッドの ID。

string

はい

run_id

取得する実行の ID。

string

はい

戻り値

{
    "id": "run_3de634fa-75d4-4370-adcf-92ba2a60c396",
    "object": "thread.run",
    "created_at": 1711517598169,
    "thread_id": "thread_cc2a3e9d-436b-482b-91c5-377e0f376506",
    "assistant_id": "asst_46e95014-ccac-435d-b884-c97ac44a94d9",
    "status": "completed",
    "required_action": {},
    "last_error": {},
    "expires_at": 0,
    "started_at": 0,
    "cancelled_at": 0,
    "failed_at": 0,
    "completed_at": 0,
    "model": "qwen-max",
    "instructions": "あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出して回答を提供できます。必要に応じてツールを使用してください。",
    "tools": [
        {
            "type": "search"
        },
        {
            "type": "text_to_image"
        }
    ],
    "metadata": {},
    "usage": {
        "prompt_tokens": 66,
        "completion_tokens": 9,
        "total_tokens": 75
    },
    "request_id": "05c5f4ea-5e6b-9901-9849-7a0943a0db43"
}

レスポンスパラメーター

指定された ID に一致する実行オブジェクトが返されます。

SDK

コード例

import dashscope
from dashscope import Runs
import os

dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'import os

run = Runs.retrieve(
    'run_id',
    # DASHSCOPE_API_KEY 環境変数を設定することを推奨します。設定していない場合は、次の行をご利用の Model Studio API キーに置き換えてください:api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    thread_id='thread_id'
)
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.InvalidateParameter;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.threads.runs.Run;
import com.alibaba.dashscope.threads.runs.Runs;
import com.alibaba.dashscope.utils.Constants;

public class Main {
    static {
        Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
    }
    public static void main(String[] args) throws ApiException, NoApiKeyException, InputRequiredException, InvalidateParameter, InterruptedException {
        Runs runs = new Runs();
        // DASHSCOPE_API_KEY 環境変数を設定することを推奨します。設定していない場合は、次の行をご利用の Model Studio API キーに置き換えてください:apiKey("sk-xxx")
        String apiKey = System.getenv("DASHSCOPE_API_KEY");
        Run run = runs.retrieve("threadId", "runId", apiKey);
    }
}

リクエストパラメーター

パラメーター

タイプ

デフォルト値

説明

run_id

str

-

クエリするランの ID です。

thread_id

str

-

実行が属するスレッドの ID。

workspace

str

None

Alibaba Cloud Model Studio のワークスペース ID。このパラメーターは、api_key がサブワークスペース API キーである場合にのみ必須です。

api_key

str

None

Alibaba Cloud Model Studio のAPI キー。API キーを環境変数として設定する (このトピックは非公開予定で、「API キーの設定」にマージされます) ことを推奨します。

レスポンスパラメーター

レスポンスは create 操作と同じです。

ランの変更

実行を変更します。

HTTP

コード例

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_cc2a3e9d-436b-482b-91c5-377e0f376506/runs/run_3de634fa-75d4-4370-adcf-92ba2a60c396' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "metadata": {
        "user": "abc123"
    }
}'

リクエストパラメーター

パラメーター

説明

タイプ

必須

thread_id

変更するスレッドの ID。

string

はい

run_id

変更する実行の ID。

string

はい

*

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

string

いいえ

結果

{
    "id": "run_3de634fa-75d4-4370-adcf-92ba2a60c396",
    "object": "thread.run",
    "created_at": 1711517598169,
    "thread_id": "thread_cc2a3e9d-436b-482b-91c5-377e0f376506",
    "assistant_id": "asst_46e95014-ccac-435d-b884-c97ac44a94d9",
    "status": "completed",
    "required_action": {},
    "last_error": {},
    "expires_at": 0,
    "started_at": 0,
    "cancelled_at": 0,
    "failed_at": 0,
    "completed_at": 0,
    "model": "qwen-max",
    "instructions": "あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出して回答を提供できます。必要に応じてツールを使用してください。",
    "tools": [
        {
            "type": "search"
        },
        {
            "type": "text_to_image"
        }
    ],
    "metadata": {
        "user": "abc123"
    },
    "usage": {
        "prompt_tokens": 66,
        "completion_tokens": 9,
        "total_tokens": 75
    },
    "request_id": "bb6a5c5c-146f-95b8-bafa-e6c467e4f2d3"
}

レスポンスパラメーター

指定された ID に一致する変更後の実行オブジェクトが返されます。

SDK

コード例

import dashscope
from dashscope import Runs
import os

dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
run = Runs.update(
    'run_id',
    # DASHSCOPE_API_KEY 環境変数を設定することを推奨します。設定していない場合は、次の行をご利用の Model Studio API キーに置き換えてください:api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    thread_id='thread_id',
    metadata={'newkey': 'newvalue'}
)
import java.util.HashMap;
import java.util.Map;
import com.alibaba.dashscope.common.UpdateMetadataParam;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.InvalidateParameter;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.threads.runs.Run;
import com.alibaba.dashscope.threads.runs.Runs;
import com.alibaba.dashscope.utils.Constants;

public class Main {
    static {
        Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
    }
    public static void main(String[] args) throws ApiException, NoApiKeyException, InputRequiredException, InvalidateParameter, InterruptedException {
        Runs runs = new Runs();
        Map<String, String> metadata = new HashMap<>();
        metadata.put("key", "value");
        // DASHSCOPE_API_KEY 環境変数を設定することをお勧めします。 設定していない場合は、次の行をご自身の Model Studio API キーに置き換えてください: apiKey("sk-xxx")
        UpdateMetadataParam updateParam = UpdateMetadataParam.builder()
                .metadata(metadata)
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .build();
        Run run = runs.update("threadId", "runId", updateParam);
    }
}

リクエストパラメーター

パラメーター

タイプ

デフォルト値

説明

run_id

str

-

更新するランの ID です。

thread_id

str

-

実行が属するスレッドの ID。

metadata

Dict

None

アシスタントに関連付けられた情報。

workspace

str

None

Alibaba Cloud Model Studio のワークスペース ID。このパラメーターは、api_key がサブワークスペース API キーである場合にのみ必須です。

api_key

str

None

Model Studio のAPI キー。API キーを環境変数として設定する (非公開になり、「API キーの設定」にマージされます) ことを推奨します。

レスポンスパラメーター

レスポンスは create 操作と同じです。

ツール出力の送信とランの続行

実行のステータスが status: "requires_action" で、required_action.typesubmit_tool_outputs の場合、すべてのツール呼び出しが完了した後にこのエンドポイントを使用してツール出力を送信します。すべての出力は、1 回のリクエストで送信する必要があります。

HTTP

コード例

関数呼び出しを使用する場合、関数の実行結果を実行に返す必要があります。これにより、実行ステータスが「requires_action」からアクティブな状態に変わります。この場合、required_action.type の値は submit_tool_outputs です。

非ストリーミング

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_9157dfad-71fd-4add-b7a9-1afa452d2d67/runs/run_99935dbd-e731-4bad-b450-60d9d6bf9a44/submit_tool_outputs' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "tool_outputs": [
      {
        "tool_call_id": "",
        "output": "rain"
      }
    ]
  }'

ストリーミング

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_9157dfad-71fd-4add-b7a9-1afa452d2d67/runs/run_99935dbd-e731-4bad-b450-60d9d6bf9a44/submit_tool_outputs' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "tool_outputs": [
      {
        "tool_call_id": "",
        "output": "rain"
      }
    ],
    "stream": true
  }'

リクエストパラメーター

パラメーター

入力パラメーター

タイプ

必須

thread_id

変更するスレッドの ID。

string

はい

run_id

変更する実行の ID。

string

はい

tool_outputs

アシスタントに返すツール呼び出し結果のリスト。

array

はい

tool_outputs[].tool_call_id

ツール呼び出しの ID です。

string

いいえ

tool_outputs[].output

返す結果。

string

はい

stream

ストリーミングモードでレスポンスを返すかどうかを指定します。

boolean

いいえ

結果

非ストリーミング

{
    "id": "run_99935dbd-e731-4bad-b450-60d9d6bf9a44",
    "object": "thread.run",
    "created_at": 1711519089921,
    "thread_id": "thread_9157dfad-71fd-4add-b7a9-1afa452d2d67",
    "assistant_id": "asst_ce66cfa8-b2f8-4e4c-8e17-2c335145be42",
    "status": "in_progress",
    "required_action": {
        "type": "submit_tool_outputs",
        "submit_tool_outputs": {
            "tool_calls": [
                {
                    "function": {
                        "name": "get_current_weather",
                        "arguments": "{\"location\": \"Xi'an\"}"
                    },
                    "id": "",
                    "type": "function"
                }
            ]
        }
    },
    "last_error": {},
    "expires_at": 0,
    "started_at": 0,
    "cancelled_at": 0,
    "failed_at": 0,
    "completed_at": 0,
    "model": "qwen-max",
    "instructions": "あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出して回答を提供できます。必要に応じてツールを使用してください。",
    "tools": [
        {
            "type": "text_to_image"
        },
        {
            "type": "function",
            "function": {
                "name": "get_current_weather",
                "description": "指定された場所の現在の天気を取得します",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "都市と州 (例:カリフォルニア州サンフランシスコ)"
                        },
                        "unit": {
                            "type": "string",
                            "enum": [
                                "celsius",
                                "fahrenheit"
                            ]
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        }
    ],
    "metadata": {},
    "usage": null,
    "request_id": "792c29a2-e771-9840-9d99-df4f892badd0"
}

ストリーミング

event:thread.run.step.completed
data:{"id":"step_74a8b5e2-3d23-41d9-b5c8-9bf3ba3839d0","object":"thread.run.step","created_at":1714448906129,"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","thread_id":"thread_c6ac2eb0-ed95-4834-befb-ea66eba85b9f","run_id":"run_36d6fba9-0bf1-47f5-8e7b-f8c8140beda9","type":"tool_calls","status":"completed","step_details":{"type":"tool_calls","tool_calls":[{"id":"","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\": \"Xi'an\"}","output":"rain"}}]},"last_error":null,"expired_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"metadata":{},"usage":null,"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.run.queued
data:{"id":"run_36d6fba9-0bf1-47f5-8e7b-f8c8140beda9","object":"thread.run","created_at":1714448903737,"thread_id":"thread_c6ac2eb0-ed95-4834-befb-ea66eba85b9f","assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","status":"queued","required_action":null,"last_error":null,"expires_at":null,"started_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"model":"qwen-max","instructions":"あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出し、回答を提供できます。必要に応じてツールを使用してください。","tools":[{"type":"text_to_image"},{"type":"function","function":{"name":"get_current_weather","description":"指定された場所の現在の天気を取得します","parameters":{"type":"object","properties":{"location":{"type":"string","description":"市と州、例:カリフォルニア州サンフランシスコ"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"file_ids":[],"metadata":{},"usage":null,"temperature":null,"top_p":null,"top_k":null,"max_tokens":null,"truncation_strategy":null,"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.run.in_progress
data:{"id":"run_36d6fba9-0bf1-47f5-8e7b-f8c8140beda9","object":"thread.run","created_at":1714448903737,"thread_id":"thread_c6ac2eb0-ed95-4834-befb-ea66eba85b9f","assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","status":"in_progress","required_action":null,"last_error":null,"expires_at":null,"started_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"model":"qwen-max","instructions":"あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出し、回答を提供できます。必要に応じてツールを使用してください。","tools":[{"type":"text_to_image"},{"type":"function","function":{"name":"get_current_weather","description":"指定された場所の現在の天気を取得します","parameters":{"type":"object","properties":{"location":{"type":"string","description":"市と州、例:カリフォルニア州サンフランシスコ"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"file_ids":[],"metadata":{},"usage":null,"temperature":null,"top_p":null,"top_k":null,"max_tokens":null,"truncation_strategy":null,"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.run.step.created
data:{"id":"step_d74df5eb-dcb8-4fc2-a943-d06ccda0e2e3","object":"thread.run.step","created_at":1714449008828,"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","thread_id":"thread_c6ac2eb0-ed95-4834-befb-ea66eba85b9f","run_id":"run_36d6fba9-0bf1-47f5-8e7b-f8c8140beda9","type":"message_creation","status":"in_progress","step_details":{"type":"message_creation","message_creation":{"message_id":"message_965b3bb5-dbe2-434a-a36e-f7cda3845360"}},"last_error":null,"expired_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"metadata":{},"usage":null,"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.run.step.in_progress
data:{"id":"step_d74df5eb-dcb8-4fc2-a943-d06ccda0e2e3","object":"thread.run.step","created_at":1714449008828,"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","thread_id":"thread_c6ac2eb0-ed95-4834-befb-ea66eba85b9f","run_id":"run_36d6fba9-0bf1-47f5-8e7b-f8c8140beda9","type":"message_creation","status":"in_progress","step_details":{"type":"message_creation","message_creation":{"message_id":"message_965b3bb5-dbe2-434a-a36e-f7cda3845360"}},"last_error":null,"expired_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"metadata":{},"usage":null,"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.message.created
data:{"id":"message_965b3bb5-dbe2-434a-a36e-f7cda3845360","object":"thread.message","created_at":1714449008828,"thread_id":"thread_c6ac2eb0-ed95-4834-befb-ea66eba85b9f","incomplete_details":null,"completed_at":null,"incomplete_at":null,"role":"assistant","content":[],"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","run_id":"run_36d6fba9-0bf1-47f5-8e7b-f8c8140beda9","file_ids":[],"metadata":{},"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.message.in_progress
data:{"id":"message_965b3bb5-dbe2-434a-a36e-f7cda3845360","object":"thread.message","created_at":1714449008828,"thread_id":"thread_c6ac2eb0-ed95-4834-befb-ea66eba85b9f","incomplete_details":null,"completed_at":null,"incomplete_at":null,"role":"assistant","content":[],"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","run_id":"run_36d6fba9-0bf1-47f5-8e7b-f8c8140beda9","file_ids":[],"metadata":{},"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.message.delta
data:{"id":"message_965b3bb5-dbe2-434a-a36e-f7cda3845360","object":"thread.message.delta","delta":{"role":"assistant","content":[{"type":"text","text":{"value":"西","annotations":[]}}],"file_ids":[]},"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.message.delta
data:{"id":"message_965b3bb5-dbe2-434a-a36e-f7cda3845360","object":"thread.message.delta","delta":{"role":"assistant","content":[{"type":"text","text":{"value":"安の現在の天気は","annotations":[]}}],"file_ids":[]},"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.message.delta
data:{"id":"message_965b3bb5-dbe2-434a-a36e-f7cda3845360","object":"thread.message.delta","delta":{"role":"assistant","content":[{"type":"text","text":{"value":"雨です。","annotations":[]}}],"file_ids":[]},"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.message.delta
data:{"id":"message_965b3bb5-dbe2-434a-a36e-f7cda3845360","object":"thread.message.delta","delta":{"role":"assistant","content":[{"type":"text","text":{"value":"","annotations":[]}}],"file_ids":[]},"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.message.completed
data:{"id":"message_965b3bb5-dbe2-434a-a36e-f7cda3845360","object":"thread.message","created_at":1714449008828,"thread_id":"thread_c6ac2eb0-ed95-4834-befb-ea66eba85b9f","incomplete_details":null,"completed_at":1714449009919,"incomplete_at":null,"role":"assistant","content":[{"type":"text","text":{"value":"西安の現在の天気は雨です。","annotations":[]}}],"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","run_id":"run_36d6fba9-0bf1-47f5-8e7b-f8c8140beda9","file_ids":[],"metadata":{},"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.run.step.completed
data:{"id":"step_d74df5eb-dcb8-4fc2-a943-d06ccda0e2e3","object":"thread.run.step","created_at":1714449008828,"assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","thread_id":"thread_c6ac2eb0-ed95-4834-befb-ea66eba85b9f","run_id":"run_36d6fba9-0bf1-47f5-8e7b-f8c8140beda9","type":"message_creation","status":"completed","step_details":{"type":"message_creation","message_creation":{"message_id":"message_965b3bb5-dbe2-434a-a36e-f7cda3845360"}},"last_error":null,"expired_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1714449009919,"metadata":{},"usage":null,"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:thread.run.completed
data:{"id":"run_36d6fba9-0bf1-47f5-8e7b-f8c8140beda9","object":"thread.run","created_at":1714448903737,"thread_id":"thread_c6ac2eb0-ed95-4834-befb-ea66eba85b9f","assistant_id":"asst_5378d83a-f612-4fc1-9034-915351d67d98","status":"completed","required_action":null,"last_error":null,"expires_at":null,"started_at":null,"cancelled_at":null,"failed_at":null,"completed_at":null,"model":"qwen-max","instructions":"あなたはインテリジェントアシスタントです。ユーザーのニーズに基づいてさまざまなツールを呼び出し、回答を提供できます。必要に応じてツールを使用してください。","tools":[{"type":"text_to_image"},{"type":"function","function":{"name":"get_current_weather","description":"指定された場所の現在の天気を取得します","parameters":{"type":"object","properties":{"location":{"type":"string","description":"市と州、例:カリフォルニア州サンフランシスコ"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"file_ids":[],"metadata":{},"usage":{"input_tokens":439,"output_tokens":11,"total_tokens":450},"temperature":null,"top_p":null,"top_k":null,"max_tokens":null,"truncation_strategy":null,"request_id":"6d1573a4-3cbb-9066-99cc-7247ec17cb30"}

event:done
data:[DONE]

レスポンスパラメーター

指定された ID に一致する変更後の実行オブジェクトが返されます。

SDK

import json
import sys
from http import HTTPStatus
import dashscope
from dashscope import Assistants, Messages, Runs, Steps, Threads

dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
def create_assistant():
    # create assistant with information
    assistant = Assistants.create(
        model='qwen-max',
        name='smart helper',
        description='A tool helper.',
        instructions='あなたは役立つアシスタントです。質問されたときは、可能な限りツールを使用してください。',  # noqa E501
        tools=[{
            'type': 'function',
            'function': {
                'name': 'big_add',
                'description': 'Add to number',
                'parameters': {
                    'type': 'object',
                    'properties': {
                        'left': {
                            'type': 'integer',
                            'description': 'The left operator'
                        },
                        'right': {
                            'type': 'integer',
                            'description': 'The right operator.'
                        }
                    },
                    'required': ['left', 'right']
                }
            }
        }],
    )

    return assistant

def verify_status_code(res):
    if res.status_code != HTTPStatus.OK:
        sys.exit(res.status_code)


if __name__ == '__main__':
    # create assistant
    assistant = create_assistant()
    print(assistant)
    verify_status_code(assistant)

    # create thread.
    thread = Threads.create()
    print(thread)
    verify_status_code(thread)

    # create a message.
    message = Messages.create(thread.id, content='bigAdd 87787 to 788988737.')
    print(message)
    verify_status_code(message)

    # create run to run message

    message_run = Runs.create(thread.id, assistant_id=assistant.id)
    print(message_run)
    verify_status_code(message_run)

    # get run statue
    run_status = Runs.get(message_run.id, thread_id=thread.id)
    print(run_status)
    verify_status_code(run_status)

    # wait for run completed or requires_action
    run_status = Runs.wait(message_run.id, thread_id=thread.id)
    print(run_status)

    # if prompt input tool result, submit tool result.
    # should call big_add
    if run_status.required_action:
        tool_outputs = [{
            'tool_call_id':
            run_status.required_action.submit_tool_outputs.tool_calls[0].id,
            'output':
            '789076524'
        }]
        run = Runs.submit_tool_outputs(message_run.id,
                                       thread_id=thread.id,
                                       tool_outputs=tool_outputs)
        print(run)
        verify_status_code(run)

        # wait for run completed or requires_action
        run_status = Runs.wait(message_run.id, thread_id=thread.id)
        print(run_status)
        verify_status_code(run_status)

    run_status = Runs.get(run.id, thread_id=thread.id)
    print(run_status)
    verify_status_code(run_status)

    run_steps = Steps.list(run.id,  thread_id=thread.id)

    print(run_steps)
    verify_status_code(run_steps)

    # get the thread messages.
    msgs = Messages.list(thread.id)
    print(msgs)
    print(json.dumps(msgs, default=lambda o: o.__dict__, sort_keys=True, indent=4))
import com.alibaba.dashscope.assistants.Assistant;
import com.alibaba.dashscope.assistants.AssistantParam;
import com.alibaba.dashscope.tools.ToolFunction;
import com.alibaba.dashscope.assistants.Assistants;
import com.alibaba.dashscope.common.GeneralListParam;
import com.alibaba.dashscope.common.ListResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.InvalidateParameter;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.threads.AssistantThread;
import com.alibaba.dashscope.threads.ThreadParam;
import com.alibaba.dashscope.threads.Threads;
import com.alibaba.dashscope.threads.messages.Messages;
import com.alibaba.dashscope.threads.messages.TextMessageParam;
import com.alibaba.dashscope.threads.messages.ThreadMessage;
import com.alibaba.dashscope.threads.runs.RequiredAction;
import com.alibaba.dashscope.threads.runs.Run;
import com.alibaba.dashscope.threads.runs.RunParam;
import com.alibaba.dashscope.threads.runs.Runs;
import com.alibaba.dashscope.threads.runs.SubmitToolOutputsParam;
import com.alibaba.dashscope.threads.runs.ToolOutput;
import com.alibaba.dashscope.tools.FunctionDefinition;
import com.alibaba.dashscope.tools.ToolCallBase;
import com.alibaba.dashscope.utils.JsonUtils;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.victools.jsonschema.generator.Option;
import com.github.victools.jsonschema.generator.OptionPreset;
import com.github.victools.jsonschema.generator.SchemaGenerator;
import com.github.victools.jsonschema.generator.SchemaGeneratorConfig;
import com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder;
import com.github.victools.jsonschema.generator.SchemaVersion;
import com.alibaba.dashscope.tools.ToolCallFunction;
import com.alibaba.dashscope.utils.Constants;

public class AssistantFunctionCall {
    static {
        Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
    }
    public class AddFunctionTool {
        private int left;
        private int right;

        public AddFunctionTool(int left, int right) {
            this.left = left;
            this.right = right;
        }

        public int call() {
            return left + right;
        }
    }

    static ToolFunction buildFunction() {
        SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2020_12,
                OptionPreset.PLAIN_JSON);
        SchemaGeneratorConfig config = configBuilder.with(Option.EXTRA_OPEN_API_FORMAT_VALUES)
                .without(Option.FLATTENED_ENUMS_FROM_TOSTRING).build();
        SchemaGenerator generator = new SchemaGenerator(config);

        // 関数の jsonSchema を生成します。
        ObjectNode jsonSchema = generator.generateSchema(AddFunctionTool.class);

        // 関数呼び出しのツールで呼び出します。jsonSchema.toString() は jsonschema 文字列です。
        FunctionDefinition fd = FunctionDefinition.builder().name("add").description("add two number")
                .parameters(JsonUtils.parseString(jsonSchema.toString()).getAsJsonObject()).build();
        return ToolFunction.builder().function(fd).build();
    }
    static public Assistant createAssistant() throws ApiException, NoApiKeyException{
        AssistantParam assistantParam = AssistantParam.builder()
        .model("qwen-max") // モデルを設定する必要があります。
        .description("a helper assistant")
        .name("system")  // 名前を設定する必要があります。
        .instructions("You are a helpful assistant. When asked a question, use tools wherever possible.")
        .tool(buildFunction())
        .build();
        Assistants assistants = new Assistants();
        return assistants.create(assistantParam);
    }

    static public void run(String assistantId) throws ApiException, NoApiKeyException, InvalidateParameter, InputRequiredException, InterruptedException{
        // スレッドを作成します。
        Threads threads = new Threads();
        AssistantThread assistantThread = threads.create(ThreadParam.builder().build());    
        
        Runs runs = new Runs();
        // 新しいメッセージを作成します。
        TextMessageParam textMessageParam = TextMessageParam.builder().role("user").content("Add 87787 to 788988737.").build();
        Messages messages = new Messages();
        ThreadMessage threadMessage = messages.create(assistantThread.getId(), textMessageParam);
        System.out.println(threadMessage);
        RunParam runParam = RunParam.builder().assistantId(assistantId).build();
        Run run = runs.create(assistantThread.getId(), runParam);
        while(true){
            if(run.getStatus().equals(Run.Status.CANCELLED) || 
            run.getStatus().equals(Run.Status.COMPLETED) ||
            run.getStatus().equals(Run.Status.FAILED) ||
            run.getStatus().equals(Run.Status.REQUIRES_ACTION)||
            run.getStatus().equals(Run.Status.EXPIRED)){
                break;
            }else{
                Thread.sleep(1000);
            }
            run = runs.retrieve(assistantThread.getId(), run.getId());
        }
        if(run.getStatus().equals(Run.Status.REQUIRES_ACTION)){   
            // アクションの出力を送信します。
            RequiredAction requiredAction = run.getRequiredAction();
            if(requiredAction.getType().equals("submit_tool_outputs")){
                ToolCallBase toolCall = requiredAction.getSubmitToolOutputs().getToolCalls().get(0);
                if (toolCall.getType().equals("function")) {
                    // 関数呼び出し名と引数 (両方とも文字列) を取得します。
                    String functionName = ((ToolCallFunction) toolCall).getFunction().getName();
                    String functionId = ((ToolCallFunction)toolCall).getId();
                    String functionArgument = ((ToolCallFunction) toolCall).getFunction().getArguments();
                    if (functionName.equals("add")) {
                      // 関数オブジェクトを作成します。
                      AddFunctionTool addFunction =
                          JsonUtils.fromJson(functionArgument, AddFunctionTool.class);
                      // 関数を呼び出します。
                      int sum = addFunction.call();
                      System.out.println(sum);
                      SubmitToolOutputsParam submitToolOutputsParam = SubmitToolOutputsParam.builder()
                      .toolOutput(ToolOutput.builder().toolCallId(functionId).output(String.valueOf(sum)).build())
                      .build();
                      run = runs.submitToolOutputs(assistantThread.getId(), run.getId(), submitToolOutputsParam);
                    }
                  }
            }    
        }
        while(true){
            if(run.getStatus().equals(Run.Status.CANCELLED) || 
            run.getStatus().equals(Run.Status.COMPLETED) ||
            run.getStatus().equals(Run.Status.FAILED) ||
            run.getStatus().equals(Run.Status.REQUIRES_ACTION)||
            run.getStatus().equals(Run.Status.EXPIRED)){
                break;
            }else{
                Thread.sleep(1000);
            }
            run = runs.retrieve(assistantThread.getId(), run.getId());
        }        

        GeneralListParam listParam = GeneralListParam.builder().limit(100l).build();
        ListResult<ThreadMessage> threadMessages = messages.list(assistantThread.getId(), listParam);
        for(ThreadMessage threadMessage2: threadMessages.getData()){
            System.out.println(threadMessage2);
        }

    }

    public static void main(String[] args) throws ApiException, NoApiKeyException, InputRequiredException, InvalidateParameter, InterruptedException {
        Assistant assistant = createAssistant();
        run(assistant.getId());
    }
}

ランの完了待機

この操作は、実行が完了するのを待機します。実行は終端状態で返されます。終端状態には、「cancelled」、「failed」、「completed」、「expired」、「requires_action」が含まれます。

SDK

コード例

import dashscope
from dashscope import Runs
import os

dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
run = Runs.wait(
    'run_id',
    # DASHSCOPE_API_KEY 環境変数を設定することを推奨します。設定していない場合は、次の行をご利用の Model Studio API キーに置き換えてください:api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    thread_id='thread_id'
)
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.InvalidateParameter;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.threads.runs.Run;
import com.alibaba.dashscope.threads.runs.Runs;
import com.alibaba.dashscope.utils.Constants;

public class AssistantFunctionCall {
    static {
        Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
    }
    public static void main(String[] args) throws ApiException, NoApiKeyException, InputRequiredException, InvalidateParameter, InterruptedException {
        Runs runs = new Runs();
        // DASHSCOPE_API_KEY 環境変数を設定することをお勧めします。設定していない場合は、次の行を Model Studio API キーに置き換えてください: apiKey("sk-xxx")
        String apiKey = System.getenv("DASHSCOPE_API_KEY");
        Run run = runs.retrieve("thread_id", "run_id", apiKey);
        while(true){
            if(run.getStatus().equals(Run.Status.CANCELLED) || 
            run.getStatus().equals(Run.Status.COMPLETED) ||
            run.getStatus().equals(Run.Status.FAILED) ||
            run.getStatus().equals(Run.Status.REQUIRES_ACTION)||
            run.getStatus().equals(Run.Status.EXPIRED)){
                break;
            }else{
                Thread.sleep(1000);
            }
            run = runs.retrieve("thread_id", run.getId());
        }
    }
}

リクエストパラメーター

パラメーター

タイプ

デフォルト値

説明

run_id

string

-

キャンセルする実行の ID を指定します。

thread_id

string

-

実行が属するスレッドの ID。

workspace

string

None

Alibaba Cloud Model Studio のワークスペース ID。このパラメーターは、api_key がサブワークスペース API キーである場合にのみ必須です。

api_key

string

None

Model Studio のAPI キー。API キーを環境変数として設定する (このトピックは非公開予定で、「API キーの設定」にマージされます) ことを推奨します。

レスポンスパラメーター

指定された ID に一致する実行オブジェクトが返されます。

実行オブジェクト

実行オブジェクトは、スレッドで実行中の実行を表します。

オブジェクトの例

{
    "assistant_id": "[REDACTED]",
    "cancelled_at": null,
    "completed_at": null,
    "created_at": 1735026246751,
    "enable_search": null,
    "expires_at": null,
    "failed_at": null,
    "file_ids": [],
    "id": "[REDACTED]",
    "instructions": "あなたは役立つアシスタントです",
    "last_error": null,
    "max_tokens": null,
    "metadata": {},
    "model": "qwen-plus",
    "object": "thread.run",
    "request_id": "[REDACTED]",
    "required_action": null,
    "started_at": null,
    "status": "in_progress",
    "status_code": 200,
    "stop": "",
    "temperature": null,
    "thread_id": "[REDACTED]",
    "tool_choice": "auto",
    "tools": [],
    "top_k": null,
    "top_p": null,
    "truncation_strategy": null,
    "usage": null
}

オブジェクト属性

パラメーター

タイプ

説明

id

string

ランの一意の識別子です。

assistant_id

string

このランに関連付けられたアシスタントの ID です。

cancelled_at

integer

実行がキャンセルされたときの UNIX タイムスタンプ (ミリ秒単位)。

completed_at

integer

実行が完了したときの UNIX タイムスタンプ (ミリ秒単位)。

created_at

integer

実行が作成されたときの UNIX タイムスタンプ (ミリ秒単位)。

expires_at

integer

実行が期限切れになる UNIX タイムスタンプ (ミリ秒単位)。

failed_at

integer

実行が失敗したときの UNIX タイムスタンプ (ミリ秒単位)。

instructions

string

ランの命令です。

metadata

map

オブジェクトにアタッチできる最大 16 個のキーと値のペアのセット。これは、オブジェクトに関する追加情報を構造化されたフォーマットで保存するのに役立ちます。キーは最大 64 文字、値は最大 512 文字です。

last_error

string

この実行に関連付けられた最後のエラー。エラーがない場合は null になります。

model

string

ランに使用されるモデルの名前です。

object

string

オブジェクトタイプで、常に `thread.run` です。

required_action

object

ツール出力の送信など、実行に必要な操作の詳細。

started_at

integer

実行が開始されたときの UNIX タイムスタンプ (ミリ秒単位)。

status

string

実行のステータス。有効な値:queued、in_progress、requires_action、cancelling、cancelled、failed、completed、expired。

thread_id

string

この実行が属するスレッドの ID。

tools

array

ランが使用するツールのリストです。

usage

object

リソース使用量に関する統計。

status_code

integer

HTTP ステータスコード。注:このパラメーターは内部使用専用です。このパラメーターは無視できます。

よくある質問

  • Q:進行中のランをキャンセルするにはどうすればよいですか?

    A:現在、アシスタント API には実行をキャンセルするエンドポイントはありません。回避策として、アプリケーションにキャンセルロジックを実装することを推奨します。

エラーコード

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