Skip to content

Conversation

Stream29
Copy link

@Stream29 Stream29 commented Aug 28, 2025

Motivation and Context

Alibaba cloud serves Qwen models and they have a different API format. This PR adds support to use models on Alibaba dashscope platform.

Resolves #529.

Breaking Changes

No breaking change.


Type of the changes

New feature (non-breaking change which adds functionality)

Checklist

  • The pull request has a description of the proposed change
  • I read the Contributing Guidelines before opening the pull request
  • The pull request uses develop as the base branch
  • Tests for the changes have been added
  • All new and existing tests passed
Additional steps for pull requests adding a new feature
  • An issue describing the proposed change exists
  • The pull request includes a link to the issue
  • The change was discussed and approved in the issue
  • Docs have been added / updated

@Stream29 Stream29 marked this pull request as ready for review August 30, 2025 15:36
@kid1412621
Copy link

Seems the dashscope platform updated to sfm(bailian). Use the naming for client might not be a good idea.

@Stream29
Copy link
Author

Seems the dashscope platform updated to sfm(bailian). Use the naming for client might not be a good idea.

@kid1412621 In their official SDKs, they still call themselves as Dashscope SDK. So I just followed their naming,

Copy link
Contributor

@devcrocod devcrocod left a comment

Choose a reason for hiding this comment

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

thanks a lot!
lgtm!

Have you tested this client locally?
Could you also update to the latest changes from develop branch and add the logic with additionalProperties?

* @property promptTokensDetails Breakdown of tokens used in the prompt.
*/
@Serializable
public class DashscopeUsage(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the usage of DashScope different from OpenAI?
I think they’re the same, so you could reuse OpenAIUsage

Copy link
Author

Choose a reason for hiding this comment

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

I had found a slight different after testing locally.

/**
 * @property audioTokens Audio input tokens generated by the model.
 * @property cachedTokens Cached tokens present in the prompt.
 */
@Serializable
public class PromptTokensDetails(
    public val audioTokens: Int? = null,
    public val cachedTokens: Int,
)

In older versions of Koog, the audioTokens property of PromptTokensDetails does not have a default value and will cause SerializationException for missing field with Dashscope endpoints.

In commit 6b2283a1fb733e95ccc28453f3c09cf30588dad1, this property was changed nullable and having a null default value. So I agree with your idea.

Copy link
Author

Choose a reason for hiding this comment

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

OK. Refactored.

* @property maxTokens The maximum number of tokens to generate.
* @property toolChoice Controls which (if any) tool is called by the model.
*/
public data class DashscopeParams(
Copy link
Contributor

Choose a reason for hiding this comment

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

DashscopeParams should inherit from LLMParams. But if it doesn’t extend LLMParams, then it’s better not to use it at all

Copy link
Author

Choose a reason for hiding this comment

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

OK. Refactored.

/**
* Dashscope LLM models enumeration.
*/
public object DashscopeModels : LLModelDefinitions {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the documentation I see many more models – https://modelstudio.console.alibabacloud.com/?tab=doc#/doc/?type=model&url=2840914
Could you please add the latest Qwen3 models and remove the old turbo?

Copy link
Author

Choose a reason for hiding this comment

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

OK. Added.

@Stream29 Stream29 requested a review from devcrocod October 3, 2025 13:21
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.

Qwen support
3 participants