Check the response from the completion call.
Use tenacity to retry the completion call.
Use tenacity to retry the completion call.
Async version of stream_generate_with_retry.
Because the dashscope SDK doesn't provide an async API,
we wrap stream_generate_with_retry with an async generator.
Generate elements from an iterable, and a boolean indicating if it is the last element.
Generate elements from an async iterable, and a boolean indicating if it is the last element.