AI编码工具-通义灵码功能实测(二)
- 通义灵码智能问答
在上一篇文章中:https://blog.csdn.net/csdn565973850/article/details/138563670?spm=1001.2014.3001.5501 讲述了通义灵码的7大应用场景,这里在使用过程中遇到了一些问题,【说明:以下的问题基于 初版通义灵码插件提出,后来更新的通义灵码插件未进行测试,大家可以自行测试哈。】
通义灵码智能问答
为了测试通义灵码对于阿里云SDK的很好的支持性,这里我输入一段中文 【java 实现钉钉发送消息代码】,根据智能问答返回的代码创建java类后粘贴代码,
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
public class DingTalkClient {
private static final String WEBHOOK_URL = "https://oapi.dingtalk.com/robot/send";
private static final String MESSAGE_TYPE_TEXT = "text";
private static final String MESSAGE_TYPE_IMAGE = "image";
private static final String MESSAGE_TYPE_LINK = "link";
private static final String MESSAGE_TYPE新聞 = "news";
public static void main(String[] args) {
String access_token = "your_access_token";
String text = "your_text_message";
String mediaId = "your_media_id";
String title = "your_title";
String description = "your_description";
sendTextMessage(access_token, text);
sendImageMessage(access_token, mediaId, title);
sendLinkMessage(access_token, text, mediaId, title, description);
sendNewsMessage(access_token, text, mediaId, title, description);
}
private static void sendTextMessage(String access_token, String text) {
StringBuilder payload = new StringBuilder();
payload.append("{\"msgtype\":\"").append(MESSAGE_TYPE_TEXT).append "\",\"text\":{\"content\":\"").append(text).append("\"}}");
try {
HttpURLConnection connection = (HttpURLConnection) new URL(WEBHOOK_URL).openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Authorization", "Bearer " + access_token);
connection.setDoOutput(true);
OutputStream outputStream = connection.getOutputStream();
outputStream.write(payload.toString().getBytes(StandardCharsets.UTF_8));
outputStream.flush();
outputStream.close();
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
} catch (IOException e) {
e.printStackTrace();
}
}
private static void sendImageMessage(String access_token, String mediaId, String title) {
StringBuilder payload = new StringBuilder();
payload.append("{\"msgtype\":\"").append(MESSAGE_TYPE_IMAGE).append "\",\"image\":{\"mediaId\":\"").append(mediaId).append("\",\"title\":\"").append(title).append("\"}}");
try {
HttpURLConnection connection = (HttpURLConnection) new URL(WEBHOOK_URL).openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Authorization", "Bearer " + access_token);
connection.setDoOutput(true);
OutputStream outputStream = connection.getOutputStream();
outputStream.write(payload.toString().getBytes(StandardCharsets.UTF_8));
outputStream.flush();
outputStream.close();
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
} catch (IOException e) {
e.printStackTrace();
}
}
private static void sendLinkMessage(String access_token, String text, String mediaId, String title, String description) {
StringBuilder payload = new StringBuilder();
payload.append("{\"msgtype\":\"").append(MESSAGE_TYPE_LINK).append "\",\"action\":{\"name\":\"").append(title).append("\",\"url\":\"").append(mediaId).append("\",\"text\":\"").append(description).append("\",\"tip\":\"").append("查看详情").append("\"}}");
try {
HttpURLConnection connection = (HttpURLConnection) new URL(WEBHOOK_URL).openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Authorization", "Bearer " + access_token);
connection.setDoOutput(true);
OutputStream outputStream = connection.getOutputStream();
outputStream.write(payload.toString().getBytes(StandardCharsets.UTF_8));
outputStream.flush();
outputStream.close();
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
} catch (IOException e) {
e.printStackTrace();
}
}
private static void sendNewsMessage(String access_token, String text, String mediaId, String title, String description) {
StringBuilder payload = new StringBuilder();
payload.append("{\"msgtype\":\"").append(MESSAGE_TYPE新聞).append "\",\"news\":{\"articles\":[{\"title\":\"").append(title).append "\",\"description\":\"").append(description).append "\",\"url\":\"\",\"picUrl\":\"").append(mediaId).append("\"}]}}");
try {
HttpURLConnection connection = (HttpURLConnection) new URL(WEBHOOK_URL).openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Authorization", "Bearer " + access_token);
connection.setDoOutput(true);
OutputStream outputStream = connection.getOutputStream();
outputStream.write(payload.toString().getBytes(StandardCharsets.UTF_8));
outputStream.flush();
outputStream.close();
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
} catch (IOException e) {
e.printStackTrace();
}
}
}
这里来评价一下这段通义灵码生成的代码,首先个人是不会用这段代码去发消息的。钉钉消息分为工作通知消息和机器人消息,但是生成的代码直接写死了钉钉消息发送路径为机器人消息链接
再看一下具体的发送消息的方法,代码生成的有缺失,部分jar包未自动导入,钉钉发送消息方法不是官方文档推荐的
钉钉开放文档中提供了在线调试页面,可以直观的看到基于SDK的钉钉发送消息操作,以机器人消息为例,代码如下
直观上就比通义灵码智能问答生成的 HttpURLConnection 调用更加直观简单,那自然是不会用智能问答生成的这段代码了。另外又尝试了通义灵码智能问答的【搜索】功能,搜索钉钉发送消息相关内容,加载大概1分钟,感觉加载时间有点偏长,没有直接在浏览器搜索返回速度快。
另外就是对于搜索到的阿里云开发者社区的文章想要点赞收藏,却跳转到了登录页面,正常情况下通义灵码登录账号就是阿里云社区账号,这里是否可以不用登录直接正常操作阿里云社区内容呢?
智能问答有时甚至返回的内容是错误的,比如搜索【达梦 partition by用法】
根据返回的sql语法语句进行尝试
select * from edu_netschool_course where netschool_id=1 group by course_id partition by netschool_id;
在达梦客户端工具执行直接提示语法分析错误
查阅达梦数据库官方文档partition by不是这样用的。然后到智能问答的【搜索】页面同样的问题搜索
这里的匹配结果基本就是按单个字母匹配了,并没有想要的内容,建议这里可以优化一下,对于一些常用的关键字不要拆开成单个字母搜索,这样的搜索完全是没有意义的。当然也有可能是关于达梦的关键字语法训练数据补够导致识别不准确的。