Skip to content

Commit f864c26

Browse files
v1.0.2
- 用java8编译打包
1 parent 0ca2a2b commit f864c26

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ AI助手jar包,可二次开发复用 (基于langchain4j的java8版本开发)
1616
<dependency>
1717
<groupId>com.github.wangzihaogithub</groupId>
1818
<artifactId>ai-assistant</artifactId>
19-
<version>1.0.1</version>
19+
<version>1.0.2</version>
2020
</dependency>
2121

2222
<!-- Required Dependencies -->

pom.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@
55

66
<groupId>com.github.wangzihaogithub</groupId>
77
<artifactId>ai-assistant</artifactId>
8-
<version>1.0.1</version>
8+
<version>1.0.2</version>
99
<packaging>jar</packaging>
1010

1111
<name>ai-assistant</name>
1212
<description>ai-assistant</description>
1313
<url>https://github.com/wangzihaogithub/ai-assistant.git</url>
1414

15-
<parent>
16-
<groupId>org.sonatype.oss</groupId>
17-
<artifactId>oss-parent</artifactId>
18-
<version>9</version>
19-
</parent>
20-
2115
<properties>
2216
<argLine>-Dfile.encoding=UTF-8</argLine>
2317
<!-- 文件拷贝时的编码 -->
@@ -49,7 +43,7 @@
4943
<connection>scm:git:https://github.com/wangzihaogithub/ai-assistant.git</connection>
5044
<developerConnection>scm:git:[email protected]:wangzihaogithub/ai-assistant.git</developerConnection>
5145
<url>[email protected]:wangzihaogithub/ai-assistant.git</url>
52-
<tag>v1.0.1</tag>
46+
<tag>v1.0.2</tag>
5347
</scm>
5448

5549
<!-- 开发者信息 -->

