feat(BaiduGPTManager):优化图片描述功能并添加翻译功能
- 更新图片转文本的提示语,要求更详细的描述 - 添加将英文结果翻译成中文的功能 - 优化翻译提示语,确保准确翻译 - 更新版本号至 QQBot v.1.7.9.1 -调整日志设置的加载顺序
This commit is contained in:
parent
1041dfa909
commit
09305ae824
@ -10,17 +10,15 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class QQBotApplication {
|
||||
public static final String version = "QQBot v.1.7.8";
|
||||
public static final String version = "QQBot v.1.7.9.1";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("version = " + version);
|
||||
SpringApplication.run(QQBotApplication.class, args);
|
||||
NapCatApi.setLog(true);
|
||||
RedisTools.initRedisPoolSub();
|
||||
QQBotManager.getInstance();
|
||||
val log = ConfigTools.load(ConfigTools.CONFIG, ConfigTools.QQ_LOG, Boolean.class);
|
||||
val log = ConfigTools.load(ConfigTools.CONFIG, ConfigTools.QQ_LOG, Boolean.class,true);
|
||||
NapCatApi.setLog(log);
|
||||
//1
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -190,17 +190,11 @@ public class BaiduGPTManager {
|
||||
// 调用图像转文本的API
|
||||
Image2TextResponse response = qianfan.image2Text()
|
||||
.image(base64)
|
||||
.prompt("分析图片,如果图中有文本则加上文本内容")
|
||||
.prompt("请描述这张图片中的主要内容和细节,以及它们之间的关系\n")
|
||||
.execute();
|
||||
|
||||
String translationPrompt = "将以下英文内容严格翻译为简体中文,不要解释、不要添加额外内容,保留专业术语和名称(如Star Wars保持英文):\n" + response.getResult();
|
||||
// 获取API返回的结果
|
||||
String result = response.getResult();
|
||||
|
||||
// 如果结果不是中文,通过sendMessage函数尝试将其翻译成中文
|
||||
result = sendMessage("bot", "你是一个语言翻译专家,如果这段内容不是中文,请翻译成中文,如果已经是中文则不需要翻译:" + result).getContent();
|
||||
|
||||
// 返回最终的中文描述结果
|
||||
return result;
|
||||
return sendMessage("bot",translationPrompt).getContent();
|
||||
} catch (Exception e) {
|
||||
// 异常处理:记录错误日志
|
||||
Log.e(e);
|
||||
|
Loading…
Reference in New Issue
Block a user