Table of Contents

Class QwenService

Namespace
Mythosia.AI.Providers.Alibaba
Assembly
Mythosia.AI.Providers.Alibaba.dll
public class QwenService : OpenAICompatibleService, IAIService, IAIRunService, IAIRequestFeatureService, IFunctionRegisterable, IAIProcessingInfoService
Inheritance
QwenService
Implements
Inherited Members

Constructors

QwenService(string, EndpointPlatform, HttpClient)

public QwenService(string baseUrl, EndpointPlatform platform, HttpClient httpClient)

Parameters

baseUrl string
platform EndpointPlatform
httpClient HttpClient

QwenService(string, EndpointPlatform, string, HttpClient)

public QwenService(string baseUrl, EndpointPlatform platform, string model, HttpClient httpClient)

Parameters

baseUrl string
platform EndpointPlatform
model string
httpClient HttpClient

QwenService(string, HttpClient)

public QwenService(string apiKey, HttpClient httpClient)

Parameters

apiKey string
httpClient HttpClient

QwenService(string, string, HttpClient)

public QwenService(string apiKey, string model, HttpClient httpClient)

Parameters

apiKey string
model string
httpClient HttpClient

Properties

ModelIdOverride

public string? ModelIdOverride { get; set; }

Property Value

string

Provider

The AI provider for this service

public override string Provider { get; }

Property Value

string

ThinkingMode

public QwenThinking ThinkingMode { get; set; }

Property Value

QwenThinking

Methods

ApplyCapabilityRequestProfile(AIRequestProfile)

Applies only execution-local profile settings needed to describe capabilities.

protected override void ApplyCapabilityRequestProfile(AIRequestProfile profile)

Parameters

profile AIRequestProfile

Remarks

Common builder overrides are already captured. Custom providers may override this hook with SetExecutionSetting calls for native mode flags. Do not prepare execution, reserve token budgets, invoke callbacks, validate requests, or modify service/caller-owned state. Execution profile hooks are intentionally not called during inspection.

ApplyProviderSpecificRequestProfile(AIRequestProfile)

protected override Action ApplyProviderSpecificRequestProfile(AIRequestProfile profile)

Parameters

profile AIRequestProfile

Returns

Action

CaptureRequestSettings(IDictionary<string, object?>)

Captures provider and common defaults. Overrides copy native mutable option values.

protected override void CaptureRequestSettings(IDictionary<string, object?> settings)

Parameters

settings IDictionary<string, object>

CreateFunctionMessageRequest()

Creates HTTP request with function definitions

protected override HttpRequestMessage CreateFunctionMessageRequest()

Returns

HttpRequestMessage

CreateMessageRequest()

Creates the HTTP request message for the AI service

protected override HttpRequestMessage CreateMessageRequest()

Returns

HttpRequestMessage

CreateStreamParseFailure(string, Exception, StreamDiagnostics)

Lets providers turn a malformed SSE data event into an explicit terminal error. Returning null preserves the tolerant behavior used by legacy compatible providers.

protected override StreamingContent? CreateStreamParseFailure(string jsonData, Exception exception, StreamDiagnostics diagnostics)

Parameters

jsonData string
exception Exception
diagnostics StreamDiagnostics

Returns

StreamingContent

ExtractFunctionCalls(string)

Extracts every function call from one API response.

protected override (string content, FunctionCallBatch functionCalls) ExtractFunctionCalls(string response)

Parameters

response string

Returns

(string content, FunctionCallBatch functionCalls)

ExtractResponseContent(string)

Extracts the response content from the API response

protected override string ExtractResponseContent(string responseContent)

Parameters

responseContent string

Returns

string

GetCompletionAsync(Message)

public override Task<string> GetCompletionAsync(Message message)

Parameters

message Message

Returns

Task<string>

GetInputTokenCountAsync()

Gets the token count for the current conversation

public override Task<uint> GetInputTokenCountAsync()

Returns

Task<uint>

GetInputTokenCountAsync(string)

Gets the token count for a specific prompt

public override Task<uint> GetInputTokenCountAsync(string prompt)

Parameters

prompt string

Returns

Task<uint>

GetModelMaxOutputTokens()

Returns the maximum output tokens allowed for the current model. Override in each service to provide model-specific limits.

protected override uint GetModelMaxOutputTokens()

Returns

uint

GetRunRequestedModel()

Resolves the explicit model ID sent for the captured run request.

protected override string GetRunRequestedModel()

Returns

string

Remarks

Override when provider options replace the configured model or translate it to a wire ID. Return null when the request delegates model selection without a single model ID. Called within the captured request settings and provider-feature scope.

ParseStreamChunk(string, StreamOptions)

Parses a single SSE JSON chunk into a provider-neutral stream chunk. Each provider overrides this to handle its specific JSON format.

protected override OpenAICompatibleService.OpenAIStreamChunk ParseStreamChunk(string jsonData, StreamOptions options)

Parameters

jsonData string
options StreamOptions

Returns

OpenAICompatibleService.OpenAIStreamChunk

ResolveRequestCapabilities()

Resolves adapter support using RequestSetting and CurrentRequestFeatures without side effects.

protected override AIModelCapabilities ResolveRequestCapabilities()

Returns

AIModelCapabilities

Remarks

Custom providers may override this hook. The default preserves compatibility by returning Unknown. Overrides must not send requests, consume options, change history or invoke user callbacks.

StreamParseJson(string)

Parses streaming JSON data

protected override string StreamParseJson(string jsonData)

Parameters

jsonData string

Returns

string

UseMaxModel()

public QwenService UseMaxModel()

Returns

QwenService

UsePlusModel()

public QwenService UsePlusModel()

Returns

QwenService

UseQwen3_235BModel()

public QwenService UseQwen3_235BModel()

Returns

QwenService

UseQwen3_32BModel()

public QwenService UseQwen3_32BModel()

Returns

QwenService

UseTurboModel()

public QwenService UseTurboModel()

Returns

QwenService

ValidateStreamTermination(bool, bool, StreamDiagnostics)

Lets providers require an explicit successful terminal event before committing a streamed assistant message or executing a collected function call.

protected override StreamingContent? ValidateStreamTermination(bool doneMarkerReceived, bool completionEventReceived, StreamDiagnostics diagnostics)

Parameters

doneMarkerReceived bool
completionEventReceived bool
diagnostics StreamDiagnostics

Returns

StreamingContent

WithQwenParameters(QwenThinking)

public QwenService WithQwenParameters(QwenThinking thinking = QwenThinking.On)

Parameters

thinking QwenThinking

Returns

QwenService