zms9110750.DeepSeekClient 0.4.0

Suggested Alternatives

OpenAI

dotnet add package zms9110750.DeepSeekClient --version 0.4.0
                    
NuGet\Install-Package zms9110750.DeepSeekClient -Version 0.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="zms9110750.DeepSeekClient" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="zms9110750.DeepSeekClient" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="zms9110750.DeepSeekClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add zms9110750.DeepSeekClient --version 0.4.0
                    
#r "nuget: zms9110750.DeepSeekClient, 0.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package zms9110750.DeepSeekClient@0.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=zms9110750.DeepSeekClient&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=zms9110750.DeepSeekClient&version=0.4.0
                    
Install as a Cake Tool
//创建一个连接器
DeepSeekApiClient deepSeek = new DeepSeekApiClient("sk-15c0c15987d34");

//工具箱可以添加任何委托作为函数调用
deepSeek.Option.Tools = new ToolKit();
deepSeek.Option.Tools.Add((Func<int, int, int>)Random.Shared.Next);

//设置消息列表
List<Message> messages = new List<Message>();
deepSeek.Option.Messages = messages;
messages.Add(Message.NewUserMsg("测试API,试试调用一个方法。生成一个上亿的数字。"));

//发出请求
var response = await deepSeek.ChatAsync();
//记得把回应添加进消息列表
messages.Add(response.Choices[0].Message);

//调用工具箱
if (response.Choices[0].Message.ToolCalls != null)
{
	foreach (var toolCall in response.Choices[0].Message.ToolCalls!)
	{
		//工具箱调用消息里的API调用请求。
		messages.Add(deepSeek.Option.Tools.Invoke(toolCall));
	}
}

messages.Add(Message.NewUserMsg("可以告诉我得到了多少吗"));


//设置模型
deepSeek.Option.SetModel(ChatModel.R1);


//使用流式请求
var response2 = await deepSeek.ChatStreamAsync();
bool b = false;

//流式请求可以通过异步迭代器获取途中的消息。
await foreach (var item in response2)
{
	//增量消息通过Delta属性获取。
	Console.Write(item.Delta?.ReasoningContent);
	if (!b && string.IsNullOrEmpty(item.Delta?.ReasoningContent))
	{
		b = true;
		Console.WriteLine();
		Console.WriteLine();
	}
	Console.Write(item.Delta?.Content);
}

//也可以直接await获取拼接完的消息
var response3 = await response2;
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();

//ReasoningContent属性获取思维链内容
Console.WriteLine(response3.Choices[0].Message.ReasoningContent);
//Content属性获取普通消息内容
Console.WriteLine(response3.Choices[0].Message.Content);
messages.Add(response3.Choices[0].Message);

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

迁移命名空间。增加通用性。略微增加性能。公开源生成器配置