Ohh.DeepSeek.AI 1.0.0

dotnet add package Ohh.DeepSeek.AI --version 1.0.0
NuGet\Install-Package Ohh.DeepSeek.AI -Version 1.0.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="Ohh.DeepSeek.AI" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ohh.DeepSeek.AI --version 1.0.0
#r "nuget: Ohh.DeepSeek.AI, 1.0.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.
// Install Ohh.DeepSeek.AI as a Cake Addin
#addin nuget:?package=Ohh.DeepSeek.AI&version=1.0.0

// Install Ohh.DeepSeek.AI as a Cake Tool
#tool nuget:?package=Ohh.DeepSeek.AI&version=1.0.0

公众号:办公魔盒

博客:https://bgmh.work

VB.NET 示例代码

''' <summary>
    ''' 按钮
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles button1.Click
        ' moonshot平台KEY
        Dim apiKey As String = "sk-xxxxxxxxxx"
        ' 配置模型
        Dim Model As New DeepSeekChatModel(
            New DeepSeekProvider(
                New DeepSeekConfiguration() With
                    {
                    .ApiKey = apiKey,
                    .Endpoint = "api.deepseek.com",
                    .ChatSettings = New OpenAiChatSettings() With
                        {
                            .UseStreaming = True,
                            .MaxTokens = 2000,
                            .FrequencyPenalty = 2
                        }
                    }
                )
            )
        ' 配置聊天请求体
        Dim ChatRequest As New ChatRequest With
        {
            .Messages = New List(Of Message) From {
                New Message() With {.Role = MessageRole.System, .Content = "你是一个代码助手,打工人助手,Excel公式助手"},
                New Message() With {.Role = MessageRole.Human, .Content = textBox1.Text}
            }
        }
        ' 绑定模型事件
        AddHandler Model.PromptSent, New EventHandler(Of String)(AddressOf Model_PromptSent)
        AddHandler Model.PartialResponseGenerated, New EventHandler(Of String)(AddressOf Model_PartialResponseGenerated)
        AddHandler Model.CompletedResponseGenerated, New EventHandler(Of String)(AddressOf Model_CompletedResponseGenerated)
        ' 生成结果
        Dim result = Await Model.GenerateAsync(ChatRequest, Nothing)
    End Sub


    ''' <summary>
    ''' 模型结果全部输入完毕
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Sub Model_CompletedResponseGenerated(sender, e)
        ''Debug.WriteLine(e)
        Invoke(Sub() If e IsNot Nothing Then richTextBox1.Text = e)
    End Sub

    ''' <summary>
    ''' 模型结果正在输出
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Sub Model_PartialResponseGenerated(sender, e)
        ''Debug.WriteLine(e)
        Invoke(Sub() If e IsNot Nothing Then richTextBox1.AppendText(e.ToString().Replace(vbCrLf, "")))
    End Sub

    ''' <summary>
    ''' 问题发送中
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Sub Model_PromptSent(sender, e)
        ''Debug.WriteLine(e)
    End Sub

C#示例

  /// <summary>
        /// 发送
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void button1_Click(object sender, EventArgs e)
        {
            var apiKey = "sk-xxxxxxxxxxxxxx";
            var model = new DeepSeekChatModel(
            new DeepSeekProvider(
            new DeepSeekConfiguration()
            {
                ApiKey = apiKey,
                Endpoint = "api.deepseek.com",
                ChatSettings = new OpenAiChatSettings()
                {
                    UseStreaming = true,
                    MaxTokens = 2000,
                    FrequencyPenalty = 2
                }
            })
            );

            ChatRequest chatRequest = new()
            {
                Messages = new List<LangChain.Providers.Message> {
                     new() { Role = MessageRole.System, Content = "你是一个代码助手,打工人助手,Excel公式助手" },
                     new() { Role = MessageRole.Human, Content =textBox1.Text }
                 }
            };

            model.PromptSent += Model_PromptSent;
            model.PartialResponseGenerated += Model_PartialResponseGenerated;
            model.CompletedResponseGenerated += Model_CompletedResponseGenerated;


            var result = await model.GenerateAsync(chatRequest);
        }

        /// <summary>
        /// 模型结果全部输入完毕
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Model_CompletedResponseGenerated(object sender, string e)
        {
            // Console.WriteLine(e);
            Invoke(new Action(() => {
                if (e != null)
                {
                    richTextBox1.Text = e;
                }
            }));
        }

        /// <summary>
        /// 模型结果正在输出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Model_PartialResponseGenerated(object sender, string e)
        {
            // Console.WriteLine(e);

            Invoke(new Action(() => {
                if (e != null)
                {
                    richTextBox1.AppendText(e.Replace("\r", ""));
                }
            }));
        }
        /// <summary>
        /// 问题发送中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Model_PromptSent(object sender, string e)
        {
            Console.WriteLine(e);
        }
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 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.

Version Downloads Last updated
1.0.0 41 6/18/2024

修复bug