Table of Contents

Class QwenService

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

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

ApplyProviderSpecificRequestProfile(AIRequestProfile)

protected override Action ApplyProviderSpecificRequestProfile(AIRequestProfile profile)

Parameters

profile AIRequestProfile

Returns

Action

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

ExtractFunctionCall(string)

Extracts function call from API response

protected override (string content, FunctionCall functionCall) ExtractFunctionCall(string response)

Parameters

response string

Returns

(string content, FunctionCall functionCall)

ExtractResponseContent(string)

Extracts the response content from the API response

protected override string ExtractResponseContent(string responseContent)

Parameters

responseContent string

Returns

string

GenerateImageAsync(string, string)

Generates an image from a text prompt

public override Task<byte[]> GenerateImageAsync(string prompt, string size = "1024x1024")

Parameters

prompt string
size string

Returns

Task<byte[]>

GenerateImageUrlAsync(string, string)

Generates an image URL from a text prompt

public override Task<string> GenerateImageUrlAsync(string prompt, string size = "1024x1024")

Parameters

prompt string
size string

Returns

Task<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

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

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

WithQwenParameters(QwenThinking)

public QwenService WithQwenParameters(QwenThinking thinking = QwenThinking.On)

Parameters

thinking QwenThinking

Returns

QwenService