Table of Contents

Class DeepSeekService

Namespace
Mythosia.AI.Services.DeepSeek
Assembly
Mythosia.AI.dll
public class DeepSeekService : AIService, IAIService, IFunctionRegisterable
Inheritance
DeepSeekService
Implements
Inherited Members
Extension Methods

Constructors

DeepSeekService(string, HttpClient)

public DeepSeekService(string apiKey, HttpClient httpClient)

Parameters

apiKey string
httpClient HttpClient

DeepSeekService(string, string, HttpClient)

Creates a DeepSeekService with a specific model.

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

Parameters

apiKey string
model string
httpClient HttpClient

Properties

Provider

The AI provider for this service

public override string Provider { get; }

Property Value

string

Methods

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)

DeepSeek doesn't support image generation

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

Parameters

prompt string
size string

Returns

Task<byte[]>

GenerateImageUrlAsync(string, string)

DeepSeek doesn't support image generation

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>

GetCompletionWithCoTAsync(string)

Gets completion with Chain of Thought prompting

public Task<string> GetCompletionWithCoTAsync(string prompt)

Parameters

prompt string

Returns

Task<string>

GetCompletionWithImageAsync(string, string)

DeepSeek doesn't currently support image inputs

public override Task<string> GetCompletionWithImageAsync(string prompt, string imagePath)

Parameters

prompt string
imagePath string

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

StreamCompletionAsync(Message, Func<string, Task>)

public override Task StreamCompletionAsync(Message message, Func<string, Task> messageReceivedAsync)

Parameters

message Message
messageReceivedAsync Func<string, Task>

Returns

Task

StreamCoreAsync(Message, StreamOptions, CancellationToken)

Core streaming loop. Override this method to replace the full streaming pipeline (round loop, StatelessMode, summary policy). Most providers should override StreamRoundAsync(StreamOptions, bool, FunctionCallingPolicy, CancellationToken) instead.

protected override IAsyncEnumerable<StreamingContent> StreamCoreAsync(Message message, StreamOptions options, CancellationToken cancellationToken = default)

Parameters

message Message
options StreamOptions
cancellationToken CancellationToken

Returns

IAsyncEnumerable<StreamingContent>

StreamParseJson(string)

Parses streaming JSON data

protected override string StreamParseJson(string jsonData)

Parameters

jsonData string

Returns

string

UseReasonerModel()

Switches to DeepSeek Reasoner model for complex reasoning tasks

public DeepSeekService UseReasonerModel()

Returns

DeepSeekService

WithCodeGenerationMode(string)

Sets DeepSeek-specific parameters for code generation

public DeepSeekService WithCodeGenerationMode(string language = "python")

Parameters

language string

Returns

DeepSeekService

WithMathMode()

Optimizes settings for mathematical reasoning

public DeepSeekService WithMathMode()

Returns

DeepSeekService