Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Update ERNIE Bot SDK dependencies #100

Merged
merged 2 commits into from
Feb 19, 2024
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: 0 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.KernelMemory.Abstractions" Version="0.11.231121.2-preview+ea157ef" />
<PackageVersion Include="Microsoft.KernelMemory.Core" Version="0.28.240212.1" />
<PackageVersion Include="Microsoft.SemanticKernel.Abstractions" Version="1.4.0" />
<PackageVersion Include="Microsoft.SemanticKernel.Core" Version="1.4.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.SemanticKernel.Plugins.Core" Version="1.4.0-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.4.0-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.TemplateEngine.Basic" Version="1.0.0-beta8" />
<!-- Validation -->
<PackageVersion Include="Microsoft.VisualStudio.Validation" Version="17.8.8" />
<!-- Tests -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Core" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" />
<PackageReference Include="Microsoft.SemanticKernel.TemplateEngine.Basic" />
<PackageReference Include="Swashbuckle.AspNetCore" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/ERNIE-Bot.SDK/ERNIEBotClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public async Task<string> GetAccessTokenAsync(CancellationToken cancellationToke

var webRequest = new HttpRequestMessage(HttpMethod.Post, url);
var response = await _client.SendAsync(webRequest, cancellationToken);
var accessToken = await ParseResponseAsync<TokenResponse>(response);
var accessToken = await ParseResponseAsync<AccessTokenResponse>(response);

if (string.IsNullOrWhiteSpace(accessToken.AccessToken))
{
Expand Down
12 changes: 11 additions & 1 deletion src/ERNIE-Bot.SDK/ModelEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ public static class ModelEndpoints
/// <summary>
/// <see href="https://cloud.baidu.com/doc/WENXINWORKSHOP/s/clntwmv7t">ERNIE Bot 4 Chat Model</see>
/// </summary>
public static readonly ModelEndpoint ERNIE_Bot_4 = new("completions_pro");
public static readonly ModelEndpoint ERNIE_Bot_4 = new("completions_pro", 5000);

/// <summary>
/// <see href="https://cloud.baidu.com/doc/WENXINWORKSHOP/s/jlil56u11">ERNIE Bot Chat Model</see>
/// </summary>
public static readonly ModelEndpoint ERNIE_Bot = new("completions");

/// <summary>
/// <see href="https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Llsr67q8h"/>
/// </summary>
public static readonly ModelEndpoint ERNIE_Bot_35_4K_0205 = new("ernie-3.5-4k-0205");

/// <summary>
/// <see href="https://cloud.baidu.com/doc/WENXINWORKSHOP/s/llsr6hjxo"/>
/// </summary>
public static readonly ModelEndpoint ERNIE_Bot_35_8K_0205 = new("ernie-3.5-8k-0205");

/// <summary>
/// <see href="https://cloud.baidu.com/doc/WENXINWORKSHOP/s/4lilb2lpf"> ERNIE Bot Turbo Chat Model</see>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace ERNIE_Bot.SDK.Models
/// <summary>
/// Access Token Response
/// </summary>
public class TokenResponse
public class AccessTokenResponse
{
[JsonPropertyName("access_token")]
public string AccessToken { get; set; } = string.Empty;
Expand Down
30 changes: 29 additions & 1 deletion src/ERNIE-Bot.SDK/Models/ChatRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,32 @@ public class ChatCompletionsRequest : ChatRequest
[JsonPropertyName("max_output_tokens")]
public int? MaxTokens { get; set; }

/// <summary>
/// 生成停止标识,当模型生成结果以stop中某个元素结尾时,停止文本生成。
/// <br/> 说明:
/// <br/>(1)每个元素长度不超过20字符
/// <br/>(2)最多4个元素
/// </summary>
[JsonPropertyName("stop")]
public string[]? Stops { get; set; }

/// <summary>
/// 是否强制关闭实时搜索功能,默认false,表示不关闭
/// </summary>
[JsonPropertyName("disable_search")]
public bool? DisableSearch { get; set; }

/// <summary>
/// 是否开启引用返回,说明:
///(1)开启后,有概率触发搜索溯源信息search_info,search_info内容见响应参数介绍
///(2)默认false,不开启
[JsonPropertyName("enable_citation")]
public bool? EnableCitation { get; set; }
}

public class FunctionInfo
{

}

public class Message
Expand All @@ -52,8 +78,10 @@ public class Message

[JsonPropertyName("content")]
public string Content { get; set; } = string.Empty;
}

[JsonPropertyName("name")]
public string? Name { get; set; }
}
public static class MessageRole
{
public const string User = "user";
Expand Down
Loading