Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Senparc.AI.Agents/Senparc.AI.Agents.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>0.4.0</Version>
<Version>0.5.0</Version>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
<AssemblyName>Senparc.AI.Agents</AssemblyName>
Expand Down
12 changes: 12 additions & 0 deletions src/Senparc.AI.Kernel/Helpers/SemanticKernelHelper.Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ public IKernelBuilder ConfigChat(string userId, string modelName = null, ISenpar
endpoint: senparcAiSetting.OllamaEndpoint,
serviceId: null
),
//DeepSeek 使用和 OpenAI 一致的请求格式
AiPlatform.DeepSeek => kernelBuilder.AddOpenAIChatCompletion(modelName,
endpoint: new Uri(senparcAiSetting.Endpoint),
apiKey: senparcAiSetting.ApiKey,
orgId: senparcAiSetting.OrganizationId,
httpClient: _httpClient),

_ => throw new SenparcAiException($"没有处理当前 {nameof(AiPlatform)} 类型:{aiPlatForm}")
};

Expand Down Expand Up @@ -165,6 +172,11 @@ public IKernelBuilder ConfigTextCompletion(string userId, string modelName = nul
endpoint: senparcAiSetting.OllamaEndpoint,
serviceId: null
),
AiPlatform.DeepSeek => kernelBuilder.AddOpenAIChatCompletion(modelName,
endpoint:new Uri(senparcAiSetting.Endpoint),
apiKey: senparcAiSetting.ApiKey,
orgId: senparcAiSetting.OrganizationId,
httpClient: _httpClient),
_ => throw new SenparcAiException($"没有处理当前 {nameof(AiPlatform)} 类型:{aiPlatForm}")
};

Expand Down
2 changes: 1 addition & 1 deletion src/Senparc.AI.Kernel/Senparc.AI.Kernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>0.21.0</Version>
<Version>0.22.0</Version>
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
<AssemblyName>Senparc.AI.Kernel</AssemblyName>
Expand Down
13 changes: 13 additions & 0 deletions src/Senparc.AI/Entities/Keys/DeepSeekKeys.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
using Senparc.AI.Entities.Keys;

namespace Senparc.AI
{
public class DeepSeekKeys: BaseKeys
{
public string ApiKey { get; set; }
public string Endpoint { get; set; }
}
}
25 changes: 25 additions & 0 deletions src/Senparc.AI/Entities/SenparcAiSettingBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public class SenparcAiSettingBase : ISenparcAiSetting
/// </summary>
public virtual bool Ollama => AiPlatform == AiPlatform.Ollama;

/// <summary>
/// 是否使用 DeepSeek
/// </summary>
public virtual bool UseDeepSeek => AiPlatform == AiPlatform.DeepSeek;

/// <summary>
/// AI 平台类型
/// </summary>
Expand All @@ -87,6 +92,8 @@ public class SenparcAiSettingBase : ISenparcAiSetting
public virtual FastAPIKeys FastAPIKeys { get; set; }
public virtual OllamaKeys OllamaKeys { get; set; }

public virtual DeepSeekKeys DeepSeekKeys { get; set; }

/// <summary>
/// Azure OpenAI 或 OpenAI API Key
/// </summary>
Expand All @@ -98,6 +105,7 @@ public class SenparcAiSettingBase : ISenparcAiSetting
AiPlatform.HuggingFace => "",
AiPlatform.FastAPI => FastAPIKeys.ApiKey,
AiPlatform.Ollama => "",
AiPlatform.DeepSeek => DeepSeekKeys?.ApiKey,
_ => ""
};

Expand Down Expand Up @@ -167,6 +175,11 @@ public class SenparcAiSettingBase : ISenparcAiSetting

#endregion

#region DeepSeek
public string DeepSeekEndpoint => DeepSeekKeys?.Endpoint;

#endregion

public virtual bool IsOpenAiKeysSetted => OpenAIKeys != null && !OpenAIKeys.ApiKey.IsNullOrEmpty();


Expand Down Expand Up @@ -242,6 +255,18 @@ public ISenparcAiSetting SetOllama(OllamaKeys ollamaAPIKeys)
return this;
}

