|
|
@@ -10,7 +10,8 @@ import java.util.Map;
|
|
|
public class OpenAIUtils {
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- System.out.println(makeKimiTitleSafer("历史上真实的王莽,还真不是传说中的那样"));
|
|
|
+ System.out.println(getKimiTitleSafeScore("历史上真实的王莽,还真不是传说中的那样"));
|
|
|
+// System.out.println(makeKimiTitleSafer("历史上真实的王莽,还真不是传说中的那样"));
|
|
|
// System.out.println(kimiMining("在这个充满喜悦和庆祝的日子里,我决定为弟弟的婚礼准备一份特别的礼物——30000元作为结婚礼金。\n" +
|
|
|
// "这笔钱对我和我的家庭来说不算小数目,但在我看来,能为弟弟的新生活贡献一份力量,这份心意远远超过了金钱的价值。\n" +
|
|
|
// "我和丈夫商量过后,都认为这是一个表达我们祝福和支持的好办法。\n" +
|
|
|
@@ -90,7 +91,7 @@ public class OpenAIUtils {
|
|
|
" (11)不符合《即时通信工具公众信息服务发展管理暂行规定》及遵守法律法规、社会主义制度、国家利益、公民合法利益、公共秩序、社会道德风尚和信息真实性等“七条底线”要求的; \n" +
|
|
|
" (12)含有法律、行政法规禁止的其他内容的。\n" +
|
|
|
" 输入的标题是: " + kimiTitle;
|
|
|
- String res = KimiAPI.chat(prompt);
|
|
|
+ String res = DeepSeekAPI.chat(prompt);
|
|
|
if (StringUtils.isNotEmpty(res) && NumberUtils.isParsable(res)) {
|
|
|
return Integer.parseInt(res);
|
|
|
}
|
|
|
@@ -104,13 +105,16 @@ public class OpenAIUtils {
|
|
|
" 直接输出改写后的标题列表。\n" +
|
|
|
" 在改写完成后,再输出一次,在改写的标题前增加和标题情感、语气匹配的特殊符号,如:“\uD83D\uDD34”、“\uD83D\uDE04”、“\uD83D\uDD25”、“\uD83D\uDE28”等等\n" +
|
|
|
" 输出:\n" +
|
|
|
- " 输出结果是Dict, 格式为: \n" +
|
|
|
+ " 输出结果是json, 格式为: \n" +
|
|
|
" {\n" +
|
|
|
" \"title_v1\": 请填写第一次输出的标题,\n" +
|
|
|
" \"title_v2\": 请填写第二次输出的标题\n" +
|
|
|
" }\n" +
|
|
|
" 输入的标题是: " + title;
|
|
|
- String res = KimiAPI.jsonChat(prompt);
|
|
|
+ Map<String, String> responseFormat = new HashMap<>();
|
|
|
+ responseFormat.put("type", "json_object");
|
|
|
+ String res = DeepSeekAPI.chat(prompt, responseFormat);
|
|
|
+// String res = KimiAPI.jsonChat(prompt);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
return jsonObject.getString("title_v2");
|
|
|
}
|
|
|
@@ -123,10 +127,10 @@ public class OpenAIUtils {
|
|
|
" \"content_title\": 一个总结性的标题,该标题应简洁并能够反映文章的主要内容\n" +
|
|
|
" }\n" +
|
|
|
" 你需要处理的文本是:";
|
|
|
-// Map<String, String> responseFormat = new HashMap<>();
|
|
|
-// responseFormat.put("type", "json_object");
|
|
|
-// String content = DeepSeekAPI.chat(textPrompt + text, responseFormat);
|
|
|
- String content = KimiAPI.jsonChat(textPrompt + text);
|
|
|
+ Map<String, String> responseFormat = new HashMap<>();
|
|
|
+ responseFormat.put("type", "json_object");
|
|
|
+ String content = DeepSeekAPI.chat(textPrompt + text, responseFormat);
|
|
|
+// String content = KimiAPI.jsonChat(textPrompt + text);
|
|
|
if (StringUtils.isEmpty(content)) {
|
|
|
return null;
|
|
|
}
|