Skip to content

Commit 7c4840b

Browse files
committed
feat: code clean up
1 parent a259145 commit 7c4840b

File tree

8 files changed

+13
-15
lines changed

8 files changed

+13
-15
lines changed

src/Cnblogs.DashScope.AspNetCore/DashScopeClientAspNetCore.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Cnblogs.DashScope.Core;
2-
using Microsoft.Extensions.Options;
32

43
namespace Cnblogs.DashScope.AspNetCore;
54

src/Cnblogs.DashScope.AspNetCore/ServiceCollectionInjector.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static IHttpClientBuilder AddDashScopeClient(this IServiceCollection serv
4040
{
4141
var apiKey = section["apiKey"]
4242
?? throw new InvalidOperationException("There is no apiKey provided in given section");
43-
var baseAddress = section["baseAddress"] ?? DashScopeDefaults.DashScopeHttpApiBaseAddress;
43+
var baseAddress = section["baseAddress"] ?? DashScopeDefaults.HttpApiBaseAddress;
4444
var workspaceId = section["workspaceId"];
4545
services.Configure<DashScopeOptions>(section);
4646
return services.AddDashScopeHttpClient(apiKey, baseAddress, workspaceId);
@@ -84,7 +84,7 @@ public static IHttpClientBuilder AddDashScopeClient(
8484
private static IHttpClientBuilder AddDashScopeHttpClient(
8585
this IServiceCollection services,
8686
string apiKey,
87-
string baseAddress,
87+
string? baseAddress,
8888
string? workspaceId)
8989
{
9090
services.AddSingleton<DashScopeClientWebSocketPool>(sp
@@ -100,7 +100,7 @@ private static IHttpClientBuilder AddDashScopeHttpClient(
100100
h.DefaultRequestHeaders.Add("X-DashScope-WorkSpace", workspaceId);
101101
}
102102

103-
h.BaseAddress = new Uri(baseAddress);
103+
h.BaseAddress = new Uri(baseAddress ?? DashScopeDefaults.HttpApiBaseAddress);
104104
});
105105
}
106106
}

src/Cnblogs.DashScope.Core/DashScopeClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public class DashScopeClient : DashScopeClientCore
2727
public DashScopeClient(
2828
string apiKey,
2929
TimeSpan? timeout = null,
30-
string baseAddress = DashScopeDefaults.DashScopeHttpApiBaseAddress,
31-
string baseWebsocketAddress = DashScopeDefaults.DashScopeWebsocketApiBaseAddress,
30+
string baseAddress = DashScopeDefaults.HttpApiBaseAddress,
31+
string baseWebsocketAddress = DashScopeDefaults.WebsocketApiBaseAddress,
3232
string? workspaceId = null,
3333
int socketPoolSize = 5)
3434
: base(
@@ -75,7 +75,7 @@ private static HttpClient GetConfiguredClient(
7575
{
7676
client = new HttpClient
7777
{
78-
BaseAddress = new Uri(baseAddress ?? DashScopeDefaults.DashScopeHttpApiBaseAddress),
78+
BaseAddress = new Uri(baseAddress ?? DashScopeDefaults.HttpApiBaseAddress),
7979
Timeout = timeout ?? TimeSpan.FromMinutes(2)
8080
};
8181

src/Cnblogs.DashScope.Core/DashScopeClientWebSocketPool.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Concurrent;
2-
using System.Net.WebSockets;
32

43
namespace Cnblogs.DashScope.Core;
54

src/Cnblogs.DashScope.Core/DashScopeClientWebSocketWrapper.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Threading.Channels;
2-
3-
namespace Cnblogs.DashScope.Core;
1+
namespace Cnblogs.DashScope.Core;
42

53
/// <summary>
64
/// Represents a transient wrapper for rented websocket, should be transient.

src/Cnblogs.DashScope.Core/DashScopeOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public class DashScopeOptions
1515
/// <summary>
1616
/// Base address for DashScope HTTP API.
1717
/// </summary>
18-
public string BaseAddress { get; set; } = DashScopeDefaults.DashScopeHttpApiBaseAddress;
18+
public string BaseAddress { get; set; } = DashScopeDefaults.HttpApiBaseAddress;
1919

2020
/// <summary>
2121
/// Base address for DashScope websocket API.
2222
/// </summary>
23-
public string BaseWebsocketAddress { get; set; } = DashScopeDefaults.DashScopeWebsocketApiBaseAddress;
23+
public string BaseWebsocketAddress { get; set; } = DashScopeDefaults.WebsocketApiBaseAddress;
2424

2525
/// <summary>
2626
/// Default workspace Id.

src/Cnblogs.DashScope.Core/DashScopeWebSocketRequestPayload.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
/// <summary>
44
/// Payload for websocket request.
55
/// </summary>
6+
/// <typeparam name="TInput">Type of the input.</typeparam>
7+
/// <typeparam name="TParameter">Type of the parameter.</typeparam>
68
public class DashScopeWebSocketRequestPayload<TInput, TParameter>
79
where TInput : class
810
where TParameter : class

src/Cnblogs.DashScope.Core/Internals/DashScopeDefaults.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public static class DashScopeDefaults
1111
/// <summary>
1212
/// Base address for HTTP API.
1313
/// </summary>
14-
public const string DashScopeHttpApiBaseAddress = "https://dashscope.aliyuncs.com/api/v1/";
14+
public const string HttpApiBaseAddress = "https://dashscope.aliyuncs.com/api/v1/";
1515

1616
/// <summary>
1717
/// Base address for websocket API.
1818
/// </summary>
19-
public const string DashScopeWebsocketApiBaseAddress = "wss://dashscope.aliyuncs.com/api-ws/v1/inference/";
19+
public const string WebsocketApiBaseAddress = "wss://dashscope.aliyuncs.com/api-ws/v1/inference/";
2020

2121
/// <summary>
2222
/// Default json serializer options.

0 commit comments

Comments
 (0)