-
Notifications
You must be signed in to change notification settings - Fork 26
funasr support payload.input and bug fix in transcription #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -191,6 +191,7 @@ async def wait( | |||||
| task: Union[str, DashScopeAPIResponse], | ||||||
| api_key: str = None, | ||||||
| workspace: str = None, | ||||||
| wait_timeout: int = -1, | ||||||
| **kwargs, | ||||||
| ) -> DashScopeAPIResponse: | ||||||
| """Wait for async task completion and return task result. | ||||||
|
|
@@ -199,6 +200,12 @@ async def wait( | |||||
| task (Union[str, DashScopeAPIResponse]): The task_id, or | ||||||
| async_call response. | ||||||
| api_key (str, optional): The api_key. Defaults to None. | ||||||
| workspace (str, optional): The dashscope workspace id. | ||||||
| wait_timeout (int, optional): The maximum seconds to wait | ||||||
| for the task to complete. Default is -1, which means no | ||||||
| timeout. When set to a value > 0, if the task does not | ||||||
| complete within this time, a timeout error response will | ||||||
| be returned. | ||||||
|
|
||||||
| Returns: | ||||||
| DashScopeAPIResponse: The async task information. | ||||||
|
|
@@ -208,6 +215,7 @@ async def wait( | |||||
| max_wait_seconds = 5 | ||||||
| increment_steps = 3 | ||||||
| step = 0 | ||||||
| start_time = time.time() | ||||||
| while True: | ||||||
| step += 1 | ||||||
| # we start by querying once every second, and double | ||||||
|
|
@@ -217,6 +225,21 @@ async def wait( | |||||
| # (server side return immediately when ready) | ||||||
| if wait_seconds < max_wait_seconds and step % increment_steps == 0: | ||||||
| wait_seconds = min(wait_seconds * 2, max_wait_seconds) | ||||||
| if 0 < wait_timeout <= (time.time() - start_time): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If Adding a check to ensure
Suggested change
|
||||||
| logger.warning( | ||||||
| "Wait task: %s timeout after %s seconds.", | ||||||
| task_id, | ||||||
| wait_timeout, | ||||||
| ) | ||||||
| return DashScopeAPIResponse( | ||||||
| request_id=task_id, | ||||||
| status_code=HTTPStatus.REQUEST_TIMEOUT, | ||||||
| code="WaitTaskTimeout", | ||||||
| message=( | ||||||
| f"Wait task: {task_id} timeout after " | ||||||
| f"{wait_timeout} seconds." | ||||||
| ), | ||||||
| ) | ||||||
| rsp = await cls._get( | ||||||
| task_id, | ||||||
| api_key, | ||||||
|
|
@@ -600,6 +623,10 @@ def call( | |||||
| **kwargs, | ||||||
| ) -> DashScopeAPIResponse: | ||||||
| """Call service and get result.""" | ||||||
| wait_timeout = -1 | ||||||
| if "wait_timeout" in kwargs: | ||||||
| wait_timeout = kwargs.pop("wait_timeout") | ||||||
|
|
||||||
| task_response = cls.async_call( # type: ignore[misc] | ||||||
| *args, | ||||||
| api_key=api_key, | ||||||
|
|
@@ -610,6 +637,7 @@ def call( | |||||
| task_response, | ||||||
| api_key=api_key, | ||||||
| workspace=workspace, | ||||||
| wait_timeout=wait_timeout, | ||||||
| ) | ||||||
| return response | ||||||
|
|
||||||
|
|
@@ -767,6 +795,7 @@ def wait( | |||||
| task: Union[str, DashScopeAPIResponse], | ||||||
| api_key: str = None, | ||||||
| workspace: str = None, | ||||||
| wait_timeout: int = -1, | ||||||
| **kwargs, | ||||||
| ) -> DashScopeAPIResponse: | ||||||
| """Wait for async task completion and return task result. | ||||||
|
|
@@ -775,6 +804,12 @@ def wait( | |||||
| task (Union[str, DashScopeAPIResponse]): The task_id, or | ||||||
| async_call response. | ||||||
| api_key (str, optional): The api_key. Defaults to None. | ||||||
| workspace (str, optional): The dashscope workspace id. | ||||||
| wait_timeout (int, optional): The maximum seconds to wait | ||||||
| for the task to complete. Default is -1, which means no | ||||||
| timeout. When set to a value > 0, if the task does not | ||||||
| complete within this time, a timeout error response will | ||||||
| be returned. | ||||||
|
|
||||||
| Returns: | ||||||
| DashScopeAPIResponse: The async task information. | ||||||
|
|
@@ -784,6 +819,7 @@ def wait( | |||||
| max_wait_seconds = 5 | ||||||
| increment_steps = 3 | ||||||
| step = 0 | ||||||
| start_time = time.time() | ||||||
| while True: | ||||||
| step += 1 | ||||||
| # we start by querying once every second, and double | ||||||
|
|
@@ -794,6 +830,21 @@ def wait( | |||||
| # (server side return immediately when ready) | ||||||
| if wait_seconds < max_wait_seconds and step % increment_steps == 0: | ||||||
| wait_seconds = min(wait_seconds * 2, max_wait_seconds) | ||||||
| if 0 < wait_timeout <= (time.time() - start_time): | ||||||
|
songguocola marked this conversation as resolved.
|
||||||
| logger.warning( | ||||||
| "Wait task: %s timeout after %s seconds.", | ||||||
| task_id, | ||||||
| wait_timeout, | ||||||
| ) | ||||||
| return DashScopeAPIResponse( | ||||||
| request_id=task_id, | ||||||
| status_code=HTTPStatus.REQUEST_TIMEOUT, | ||||||
| code="WaitTaskTimeout", | ||||||
| message=( | ||||||
| f"Wait task: {task_id} timeout after " | ||||||
| f"{wait_timeout} seconds." | ||||||
| ), | ||||||
| ) | ||||||
| rsp = cls._get(task_id, api_key, workspace=workspace, **kwargs) | ||||||
| if rsp.status_code == HTTPStatus.OK: | ||||||
| if rsp.output is None: | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.