Skip to content

feat: add Astraflow provider support to voice input example#2870

Open
ucloudnb666 wants to merge 1 commit into
modelscope:mainfrom
ucloudnb666:feat/astraflow-1779630321
Open

feat: add Astraflow provider support to voice input example#2870
ucloudnb666 wants to merge 1 commit into
modelscope:mainfrom
ucloudnb666:feat/astraflow-1779630321

Conversation

@ucloudnb666
Copy link
Copy Markdown

Summary

Adds Astraflow (by UCloud / 优刻得) as a named provider shortcut in examples/voice_input/funasr_input.py.

Astraflow is an OpenAI-compatible AI model aggregation platform supporting 200+ models. Because the voice input tool already uses the openai Python client with a configurable base_url, wiring in Astraflow requires only:

  1. A PROVIDER_CONFIGS dict that maps provider names → (base_url, api_key_env).
  2. A --provider CLI argument that overrides --server / --apikey when set.
  3. Env-var validation with a helpful signup URL when the key is missing.

Usage:

Global endpoint (outside China):

export ASTRAFLOW_API_KEY=your_key_here
python funasr_input.py --provider astraflow --model sensevoice

China endpoint:

export ASTRAFLOW_CN_API_KEY=your_key_here
python funasr_input.py --provider astraflow-cn --model sensevoice

Type of change

  • Bug fix
  • Documentation
  • Example or demo
  • Runtime or deployment
  • Benchmark or evaluation
  • Model/training change

Validation

Changes are limited to examples/voice_input/funasr_input.py: adds PROVIDER_CONFIGS, --provider / --apikey CLI args, provider resolution logic, and updated usage examples in the docstring. No new files, no new dependencies, no changes to core FunASR model code.

  • python -m compileall funasr examples tests
  • Docs or links checked
  • Runtime/deployment command tested

N/A (no screenshots or recordings applicable)

User impact

Users who want to use Astraflow (by UCloud / 优刻得) as their LLM backend — both global users (ASTRAFLOW_API_KEY) and China-region users (ASTRAFLOW_CN_API_KEY) — can now select it via a single --provider astraflow or --provider astraflow-cn flag without manually specifying --server and --apikey. This lowers the barrier for new users onboarding with an OpenAI-compatible aggregation platform supporting 200+ models.

Notes for reviewers

  • This is a purely additive change to one example file; no core library code is touched.
  • The new --provider argument short-circuits --server / --apikey when set, so existing CLI usage is fully backward-compatible.
  • Provider endpoint details:
Field Value
Global endpoint https://api-us-ca.umodelverse.ai/v1
China endpoint https://api.modelverse.cn/v1
Global signup https://astraflow.ucloud-global.com
China signup https://astraflow.ucloud.cn
Protocol OpenAI-compatible (drop-in base_url replacement)
  • Follow-up: other named providers could be added to PROVIDER_CONFIGS using the same pattern.

Signed-off-by: ucloudnb666 <ucloudnb666@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a provider shortcut system for the FunASR voice input example, allowing users to switch between local and Astraflow backends via a new --provider flag. It also adds support for API keys through command-line arguments or environment variables. The reviewer suggested simplifying the API key assignment logic by removing an unnecessary getattr call and redundant default value handling.

else:
args.apikey = args.apikey or "not-needed"

api_key = getattr(args, "apikey", None) or "not-needed"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use of getattr(args, "apikey", None) is unnecessary here because apikey is a defined argument in the parser and is guaranteed to exist on the args object. You can simplify this to a direct attribute access. Additionally, the default value logic here makes the else block at lines 88-89 redundant.

    api_key = args.apikey or "not-needed"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant