Skip to content

Commit 12705bb

Browse files
committed
refactor: chatCompletionWithSession 参数顺序统一为 (request, sessionKey)
与 Hermes/OpenClaw 对齐:请求体在前,sessionKey 在后。
1 parent 77074d3 commit 12705bb

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/main/java/io/github/hiwepy/opencode/OpenCodeClient.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,33 +121,33 @@ public PromptResult chatCompletion(String sessionId, String text, String provide
121121
* {@code ensureSession} 保证 session 存在(不存在则创建)。
122122
* 建议用 {@link io.github.hiwepy.opencode.api.OpenCodeSessionKeys} 生成 sessionKey。</p>
123123
*
124-
* @param sessionKey 会话复用 key
125124
* @param request prompt 请求
125+
* @param sessionKey 会话复用 key
126126
* @return AI 响应
127127
*/
128-
public PromptResult chatCompletionWithSession(String sessionKey, PromptRequest request) {
129-
return httpClient.chatCompletionWithSession(sessionKey, request);
128+
public PromptResult chatCompletionWithSession(PromptRequest request, String sessionKey) {
129+
return httpClient.chatCompletionWithSession(request, sessionKey);
130130
}
131131

132132
/**
133133
* 按 sessionKey 发送纯文本消息并同步等待 AI 响应。
134134
*/
135-
public PromptResult chatCompletionWithSession(String sessionKey, String text) {
136-
return httpClient.chatCompletionWithSession(sessionKey, PromptRequest.ofText(text));
135+
public PromptResult chatCompletionWithSession(String text, String sessionKey) {
136+
return httpClient.chatCompletionWithSession(PromptRequest.ofText(text), sessionKey);
137137
}
138138

139139
/**
140140
* 按 sessionKey 发送纯文本消息并指定模型。
141141
*/
142-
public PromptResult chatCompletionWithSession(String sessionKey, String text, String providerID, String modelID) {
143-
return httpClient.chatCompletionWithSession(sessionKey, PromptRequest.ofText(text, providerID, modelID));
142+
public PromptResult chatCompletionWithSession(String text, String providerID, String modelID, String sessionKey) {
143+
return httpClient.chatCompletionWithSession(PromptRequest.ofText(text, providerID, modelID), sessionKey);
144144
}
145145

146146
/**
147147
* 按 sessionKey 异步发送消息,不等待响应。
148148
*/
149-
public boolean chatCompletionWithSessionAsync(String sessionKey, PromptRequest request) {
150-
return httpClient.chatCompletionWithSessionAsync(sessionKey, request);
149+
public boolean chatCompletionWithSessionAsync(PromptRequest request, String sessionKey) {
150+
return httpClient.chatCompletionWithSessionAsync(request, sessionKey);
151151
}
152152

153153
/**

src/main/java/io/github/hiwepy/opencode/http/OpenCodeHttpClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,19 @@ public PromptResult prompt(String sessionId, PromptRequest request) {
126126
* <p>sessionKey 作为 session 的 title,{@code ensureSession} 保证 session 存在(不存在则创建),
127127
* 对调用方透明。对齐 Hermes/OpenClaw 的 sessionKey 模式。</p>
128128
*
129-
* @param sessionKey 会话复用 key(建议用 {@code OpenCodeSessionKeys} 生成)
130129
* @param request prompt 请求
130+
* @param sessionKey 会话复用 key(建议用 {@code OpenCodeSessionKeys} 生成)
131131
* @return AI 响应
132132
*/
133-
public PromptResult chatCompletionWithSession(String sessionKey, PromptRequest request) {
133+
public PromptResult chatCompletionWithSession(PromptRequest request, String sessionKey) {
134134
String sessionId = ensureSession(sessionKey);
135135
return prompt(sessionId, request);
136136
}
137137

138138
/**
139139
* 按 sessionKey 异步发送消息,不等待响应。
140140
*/
141-
public boolean chatCompletionWithSessionAsync(String sessionKey, PromptRequest request) {
141+
public boolean chatCompletionWithSessionAsync(PromptRequest request, String sessionKey) {
142142
String sessionId = ensureSession(sessionKey);
143143
return promptAsync(sessionId, request);
144144
}

0 commit comments

Comments
 (0)