Download lib/python3.11/site-packages/dashscope/threads/runs/steps.py from michaelu0826/phantom_env: direct link, hf CLI and curl.
- Browser
- Download file 3.74 kB
-
https://huggingface.co/datasets/michaelu0826/phantom_env/resolve/main/lib/python3.11/site-packages/dashscope/threads/runs/steps.py
- Command line
-
hf download hf://datasets/michaelu0826/phantom_env/lib/python3.11/site-packages/dashscope/threads/runs/steps.py
-
curl -L -o steps.py https://huggingface.co/datasets/michaelu0826/phantom_env/resolve/main/lib/python3.11/site-packages/dashscope/threads/runs/steps.py
3.74 kB
| # -*- coding: utf-8 -*- | |
| # Copyright (c) Alibaba, Inc. and its affiliates. | |
| from dashscope.client.base_api import GetStatusMixin, ListObjectMixin | |
| from dashscope.common.error import InputRequired | |
| from dashscope.threads.thread_types import RunStep, RunStepList | |
| __all__ = ["Steps"] | |
| class Steps(ListObjectMixin, GetStatusMixin): | |
| SUB_PATH = "RUNS" # useless | |
| def list( # type: ignore[override] | |
| cls, | |
| run_id: str, | |
| *, | |
| thread_id: str, | |
| limit: int = None, | |
| order: str = None, | |
| after: str = None, | |
| before: str = None, | |
| workspace: str = None, | |
| api_key: str = None, | |
| **kwargs, | |
| ) -> RunStepList: | |
| """List `RunStep` of `Run`. | |
| Args: | |
| thread_id (str): The thread id. | |
| run_id (str): The run id. | |
| limit (int, optional): | |
| How many assistant to retrieve. Defaults to None. | |
| order (str, optional): Sort order by created_at. Defaults to None. | |
| after (str, optional): Assistant id after. Defaults to None. | |
| before (str, optional): Assistant id before. Defaults to None. | |
| workspace (str, optional): | |
| The DashScope workspace id. Defaults to None. | |
| api_key (str, optional): Your DashScope api key. Defaults to None. | |
| Returns: | |
| RunList: The list of runs. | |
| """ | |
| if not run_id: | |
| raise InputRequired("run_id is required!") | |
| response = super().list( | |
| limit=limit, | |
| order=order, | |
| after=after, | |
| before=before, | |
| path=f"threads/{thread_id}/runs/{run_id}/steps", | |
| workspace=workspace, | |
| api_key=api_key, | |
| flattened_output=True, | |
| **kwargs, | |
| ) | |
| return RunStepList(**response) | |
| def retrieve( | |
| cls, | |
| step_id: str, | |
| *, | |
| thread_id: str, | |
| run_id: str, | |
| workspace: str = None, | |
| api_key: str = None, | |
| **kwargs, | |
| ) -> RunStep: | |
| """Retrieve the `RunStep`. | |
| Args: | |
| thread_id (str): The thread id. | |
| run_id (str): The run id. | |
| step_id (str): The step id. | |
| workspace (str): The dashscope workspace id. | |
| api_key (str, optional): The api key. Defaults to None. | |
| Returns: | |
| RunStep: The `RunStep` object. | |
| """ | |
| if not thread_id or not run_id or not step_id: | |
| raise InputRequired("thread_id, run_id and step_id are required!") | |
| response = super().get( | |
| run_id, | |
| path=f"threads/{thread_id}/runs/{run_id}/steps/{step_id}", | |
| workspace=workspace, | |
| api_key=api_key, | |
| flattened_output=True, | |
| **kwargs, | |
| ) | |
| return RunStep(**response) | |
| def get( # type: ignore[override] | |
| cls, | |
| step_id: str, | |
| *, | |
| thread_id: str, | |
| run_id: str, | |
| workspace: str = None, | |
| api_key: str = None, | |
| **kwargs, | |
| ) -> RunStep: | |
| """Retrieve the `RunStep`. | |
| Args: | |
| thread_id (str): The thread id. | |
| run_id (str): The run id. | |
| step_id (str): The step id. | |
| workspace (str): The dashscope workspace id. | |
| api_key (str, optional): The api key. Defaults to None. | |
| Returns: | |
| RunStep: The `RunStep` object. | |
| """ | |
| # pylint: disable=too-many-function-args | |
| return cls.retrieve( # type: ignore[misc] | |
| thread_id, | |
| run_id, | |
| step_id, | |
| workspace=workspace, | |
| api_key=api_key, | |
| **kwargs, | |
| ) | |