Commit 89db7883e337c975b53356a6475553a912012683

Authored by cherishsince
1 parent 0535c294

【解决todo】驼峰命名、优化字段注释

yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/yiyan/YiYanChatClient.java
... ... @@ -119,8 +119,8 @@ public class YiYanChatClient implements ChatClient, StreamingChatClient {
119 119 // 复制 YiYanOptions 属性,到 request 中(这里 options 属性和 request 基本保持一致)
120 120 YiYanChatOptions useOptions = getYiYanOptions(prompt);
121 121 BeanUtil.copyProperties(useOptions, request);
122   - request.setTop_p(useOptions.getTopP())
123   - .setMax_output_tokens(useOptions.getMaxOutputTokens())
  122 + request.setTopP(useOptions.getTopP())
  123 + .setMaxOutputTokens(useOptions.getMaxOutputTokens())
124 124 .setTemperature(useOptions.getTemperature())
125 125 .setSystem(systemPrompt)
126 126 .setStream(stream);
... ...
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/yiyan/api/YiYanApi.java
1 1 package cn.iocoder.yudao.framework.ai.core.model.yiyan.api;
2 2  
3 3 import cn.iocoder.yudao.framework.ai.core.model.yiyan.exception.YiYanApiException;
  4 +import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
4 5 import org.springframework.http.HttpStatusCode;
5 6 import org.springframework.http.ResponseEntity;
6 7 import org.springframework.web.reactive.function.client.WebClient;
... ... @@ -85,7 +86,7 @@ public class YiYanApi {
85 86 -> uriBuilder.path(useChatModel.getUri())
86 87 .queryParam("access_token", token)
87 88 .build())
88   - .body(Mono.just(request), YiYanChatCompletionRequest.class)
  89 + .body(Mono.just(JsonUtils.toJsonString(request)), String.class)
89 90 .retrieve()
90 91 .toEntity(YiYanChatCompletionResponse.class)
91 92 .block();
... ...
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/yiyan/api/YiYanChatCompletionRequest.java
1 1 package cn.iocoder.yudao.framework.ai.core.model.yiyan.api;
2 2  
  3 +import com.fasterxml.jackson.annotation.JsonProperty;
3 4 import lombok.Data;
4 5  
5 6 import java.util.List;
6 7  
7   -// TODO @fan:字段驼峰;字段注释都可以删除,贴个链接就好;
8 8 /**
9 9 * 文心一言 Completion Request
10 10 *
... ... @@ -20,96 +20,70 @@ public class YiYanChatCompletionRequest {
20 20 }
21 21  
22 22 /**
23   - * 聊天上下文信息。
24   - * 必填:是
  23 + * 聊天上下文信息
25 24 */
26 25 private List<Message> messages;
27 26 /**
28   - * 一个可触发函数的描述列表,说明:
29   - * (1)支持的function数量无限制
30   - * (2)长度限制,最后一个message的content长度(即此轮对话的问题)、functions和system字段总内容不能超过20480 个字符,且不能超过5120 tokens
31   - * 必填:否
  27 + * functions 函数
32 28 */
33 29 private List<Function> functions;
34 30 /**
35   - * 说明:
36   - * (1)较高的数值会使输出更加随机,而较低的数值会使其更加集中和确定
37   - * (2)默认0.8,范围 (0, 1.0],不能为0
38   - * 必填:否
  31 + * temperature
39 32 */
40 33 private Float temperature;
41 34 /**
42   - * 说明:
43   - * (1)影响输出文本的多样性,取值越大,生成文本的多样性越强
44   - * (2)默认0.8,取值范围 [0, 1.0]
45   - * 必填:否
  35 + * topP
46 36 */
47   - private Float top_p;
  37 + @JsonProperty("top_p")
  38 + private Float topP;
48 39 /**
49   - * 通过对已生成的token增加惩罚,减少重复生成的现象。说明:
50   - * (1)值越大表示惩罚越大
51   - * (2)默认1.0,取值范围:[1.0, 2.0]
52   - *
53   - * 必填:否
  40 + * 通过对已生成的token增加惩罚,减少重复生成的现象
54 41 */
55   - private Float penalty_score;
  42 + @JsonProperty("penalty_score")
  43 + private Float penaltyScore;
56 44 /**
57   - * 是否以流式接口的形式返回数据,默认false
58   - * 必填:否
  45 + * stream 模式
59 46 */
60 47 private Boolean stream;
61 48 /**
62   - * 模型人设,主要用于人设设定,例如,你是xxx公司制作的AI助手,说明:
63   - * (1)长度限制,最后一个message的content长度(即此轮对话的问题)、functions和system字段总内容不能超过20480 个字符,且不能超过5120 tokens
64   - * (2)如果同时使用system和functions,可能暂无法保证使用效果,持续进行优化
65   - * 必填:否
  49 + * system 预设角色
66 50 */
67 51 private String system;
68 52 /**
69   - * 生成停止标识,当模型生成结果以stop中某个元素结尾时,停止文本生成。说明:
70   - * (1)每个元素长度不超过20字符
71   - * (2)最多4个元素
72   - * 必填:否
  53 + * 生成停止标识,当模型生成结果以stop中某个元素结尾时,停止文本生成
73 54 */
74 55 private List<String> stop;
75 56 /**
76   - * 是否强制关闭实时搜索功能,默认false,表示不关闭
77   - * 必填:否
  57 + * 是否强制关闭实时搜索功能
78 58 */
79   - private Boolean disable_search;
  59 + @JsonProperty("disable_search")
  60 + private Boolean disableSearch;
80 61 /**
81   - * 是否开启上角标返回,说明:
82   - * (1)开启后,有概率触发搜索溯源信息search_info,search_info内容见响应参数介绍
83   - * (2)默认false,不开启
84   - * 必填:否
  62 + * 是否开启上角标返回
85 63 */
86   - private Boolean enable_citation;
  64 + @JsonProperty("enable_citation")
  65 + private Boolean enableCitation;
87 66 /**
88   - * 指定模型最大输出token数,范围[2, 2048]
89   - * 必填:否
  67 + * 最大输出 token 数
90 68 */
91   - private Integer max_output_tokens;
  69 + @JsonProperty("max_output_tokens")
  70 + private Integer maxOutputTokens;
92 71 /**
93   - * 指定响应内容的格式,说明:
94   - * (1)可选值:
95   - * · json_object:以json格式返回,可能出现不满足效果情况
96   - * · text:以文本格式返回
97   - * (2)如果不填写参数response_format值,默认为text
98   - * 必填:否
  72 + * 返回格式 text、json_object
99 73 */
100   - private String response_format;
  74 + @JsonProperty("response_format")
  75 + private String responseFormat;
101 76 /**
102   - * 表示最终用户的唯一标识符
103   - * 必填:否
  77 + * 用户 id
104 78 */
105   - private String user_id;
  79 + @JsonProperty("user_id")
  80 + private String userId;
106 81 /**
107 82 * 在函数调用场景下,提示大模型选择指定的函数(非强制),说明:指定的函数名必须在functions中存在
108   - * 必填:否
109   - *
110   - * ERNIE-4.0-8K 模型没有这个字段
  83 + * tip: ERNIE-4.0-8K 模型没有这个字段
111 84 */
112   - private String tool_choice;
  85 + @JsonProperty("tool_choice")
  86 + private String toolChoice;
113 87  
114 88  
115 89 @Data
... ...