Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
61 lines (54 loc) · 1.88 KB

File metadata and controls

61 lines (54 loc) · 1.88 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) Alibaba, Inc. and its affiliates.
import static com.alibaba.dashscope.utils.ApiKeywords.HISTORY;
import static com.alibaba.dashscope.utils.ApiKeywords.PROMPT;
import com.alibaba.dashscope.base.HalfDuplexServiceParam;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.utils.ApiKeywords;
import com.alibaba.dashscope.utils.JsonUtils;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
@EqualsAndHashCode(callSuper = true)
@Data
@SuperBuilder
public class ChatGLMParam extends HalfDuplexServiceParam {
/** The input prompt. */
private String prompt;
/** { "user":"今天天气好吗?", "bot":"今天天气不错,要出去玩玩嘛?" }, */
private List<List<String>> history;
@Override
public JsonObject getInput() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(PROMPT, getPrompt());
JsonArray ar = JsonUtils.toJsonElement(history).getAsJsonArray();
jsonObject.add(HISTORY, ar);
return jsonObject;
}
/**
* Get the websocket binary data, only for websocket binary input data.
*
* @return Generation param has no binary data.
*/
@Override
public ByteBuffer getBinaryData() {
return null;
}
@Override
public JsonObject getHttpBody() {
JsonObject requestObject = new JsonObject();
requestObject.addProperty(ApiKeywords.MODEL, getModel());
requestObject.add(ApiKeywords.INPUT, getInput());
Map<String, Object> params = getParameters();
if (params != null && !params.isEmpty()) {
requestObject.add(ApiKeywords.PARAMETERS, JsonUtils.parametersToJsonObject(params));
}
return requestObject;
}
@Override
public void validate() throws InputRequiredException {}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.