Class QwenService
public class QwenService : OpenAICompatibleService, IAIService, IFunctionRegisterable
- Inheritance
-
QwenService
- Implements
- Inherited Members
Constructors
QwenService(string, EndpointPlatform, HttpClient)
public QwenService(string baseUrl, EndpointPlatform platform, HttpClient httpClient)
Parameters
baseUrlstringplatformEndpointPlatformhttpClientHttpClient
QwenService(string, EndpointPlatform, string, HttpClient)
public QwenService(string baseUrl, EndpointPlatform platform, string model, HttpClient httpClient)
Parameters
baseUrlstringplatformEndpointPlatformmodelstringhttpClientHttpClient
QwenService(string, HttpClient)
public QwenService(string apiKey, HttpClient httpClient)
Parameters
apiKeystringhttpClientHttpClient
QwenService(string, string, HttpClient)
public QwenService(string apiKey, string model, HttpClient httpClient)
Parameters
apiKeystringmodelstringhttpClientHttpClient
Properties
ModelIdOverride
public string? ModelIdOverride { get; set; }
Property Value
Provider
The AI provider for this service
public override string Provider { get; }
Property Value
ThinkingMode
public QwenThinking ThinkingMode { get; set; }
Property Value
Methods
ApplyProviderSpecificRequestProfile(AIRequestProfile)
protected override Action ApplyProviderSpecificRequestProfile(AIRequestProfile profile)
Parameters
profileAIRequestProfile
Returns
CreateFunctionMessageRequest()
Creates HTTP request with function definitions
protected override HttpRequestMessage CreateFunctionMessageRequest()
Returns
CreateMessageRequest()
Creates the HTTP request message for the AI service
protected override HttpRequestMessage CreateMessageRequest()
Returns
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
jsonDatastringexceptionExceptiondiagnosticsStreamDiagnostics
Returns
ExtractFunctionCalls(string)
Extracts every function call from one API response.
protected override (string content, FunctionCallBatch functionCalls) ExtractFunctionCalls(string response)
Parameters
responsestring
Returns
ExtractResponseContent(string)
Extracts the response content from the API response
protected override string ExtractResponseContent(string responseContent)
Parameters
responseContentstring
Returns
GetCompletionAsync(Message)
public override Task<string> GetCompletionAsync(Message message)
Parameters
messageMessage
Returns
GetInputTokenCountAsync()
Gets the token count for the current conversation
public override Task<uint> GetInputTokenCountAsync()
Returns
GetInputTokenCountAsync(string)
Gets the token count for a specific prompt
public override Task<uint> GetInputTokenCountAsync(string prompt)
Parameters
promptstring
Returns
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
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
jsonDatastringoptionsStreamOptions
Returns
StreamParseJson(string)
Parses streaming JSON data
protected override string StreamParseJson(string jsonData)
Parameters
jsonDatastring
Returns
UseMaxModel()
public QwenService UseMaxModel()
Returns
UsePlusModel()
public QwenService UsePlusModel()
Returns
UseQwen3_235BModel()
public QwenService UseQwen3_235BModel()
Returns
UseQwen3_32BModel()
public QwenService UseQwen3_32BModel()
Returns
UseTurboModel()
public QwenService UseTurboModel()
Returns
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
doneMarkerReceivedboolcompletionEventReceivedbooldiagnosticsStreamDiagnostics
Returns
WithQwenParameters(QwenThinking)
public QwenService WithQwenParameters(QwenThinking thinking = QwenThinking.On)
Parameters
thinkingQwenThinking