/// <summary>
/// 设置 DeepSeek
/// </summary>
/// <param name="deepSeekKeys"></param>
/// <returns></returns>
public ISenparcAiSetting SetDeepSeek(DeepSeekKeys deepSeekKeys)
{
this.AiPlatform = AiPlatform.DeepSeek;
this.DeepSeekKeys = deepSeekKeys;
return this;
}

/// <summary>
/// 设置其他平台
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/Senparc.AI/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum AiPlatform
//Oobabooga = 64,//未实现
FastAPI = 128,
Ollama = 256,
DeepSeek = 512
}

/// <summary>
Expand Down
12 changes: 11 additions & 1 deletion src/Senparc.AI/Interfaces/ISenparcAiSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public interface ISenparcAiSetting
AiPlatform.HuggingFace => HuggingFaceEndpoint,
AiPlatform.FastAPI => FastAPIEndpoint,
AiPlatform.Ollama => OllamaEndpoint,
AiPlatform.DeepSeek => DeepSeekEndpoint,
_ => throw new SenparcAiException($"未配置 {AiPlatform} 的 Endpoint 输出")
};

Expand All @@ -66,6 +67,7 @@ public interface ISenparcAiSetting
HuggingFaceKeys HuggingFaceKeys { get; set; }
FastAPIKeys FastAPIKeys { get; set; }
OllamaKeys OllamaKeys { get; set; }
DeepSeekKeys DeepSeekKeys { get; set; }

/// <summary>
/// Neuchar OpenAI 或 Azure OpenAI 或 OpenAI API Key
Expand Down Expand Up @@ -136,6 +138,12 @@ public interface ISenparcAiSetting

#endregion

#region DeepSeek

string DeepSeekEndpoint { get; }

#endregion

/// <summary>
/// OpenAIKeys 是否已经设置
/// </summary>
Expand All @@ -150,7 +158,8 @@ public interface ISenparcAiSetting
AiPlatform.HuggingFace => HuggingFaceKeys.ModelName,
AiPlatform.FastAPI => FastAPIKeys.ModelName,
AiPlatform.Ollama => OllamaKeys.ModelName,
_ => throw new SenparcAiException($"100-未配置 {AiPlatform} 的 Endpoint 输出")
AiPlatform.DeepSeek => DeepSeekKeys.ModelName,
_ => throw new SenparcAiException($"未配置 {AiPlatform} 的 ModelName 输出")
};

#pragma warning disable CS8603 // 可能返回 null 引用。
Expand All @@ -162,6 +171,7 @@ public interface ISenparcAiSetting
AiPlatform.HuggingFace => null,
AiPlatform.FastAPI => null,
AiPlatform.Ollama => null,
AiPlatform.DeepSeek => null,
_ => throw new SenparcAiException($"未配置 {AiPlatform} 的 DeploymentName 输出")
};
#pragma warning restore CS8603 // 可能返回 null 引用。
Expand Down
1 change: 0 additions & 1 deletion src/Senparc.AI/Register.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static class Register
/// <returns></returns>
public static IRegisterService UseSenparcAICore(this IRegisterService registerService)
{

return registerService;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Senparc.AI/Senparc.AI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>0.20.0-beta1</Version>
<Version>0.21.0-beta1</Version>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
<AssemblyName>Senparc.AI</AssemblyName>
Expand Down Expand Up @@ -53,6 +53,7 @@
[2024-11-19] v0.18.0 Update CO2NET, reframe for Aspire
[2025-01-19] v0.19.0-beta1 Update Senparc.AI.Agents; Fixed some namespace spelling errors
[2025-01-19] v0.20.0-beta1 Update Senparc.AI.Agents; Fixed some namespace spelling errors
[2025-01-21] v0.21.0-beta1 Support for DeepSeek
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/Senparc/Senparc.AI</RepositoryUrl>
<Configurations>Debug;Release;Test</Configurations>
Expand Down
2 changes: 1 addition & 1 deletion src/Senparc.AI/appsettings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"properties": {
"AiPlatform": {
"type": "string",
"enum": [ "OpenAI", "NeuCharAI", "AzureOpenAI", "HuggingFace","FastAPI","Other" ]
"enum": [ "OpenAI", "NeuCharAI", "AzureOpenAI", "HuggingFace","FastAPI","Ollama","DeepSeek","Other" ]
}
}
}
Expand Down