src/main/java/com/github/aiassistant/platform/AliyunAppsClient.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ public class AliyunAppsClient {
7676
private final String apiKey;
7777
private final String appId;
7878
private final ApiKeyStatus apiKeyStatus;
79-
private Semaphore maxCurrentRequestCount = new Semaphore(2000);
8079
// 将重试请求均匀分担到未来的几秒内
8180
private final SecondIncr retrySecondIncr = new SecondIncr(60);
8281
// 将超时延迟任务合并
8382
private final SecondIncr autoCancelTimeoutScheduledFutureIdIncr = new SecondIncr(300);
83+
private final AtomicLong futureIdIncr = new AtomicLong();
84+
private Semaphore maxCurrentRequestCount = new Semaphore(2000);
8485
// 两分钟超时自动取消(毫秒)
8586
private long autoCancelTimeoutMs = 120_000;
86-
private final AtomicLong futureIdIncr = new AtomicLong();
8787
private boolean close = false;
8888

8989
public AliyunAppsClient(String apiKey, String appId) {
@@ -129,17 +129,18 @@ public void setMaxCurrentRequestCount(int maxCurrentRequestCount) {
129129
this.maxCurrentRequestCount = new Semaphore(maxCurrentRequestCount);
130130
}
131131

132-
public void setAutoCancelTimeoutMs(long autoCancelTimeoutMs) {
133-
this.autoCancelTimeoutMs = autoCancelTimeoutMs;
134-
}
135-
136132
public long getAutoCancelTimeoutMs() {
137133
return autoCancelTimeoutMs;
138134
}
139135

136+
public void setAutoCancelTimeoutMs(long autoCancelTimeoutMs) {
137+
this.autoCancelTimeoutMs = autoCancelTimeoutMs;
138+
}
139+
140140
/**
141141
* 向阿里云发起请求
142142
*
143+
* @param userMessage 用户消息
143144
* @param maxRetryCount 最大重试次数
144145
* @return 大模型返回结果 com.alibaba.dashscope.common.DashScopeResult
145146
*/
@@ -151,6 +152,7 @@ public CompletableFuture<DashScopeResult> request(String userMessage, int maxRet
151152
/**
152153
* 向阿里云发起请求
153154
*
155+
* @param userMessage 用户消息
154156
* @param responseContextConsumer 用户重试逻辑
155157
* @param maxRetryCount 最大重试次数
156158
* @return 大模型返回结果 com.alibaba.dashscope.common.DashScopeResult
@@ -500,9 +502,9 @@ public T get(long timeout, TimeUnit unit) throws InterruptedException, Execution
500502
* 将重试请求均匀分担到每一秒内
501503
*/
502504
private static class SecondIncr {
505+
private final int futureSecond;
503506
private int secondIncr;
504507
private int lastSecond;
505-
private final int futureSecond;
506508

507509
/**
508510
* 分摊到未来的几秒内
@@ -538,11 +540,11 @@ private static class ApiKeyStatus {
538540
final LinkedList<RequestListener> listeners = new LinkedList<>();
539541
// 当前请求未完成的数量
540542
final NavigableSet<TimeOutCancelCompletableFuture<DashScopeResult>> currentRequestCount = new ConcurrentSkipListSet<>(Comparator.comparing(e -> e.timestamp));
543+
private final SecondIncr secondIncr = new SecondIncr(60);
541544
// 平均完成用户完整请求的耗时,一次用户完整请求如果出发限流会包含多次阿里云调用的耗时
542545
volatile long avgRequestMs = 0;
543546
// 平均一次阿里云调用的耗时
544547
volatile long avgOnceRequestMs = 0;
545-
private final SecondIncr secondIncr = new SecondIncr(60);
546548

547549
private ApiKeyStatus(String apiKey) {
548550
this.apiKey = apiKey;

src/main/java/com/github/aiassistant/service/jsonschema/LlmJsonSchemaApiService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public <T> T getSchema(MemoryIdVO memoryIdVO, Class<T> type) throws JsonSchemaCr
237237
* @param memoryIdVO memoryIdVO
238238
* @param type type
239239
* @param useChatMemoryProvider 是否给AI提供多伦对话历史记录
240+
* @param jsonSchemaEnum jsonSchemaEnum
240241
* @param <T> 类型
241242
* @return JsonSchema类型的模型
242243
* @throws JsonSchemaCreateException JsonSchema创建失败

src/main/java/com/github/aiassistant/util/FutureUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public static <T> void accept(CompletableFuture<T> future, CompletableFuture<?>
116116
/**
117117
* 加入到原异步完成之后执行
118118
*
119+
* @param <F> CompletionStage
119120
* @param future 原异步
120121
* @param join 新异步
121122
* @param <T> 数据类型
@@ -147,6 +148,7 @@ public static <T, F extends CompletionStage<T>> CompletableFuture<T> join(F futu
147148
* 将装有异步的MapList的格式转为扁平格式(依次等待结果聚合为等待全部结束)
148149
*
149150
* @param map 装有异步的MapList
151+
* @param <F> CompletionStage
150152
* @param <K> Key数据格式
151153
* @param <V> Value数据格式
152154
* @return 扁平格式(等待全部结束)
@@ -337,6 +339,7 @@ public static <V> CompletableFuture<V> allOf(CompletableFuture<CompletableFuture
337339
* 将装有异步的List的格式转为扁平格式(依次等待结果聚合为等待全部结束)
338340
*
339341
* @param list 装有异步的List
342+
* @param <F> CompletionStage
340343
* @param <V> Value数据格式
341344
* @return 扁平格式(等待全部结束)
342345
*/
@@ -351,6 +354,7 @@ public static <V, F extends CompletionStage<V>> CompletableFuture<List<List<V>>>
351354
/**
352355
* 将装有异步的Map的格式转为扁平格式(依次等待结果聚合为等待全部结束)
353356
*
357+
* @param <F> CompletionStage
354358
* @param map 装有异步的Map
355359
* @param <K> Key数据格式
356360
* @param <V> Value数据格式

0 commit comments

Comments
 (0)