Commit 1e875b92 authored by alex yao's avatar alex yao

feat:微博热搜插件

parent 67ac952e
...@@ -7,6 +7,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.function.html_reader.HtmlReaderF ...@@ -7,6 +7,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.function.html_reader.HtmlReaderF
import cn.com.poc.thirdparty.resource.demand.ai.function.image_ocr.ImageOCRFunction; import cn.com.poc.thirdparty.resource.demand.ai.function.image_ocr.ImageOCRFunction;
import cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.SetLongMemoryFunction; import cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.SetLongMemoryFunction;
import cn.com.poc.thirdparty.resource.demand.ai.function.memory_variable_writer.MemoryVariableWriterFunction; import cn.com.poc.thirdparty.resource.demand.ai.function.memory_variable_writer.MemoryVariableWriterFunction;
import cn.com.poc.thirdparty.resource.demand.ai.function.top_search.WeiboTopSearchFunction;
import cn.com.poc.thirdparty.resource.demand.ai.function.web_seach.WebSearchFunction; import cn.com.poc.thirdparty.resource.demand.ai.function.web_seach.WebSearchFunction;
public enum LargeModelFunctionEnum { public enum LargeModelFunctionEnum {
...@@ -18,6 +19,7 @@ public enum LargeModelFunctionEnum { ...@@ -18,6 +19,7 @@ public enum LargeModelFunctionEnum {
web_search(WebSearchFunction.class), web_search(WebSearchFunction.class),
image_ocr(ImageOCRFunction.class), image_ocr(ImageOCRFunction.class),
weibo_search_top(WeiboTopSearchFunction.class),
bing_web_search(null), bing_web_search(null),
......
package cn.com.poc.thirdparty.resource.demand.ai.function.top_search;
import cn.com.poc.agent_application.entity.Variable;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction;
import cn.com.poc.thirdparty.resource.demand.ai.function.entity.FunctionLLMConfig;
import cn.com.poc.thirdparty.resource.demand.ai.function.entity.Parameters;
import cn.com.poc.thirdparty.resource.demand.ai.function.entity.Properties;
import cn.com.poc.thirdparty.resource.tianju.api.TianApi;
import cn.com.poc.thirdparty.resource.tianju.api.entity.TianCommonResult;
import cn.com.poc.thirdparty.resource.tianju.api.entity.TianResult;
import cn.com.poc.thirdparty.resource.tianju.api.entity.TianWeiboTopSearch;
import cn.hutool.core.collection.ListUtil;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @author alex.yao
* @date 2025/1/16
*/
@Component
public class WeiboTopSearchFunction extends AbstractLargeModelFunction {
private final String DESC = "该方法获取今天微博的热点信息";
private final FunctionLLMConfig functionLLMConfig = new FunctionLLMConfig.FunctionLLMConfigBuilder()
.name("weibo_search_top")
.description(DESC)
// .parameters(new Parameters("object").addProperties("content", new Properties("string", "内容的详细说明")))
.build();
@Resource
private TianApi tianApi;
@Override
public String doFunction(String content, String identifier) {
TianCommonResult<TianWeiboTopSearch> weiboTopSearch = tianApi.getWeiboTopSearch();
TianResult<TianWeiboTopSearch> result = weiboTopSearch.getResult();
List<TianWeiboTopSearch> list = result.getList();
return JsonUtils.serialize(list);
}
@Override
public String getDesc() {
return DESC;
}
@Override
public List<String> getLLMConfig() {
return ListUtil.toList(JsonUtils.serialize(functionLLMConfig));
}
@Override
public List<String> getLLMConfig(List<Variable> variableStructure) {
return getLLMConfig();
}
}
package cn.com.poc.thirdparty.resource.tianju.api;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.http.LocalHttpClient;
import cn.com.poc.thirdparty.resource.tianju.api.constant.TianNewsChannelEnum;
import cn.com.poc.thirdparty.resource.tianju.api.entity.*;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: Zackery
* @Description: 天聚API
* @Date: 2024/4/16 10:49
*/
@Service
public class TianApi implements TianBaseApi {
private Logger logger = LoggerFactory.getLogger(TianApi.class);
@Resource
private FmxParamConfigService paramConfigService;
/**
* 获取百度热搜榜
*/
public TianCommonResult<TianBaiduTopSearch> getBaiduTopSearch() throws Exception {
String url = null;
try {
String key = paramConfigService.getParam(KEY_SITE);
String encodeKey = URLEncoder.encode(key, StandardCharsets.UTF_8.toString());
url = BAIDU_TOP_SEARCH + "?" + KEY + "=" + encodeKey;
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setUri(url)
.addHeader(urlencodedHeader)
.build();
CloseableHttpResponse httpResponse = LocalHttpClient.execute(httpUriRequest);
String responseStr = EntityUtils.toString(httpResponse.getEntity());
return JSON.parseObject(responseStr, new TypeReference<TianCommonResult<TianBaiduTopSearch>>() {
});
} catch (Exception e) {
logger.info("调用天聚百度热搜榜数据异常,请求路径:{}", url);
throw new BusinessException("采集数据异常,请联系开发人员");
}
}
/**
* 获取头条热搜榜
*/
public TianCommonResult<TianToutiaoTopSearch> getToutiaoTopSearch() throws Exception {
String url = null;
try {
String key = paramConfigService.getParam(KEY_SITE);
String encodeKey = URLEncoder.encode(key, StandardCharsets.UTF_8.toString());
url = TOUTIAO_TOP_SEARCH + "?" + KEY + "=" + encodeKey;
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setUri(url)
.addHeader(urlencodedHeader)
.build();
CloseableHttpResponse httpResponse = LocalHttpClient.execute(httpUriRequest);
String responseStr = EntityUtils.toString(httpResponse.getEntity());
return JSON.parseObject(responseStr, new TypeReference<TianCommonResult<TianToutiaoTopSearch>>() {
});
} catch (Exception e) {
logger.info("调用天聚头条热搜榜数据异常,请求路径:{}", url);
throw new BusinessException("采集数据异常,请联系开发人员");
}
}
/**
* 获取抖音热搜榜
*/
public TianCommonResult<TianDouyinTopSearch> getDouyinTopSearch() throws Exception {
String url = null;
try {
String key = paramConfigService.getParam(KEY_SITE);
String encodeKey = URLEncoder.encode(key, StandardCharsets.UTF_8.toString());
url = DOUYIN_TOP_SEARCH + "?" + KEY + "=" + encodeKey;
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setUri(url)
.addHeader(urlencodedHeader)
.build();
CloseableHttpResponse httpResponse = LocalHttpClient.execute(httpUriRequest);
String responseStr = EntityUtils.toString(httpResponse.getEntity());
return JSON.parseObject(responseStr, new TypeReference<TianCommonResult<TianDouyinTopSearch>>() {
});
} catch (Exception e) {
logger.info("调用天聚抖音热搜榜数据异常,请求路径:{}", url);
throw new BusinessException("采集数据异常,请联系开发人员");
}
}
/**
* 获取微博热搜榜
*/
public TianCommonResult<TianWeiboTopSearch> getWeiboTopSearch() {
String url = null;
try {
String key = paramConfigService.getParam(KEY_SITE);
String encodeKey = URLEncoder.encode(key, StandardCharsets.UTF_8.toString());
url = WEIBO_TOP_SEARCH + "?" + KEY + "=" + encodeKey;
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setUri(url)
.addHeader(urlencodedHeader)
.build();
CloseableHttpResponse httpResponse = LocalHttpClient.execute(httpUriRequest);
String responseStr = EntityUtils.toString(httpResponse.getEntity());
return JSON.parseObject(responseStr, new TypeReference<TianCommonResult<TianWeiboTopSearch>>() {
});
} catch (Exception e) {
logger.info("调用天聚微博热搜榜数据异常,请求路径:{}", url);
throw new BusinessException("采集数据异常,请联系开发人员");
}
}
/**
* 获取全网热搜榜
*/
public TianCommonResult<TianNetworkTopSearch> getNetworkTopSearch() throws Exception {
String url = null;
try {
String key = paramConfigService.getParam(KEY_SITE);
String encodeKey = URLEncoder.encode(key, StandardCharsets.UTF_8.toString());
url = NETWORK_TOP_SEARCH + "?" + KEY + "=" + encodeKey;
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setUri(url)
.addHeader(urlencodedHeader)
.build();
CloseableHttpResponse httpResponse = LocalHttpClient.execute(httpUriRequest);
String responseStr = EntityUtils.toString(httpResponse.getEntity());
return JSON.parseObject(responseStr, new TypeReference<TianCommonResult<TianNetworkTopSearch>>() {
});
} catch (Exception e) {
logger.info("调用天聚全网热搜榜数据异常,请求路径:{}", url);
throw new BusinessException("采集数据异常,请联系开发人员");
}
}
/**
* 获取微信热搜榜
*/
public TianCommonResult<TianWxTopSearch> getWxTopSearch() throws Exception {
String url = null;
try {
String key = paramConfigService.getParam(KEY_SITE);
String encodeKey = URLEncoder.encode(key, StandardCharsets.UTF_8.toString());
url = WX_TOP_SEARCH + "?" + KEY + "=" + encodeKey;
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setUri(url)
.addHeader(urlencodedHeader)
.build();
CloseableHttpResponse httpResponse = LocalHttpClient.execute(httpUriRequest);
String responseStr = EntityUtils.toString(httpResponse.getEntity());
return JSON.parseObject(responseStr, new TypeReference<TianCommonResult<TianWxTopSearch>>() {
});
} catch (Exception e) {
logger.info("调用天聚微信热搜榜数据异常,请求路径:{}", url);
throw new BusinessException("采集数据异常,请联系开发人员");
}
}
/**
* 获取微信精选
*/
public TianResult<TianWxNewSearch> getWxNewSearch(TianWxNewRequest wxNewRequest) throws Exception {
String url = null;
try {
String key = paramConfigService.getParam(KEY_SITE);
String encodeNum = URLEncoder.encode(String.valueOf(wxNewRequest.getNum()), StandardCharsets.UTF_8.toString());
String encodeKey = URLEncoder.encode(key, StandardCharsets.UTF_8.toString());
url = WX_NEW_SEARCH + "?" + KEY + "=" + encodeKey
+ "&" + NUM + "=" + encodeNum;
if (wxNewRequest.getWord() != null) {
String encodeWord = URLEncoder.encode(wxNewRequest.getWord(), StandardCharsets.UTF_8.toString());
url = url + "&" + WORD + "=" + encodeWord;
}
if (wxNewRequest.getPage() != null) {
String encodePage = URLEncoder.encode(String.valueOf(wxNewRequest.getPage()), StandardCharsets.UTF_8.toString());
url = url + "&" + PAGE + "=" + encodePage;
}
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setUri(url)
.addHeader(urlencodedHeader)
.build();
CloseableHttpResponse httpResponse = LocalHttpClient.execute(httpUriRequest);
String responseStr = EntityUtils.toString(httpResponse.getEntity());
TianCommonResult<TianWxNewSearch> tianCommonResult = JSON.parseObject(responseStr, new TypeReference<TianCommonResult<TianWxNewSearch>>() {
});
TianResult<TianWxNewSearch> tianResult = new TianResult<>();
tianResult.setList(tianCommonResult.getResult().getList());
tianResult.setCurpage(tianCommonResult.getResult().getCurpage());
tianResult.setAllnum(tianCommonResult.getResult().getAllnum());
return tianResult;
} catch (Exception e) {
logger.info("调用天聚微信精选数据异常,请求路径:{}", url);
throw new BusinessException("采集数据异常,请联系开发人员");
}
}
/**
* 获取新闻分类
*/
public TianCommonResult<TianNewsSortSearch> getNewsSortSearch(TianNewsSortRequest newsSortRequest) throws Exception {
String url = null;
try {
String key = paramConfigService.getParam(KEY_SITE);
String encodeNum = URLEncoder.encode(String.valueOf(newsSortRequest.getNum()), StandardCharsets.UTF_8.toString());
String encodeCol = URLEncoder.encode(String.valueOf(newsSortRequest.getCol()), StandardCharsets.UTF_8.toString());
String encodeKey = URLEncoder.encode(key, StandardCharsets.UTF_8.toString());
url = ALLNEWS_SEARCH + "?" + KEY + "=" + encodeKey
+ "&" + NUM + "=" + encodeNum
+ "&" + COL + "=" + encodeCol;
if (newsSortRequest.getRand() != null) {
String encodeRand = URLEncoder.encode(String.valueOf(newsSortRequest.getRand()), StandardCharsets.UTF_8.toString());
url = url + "&" + RAND + "=" + encodeRand;
}
if (newsSortRequest.getWord() != null) {
String encodeWord = URLEncoder.encode(newsSortRequest.getWord(), StandardCharsets.UTF_8.toString());
url = url + "&" + WORD + "=" + encodeWord;
}
if (newsSortRequest.getPage() != null) {
String encodePage = URLEncoder.encode(String.valueOf(newsSortRequest.getPage()), StandardCharsets.UTF_8.toString());
url = url + "&" + PAGE + "=" + encodePage;
}
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setUri(url)
.addHeader(urlencodedHeader)
.build();
CloseableHttpResponse httpResponse = LocalHttpClient.execute(httpUriRequest);
String responseStr = EntityUtils.toString(httpResponse.getEntity());
return JSON.parseObject(responseStr, new TypeReference<TianCommonResult<TianNewsSortSearch>>() {
});
} catch (Exception e) {
logger.info("调用天聚新闻分类数据异常,请求路径:{}", url);
throw new BusinessException("采集数据异常,请联系开发人员");
}
}
/**
* 获取新闻频道分类
*/
public TianResult<TianNewsChannel> getNewsSortChannel() throws Exception {
try {
//新闻频道分类数据
TianResult<TianNewsChannel> tianResult = new TianResult<>();
List<TianNewsChannel> channels = new ArrayList<>();
for (TianNewsChannelEnum value : TianNewsChannelEnum.values()) {
if (CommonConstant.YOrN.Y.equals(value.getIsShow())) {
channels.add(new TianNewsChannel(value.getId(), value.getNewType()));
}
}
tianResult.setList(channels);
return tianResult;
} catch (Exception e) {
logger.info("调用天聚新闻频道分类数据异常");
throw new BusinessException("采集数据异常,请联系开发人员");
}
}
/**
* 根据频道ID获取新闻分类数据
*/
public TianResult<TianNewsSortSearch> getNewsSortChannelSearch(TianNewsSortRequest newsSortRequest) throws Exception {
try {
TianResult<TianNewsSortSearch> tianResult = new TianResult<>();
TianCommonResult<TianNewsSortSearch> newsSortSearch = getNewsSortSearch(newsSortRequest);
tianResult.setList(newsSortSearch.getResult().getNewslist());
tianResult.setAllnum(newsSortSearch.getResult().getAllnum());
tianResult.setCurpage(newsSortSearch.getResult().getCurpage());
return tianResult;
} catch (Exception e) {
logger.info("根据ID调用天聚新闻频道数据异常");
throw new BusinessException("采集数据异常,请联系开发人员");
}
}
}
package cn.com.poc.thirdparty.resource.tianju.api;
import org.apache.http.Header;
import org.apache.http.HttpHeaders;
import org.apache.http.entity.ContentType;
import org.apache.http.message.BasicHeader;
/**
* 天聚基础API
*/
public interface TianBaseApi {
/**
* 基础地址
*/
String BASE_API = "https://apis.tianapi.com/";
/**
* 百度热搜榜
*/
String BAIDU_TOP_SEARCH = BASE_API + "nethot/index";
/**
* 头条热搜榜
*/
String TOUTIAO_TOP_SEARCH = BASE_API + "toutiaohot/index";
/**
* 抖音热搜榜
*/
String DOUYIN_TOP_SEARCH = BASE_API + "douyinhot/index";
/**
* 微博热搜榜
*/
String WEIBO_TOP_SEARCH = BASE_API + "weibohot/index";
/**
* 全网热搜榜
*/
String NETWORK_TOP_SEARCH = BASE_API + "networkhot/index";
/**
* 微信热搜榜
*/
String WX_TOP_SEARCH = BASE_API + "wxhottopic/index";
/**
* 今日头条热门新闻
*/
String TOUTIAO_TOP_NEWS_SEARCH = BASE_API + "topnews/index";
/**
* 微信文章精选
*/
String WX_NEW_SEARCH = BASE_API + "wxnew/index";
/**
* 分类新闻
*/
String ALLNEWS_SEARCH = BASE_API + "allnews/index";
/**
* key参数
*/
String KEY = "key";
String KEY_SITE = "tianju.key";
/**
* num参数
*/
String NUM = "num";
/**
* col参数
*/
String COL = "col";
/**
* rand参数
*/
String RAND = "rand";
/**
* word参数
*/
String WORD = "word";
/**
* page参数
*/
String PAGE = "page";
/**
* 通用头信息
*/
Header urlencodedHeader = new BasicHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString());
}
package cn.com.poc.thirdparty.resource.tianju.api.constant;
/**
* 天聚api请求错误状态码枚举
*/
public enum TianApiErrorCodeEnum {
SERVER_ERROR(100,"内部服务器错误"),
API_IS_OFFLINE(110,"当前API已下线"),
API_IS_MAINTENANCE(120,"API暂时维护中"),
API_CALL_OUT_LIMIT(130,"API调用超限"),
API_NOT_HAVE_CALL_PERMISSION(140,"API没有调用权限"),
API_NOT_ENOUGH_AVAILABLE(150,"API可用次数不足"),
ACCOUNT_NOT_SUBSCRIBED_API(160,"账号未申请该API"),
REFERER_REQUEST_LIMITED(170,"Referer请求来源受限"),
IP_REQUEST_LIMITED(180,"IP请求来源受限"),
KEY_NOT_AVAILABLE(190,"当前key不可用"),
KEY_WRONG_OR_EMPTY(230,"key错误或为空"),
KEY_MISSING_PARAMETER(240,"缺少key参数"),
DATA_RETURN_EMPTY(250,"数据返回为空"),
PARAMETER_NOT_BE_EMPTY(260,"参数值不得为空"),
PARAMETER_NOT_MEET_REQUIREMENT(270,"参数值不符合要求"),
MISSING_NECESSARY_PARAMETER(280,"缺少必要的参数"),
EXCEED_INPUT_LIMIT(290,"超过最大输入限制");
private final Integer errorCode;
private final String errorMessage;
TianApiErrorCodeEnum(Integer errorCode , String errorMessage){
this.errorCode = errorCode;
this.errorMessage = errorMessage;
}
public Integer getErrorCode() {
return errorCode;
}
public String getErrorMessage() {
return errorMessage;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.constant;
/**
* @author Leon Liu
* @create 2024/4/19 17:19
*/
public interface TianHotTopConstant {
/**
* 百度
*/
String BAIDU = "Baidu";
/**
* 今日头条
*/
String TOUTIAO = "Toutiao";
/**
* 抖音
*/
String DOUYIN = "Douyin";
/**
* 微博
*/
String WEIBO = "Weibo";
/**
* 微信
*/
String WX = "Wx";
/**
* 全网
*/
String NETWORK = "Network";
/**
* 微信文章精选
*/
String WX_NEW = "WX_NEW";
}
package cn.com.poc.thirdparty.resource.tianju.api.constant;
/**
* 新闻频道分类枚举
*/
public enum TianNewsChannelEnum {
PET_NEWS(46,"宠物","N"),
ELECTRONIC_SPORTS_NEWS(45,"电竞","N"),
FEMALE_NEWS(43,"女性","Y"),
GARBAGE_CLASSIFICATION_NEWS(42,"垃圾分类","N"),
ENVIRONMENTAL_PROTECTION_NEWS(41,"环保","N"),
FILM_TELEVISION_NEWS(40,"影视","Y"),
HANFU_NEWS(38,"汉服","N"),
SCIENCE_EXPLORATION_NEWS(36,"科学探索","Y"),
CARS_NEWS(35,"汽车","Y"),
INTERNET_NEWS(34,"互联网","Y"),
ANIMATION_NEWS(33,"动漫","Y"),
FINANCE_ECONOMICS_NEWS(32,"财经","Y"),
GAME_NEWS(31,"游戏","Y"),
CBA_NEWS(30,"CBA","Y"),
ARTIFICIAL_INTELLIGENCE_NEWS(29,"人工智能","Y"),
MILITARY_AFFAIRS(27,"军事","Y"),
FOOTBALL_NEWS(26,"足球","N"),
START_BUSINESS_NEWS(24,"创业","Y"),
IT_NEWS(22,"IT","Y"),
VR_NEWS(21,"VR","N"),
NBA_NEWS(20,"NBA","N"),
APPLE_NEWS(19,"苹果","N"),
TRAVEL_NEWS(18,"旅游","Y"),
HEALTH_KNOWLEDGE(17,"健康知识","Y"),
SCIENCE_NEWS(13,"科学","N"),
SPORTS_NEWS(12,"体育","Y"),
RECREATION_NEWS(10,"娱乐","Y"),
INTERNATION_NEWS(8,"国际","Y"),
INTERNAL_NEWS(7,"国内","N"),
SOCIETY_NEWS(5,"社会","Y");
private final Integer id;
private final String newType;
private final String isShow;
TianNewsChannelEnum(Integer id, String newType, String isShow) {
this.id = id;
this.newType = newType;
this.isShow = isShow;
}
public Integer getId() {
return id;
}
public String getNewType() {
return newType;
}
public String getIsShow() {
return isShow;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.constant;
/**
* @Author: Leon Liu
* @Description:
* @Date: 2024/4/25 11:39
*/
public interface TianNewsSortConstant {
/**
* 随机获取 true
*/
String RAND_TRUE = "1";
/**
* 随机获取 false
*/
String RAND_FALSE = "0";
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
/**
* @Author: Zackery
* @Description:
* @Date: 2024/4/16 11:14
*/
public class TianBaiduTopSearch implements Serializable {
/**
* 热搜话题
*/
private String keyword;
/**
* 简介描述
*/
private String brief;
/**
* 热搜指数
*/
private String index;
/**
* 发展趋势
*/
private String trend;
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public String getBrief() {
return brief;
}
public void setBrief(String brief) {
this.brief = brief;
}
public String getIndex() {
return index;
}
public void setIndex(String index) {
this.index = index;
}
public String getTrend() {
return trend;
}
public void setTrend(String trend) {
this.trend = trend;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
/**
* @Author: Zackery
* @Description: 天聚百度热搜榜list字段数据
* @Date: 2024/4/16 12:13
*/
public class TianBaiduTopSearchList {
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
/**
* @Author: Zackery
* @Description: 天聚通用响应实体
* @Date: 2024/4/16 11:08
*/
public class TianCommonResult<T> implements Serializable {
/**
* 状态码
*/
private Integer code;
/**
* 错误信息
*/
private String msg;
/**
* 具体数据
*/
private TianResult<T> result;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public TianResult<T> getResult() {
return result;
}
public void setResult(TianResult<T> result) {
this.result = result;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
/**
* @Author: Leon Liu
* @Date: 2024/4/16 16:45
*/
public class TianDouyinTopSearch implements Serializable {
/**
* 热搜榜指数
*/
private Integer hotindex;
/**
* 标签类型,1新,2荐,3热
*/
private Integer label;
/**
* 热点话题
*/
private String word;
public Integer getHotindex() {
return hotindex;
}
public void setHotindex(Integer hotindex) {
this.hotindex = hotindex;
}
public Integer getLabel() {
return label;
}
public void setLabel(Integer label) {
this.label = label;
}
public String getWord() {
return word;
}
public void setWord(String word) {
this.word = word;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
/**
* @Author: Leon Liu
* @Description: 天聚抖音热搜榜list字段数据
* @Date: 2024/4/16 16:50
*/
public class TianDouyinTopSearchList {
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
/**
* @Author: Leon Liu
* @Date: 2024/4/16 17:20
*/
public class TianNetworkTopSearch implements Serializable {
/**
* 热搜榜指数
*/
private String title;
/**
* 热搜话题
*/
private Integer hotnum;
/**
* 话题简介(可能为空)
*/
private String digest;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getHotnum() {
return hotnum;
}
public void setHotnum(Integer hotnum) {
this.hotnum = hotnum;
}
public String getDigest() {
return digest;
}
public void setDigest(String digest) {
this.digest = digest;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
/**
* @Author: Leon Liu
* @Description: 天聚全网热搜榜list字段数据
* @Date: 2024/4/16 17:25
*/
public class TianNetworkTopSearchList {
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
/**
* @Author: Leon Liu
* @Description:
* @Date: 2024/4/18 14:22
*/
public class TianNewsChannel {
/**
* 新闻频道ID
*/
private Integer id;
/**
* 新闻类型
*/
private String newsType;
public TianNewsChannel(Integer id, String newsType) {
this.id = id;
this.newsType = newsType;
}
public TianNewsChannel() {
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNewsType() {
return newsType;
}
public void setNewsType(String newsType) {
this.newsType = newsType;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
/**
* @Author: Leon Liu
* @Date: 2024/4/17 15:54
*/
public class TianNewsSortRequest implements Serializable {
/**
* 返回数量1-50 (必需)
*/
private Integer num;
/**
* 新闻频道对应的ID (必需)
*/
private Integer col;
/**
* 翻页
*/
private Integer page;
/**
* 随机获取
*/
private Integer rand;
/**
* 检索关键词
*/
private String word;
public TianNewsSortRequest(Integer num, Integer col, Integer page, Integer rand, String word) {
this.num = num;
this.col = col;
this.page = page;
this.rand = rand;
this.word = word;
}
public TianNewsSortRequest() {
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
public Integer getCol() {
return col;
}
public void setCol(Integer col) {
this.col = col;
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public Integer getRand() {
return rand;
}
public void setRand(Integer rand) {
this.rand = rand;
}
public String getWord() {
return word;
}
public void setWord(String word) {
this.word = word;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
/**
* @Author: Leon Liu
* @Date: 2024/4/17 15:44
*/
public class TianNewsSortSearch implements Serializable {
/**
* 新闻唯一ID
*/
private String id;
/**
* 发布时间
*/
private String ctime;
/**
* 文章标题
*/
private String title;
/**
* 文章描述
*/
private String description;
/**
* 文章来源
*/
private String source;
/**
* 封面图片
*/
private String picUrl;
/**
* 文章地址
*/
private String url;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCtime() {
return ctime;
}
public void setCtime(String ctime) {
this.ctime = ctime;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
/**
* @Author: Leon Liu
* @Description: 天聚分类新闻list字段数据
* @Date: 2024/4/17 15:49
*/
public class TianNewsSortSearchList {
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
import java.util.List;
/**
* @Author: Zackery
* @Description: 天聚热搜榜公用响应result字段
* @Date: 2024/4/16 12:17
*/
public class TianResult<T> implements Serializable {
/**
* 数据列表
*/
private List<T> list;
/**
* 新闻分类数据列表
*/
private List<T> newslist;
/**
* 当前页数
*/
private Integer curpage;
/**
* 数据个数
*/
private Integer allnum;
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public List<T> getNewslist() {
return newslist;
}
public void setNewslist(List<T> newslist) {
this.newslist = newslist;
}
public Integer getCurpage() {
return curpage;
}
public void setCurpage(Integer curpage) {
this.curpage = curpage;
}
public Integer getAllnum() {
return allnum;
}
public void setAllnum(Integer allnum) {
this.allnum = allnum;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
/**
* @Author: Leon Liu
* @Date: 2024/4/16 15:18
*/
public class TianToutiaoTopSearch implements Serializable {
/**
* 热搜榜指数
*/
private Integer hotindex;
/**
* 热点话题
*/
private String word;
public Integer getHotindex() {
return hotindex;
}
public void setHotindex(Integer hotindex) {
this.hotindex = hotindex;
}
public String getWord() {
return word;
}
public void setWord(String word) {
this.word = word;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
/**
* @Author: Leon Liu
* @Description: 天聚头条热搜榜list字段数据
* @Date: 2024/4/16 15:27
*/
public class TianToutiaoTopSearchList {
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
/**
* @Author: Leon Liu
* @Date: 2024/4/16 17:07
*/
public class TianWeiboTopSearch implements Serializable {
/**
* 热搜话题
*/
private String hotword;
/**
* 热搜指数
*/
private String hotwordnum;
/**
* 热搜标签
*/
private String hottag;
public String getHotword() {
return hotword;
}
public void setHotword(String hotword) {
this.hotword = hotword;
}
public String getHotwordnum() {
return hotwordnum;
}
public void setHotwordnum(String hotwordnum) {
this.hotwordnum = hotwordnum;
}
public String getHottag() {
return hottag;
}
public void setHottag(String hottag) {
this.hottag = hottag;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
/**
* @Author: Leon Liu
* @Description: 天聚微博热搜榜list字段数据
* @Date: 2024/4/16 17:13
*/
public class TianWeiboTopSearchList {
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
/**
* @Author: Leon Liu
* @Date: 2024/4/17 10:50
*/
public class TianWxNewRequest implements Serializable {
/**
* 返回数量(必需)
*/
private Integer num;
/**
* 翻页
*/
private Integer page;
/**
* 检索关键词
*/
private String word;
public TianWxNewRequest(Integer num, Integer page, String word) {
this.num = num;
this.page = page;
this.word = word;
}
public TianWxNewRequest() {
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public String getWord() {
return word;
}
public void setWord(String word) {
this.word = word;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
import java.util.Date;
/**
* @Author: Leon Liu
* @Date: 2024/4/16 17:35
*/
public class TianWxNewSearch implements Serializable {
/**
* 文章唯一ID
*/
private String id;
/**
* 发布时间
*/
private Date ctime;
/**
* 文章标题
*/
private String title;
/**
* 文章描述
*/
private String description;
/**
* 文章封面
*/
private String picurl;
/**
* 文章地址
*/
private String url;
/**
* 公众号名称
*/
private String username;
/**
* 公众号ID
*/
private String wxnum;
/**
* 文章分类
*/
private String type;
/**
* 文章作者
*/
private String author;
public String getId() {
return id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public void setId(String id) {
this.id = id;
}
public Date getCtime() {
return ctime;
}
public void setCtime(Date ctime) {
this.ctime = ctime;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPicurl() {
return picurl;
}
public void setPicurl(String picurl) {
this.picurl = picurl;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getWxnum() {
return wxnum;
}
public void setWxnum(String wxnum) {
this.wxnum = wxnum;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
/**
* @Author: Leon Liu
* @Description: 天聚微信精选list字段数据
* @Date: 2024/4/16 18:07
*/
public class TianWxNewSearchList {
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
import java.io.Serializable;
/**
* @Author: Leon Liu
* @Date: 2024/4/16 17:47
*/
public class TianWxTopSearch implements Serializable {
/**
* 话题内容
*/
private String word;
/**
* 热搜榜指数
*/
private Integer index;
public String getWord() {
return word;
}
public void setWord(String word) {
this.word = word;
}
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
/**
* @Author: Leon Liu
* @Description: 天聚微信热搜榜list字段数据
* @Date: 2024/4/16 17:52
*/
public class TianWxTopSearchList {
}
package cn.com.poc.thirdparty.resource.tianju.api.entity;
public class Usage {
private String completion_tokens;
private String prompt_tokens;
private String total_tokens;
public String getCompletion_tokens() {
return completion_tokens;
}
public void setCompletion_tokens(String completion_tokens) {
this.completion_tokens = completion_tokens;
}
public String getPrompt_tokens() {
return prompt_tokens;
}
public void setPrompt_tokens(String prompt_tokens) {
this.prompt_tokens = prompt_tokens;
}
public String getTotal_tokens() {
return total_tokens;
}
public void setTotal_tokens(String total_tokens) {
this.total_tokens = total_tokens;
}
}
package cn.com.poc.thirdparty.resource.demand.ai.function; package cn.com.poc.thirdparty.resource.demand.ai.function;
import cn.com.poc.thirdparty.resource.demand.ai.function.html_reader.HtmlReaderFunction;
import cn.com.poc.thirdparty.resource.demand.ai.function.image_ocr.ImageOCRFunction; import cn.com.poc.thirdparty.resource.demand.ai.function.image_ocr.ImageOCRFunction;
import cn.com.poc.thirdparty.resource.demand.ai.function.top_search.WeiboTopSearchFunction;
import cn.com.yict.framemax.core.spring.SingleContextInitializer; import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.Test; import org.junit.Test;
...@@ -27,4 +29,20 @@ public class ImageOCRFunctionTest { ...@@ -27,4 +29,20 @@ public class ImageOCRFunctionTest {
String content = "{\"query\":\"图片有什么?\",\"image_url\":\"https://ark-project.tos-cn-beijing.volces.com/images/view.jpeg\"}"; String content = "{\"query\":\"图片有什么?\",\"image_url\":\"https://ark-project.tos-cn-beijing.volces.com/images/view.jpeg\"}";
System.out.println(imageOCRFunction.doFunction(content, "test")); System.out.println(imageOCRFunction.doFunction(content, "test"));
} }
HtmlReaderFunction htmlReaderFunction = new HtmlReaderFunction();
@Test
public void testHtmlReader() {
String content = "{\"url\":\"https://top.baidu.com/board?tab=realtime\"}";
System.out.println(htmlReaderFunction.doFunction(content, "test"));
}
@Resource
WeiboTopSearchFunction weiboTopSearchFunction;
@Test
public void weibo() {
System.out.println(weiboTopSearchFunction.getLLMConfig());
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment