网站优化成都哪里好,基本网站建设技术,wordpress重新定向,甲级建筑设计公司第一步#xff1a;注册并登录百度智能云#xff0c;创建应用并获取自己的APIKey与SecretKey#xff0c;参考网址#xff1a;
点击去百度智能云
第二步#xff1a;引入千帆的pom依赖 dependencygroupIdcom.baidubce/groupIdartifactIdq…第一步注册并登录百度智能云创建应用并获取自己的APIKey与SecretKey参考网址
点击去百度智能云
第二步引入千帆的pom依赖 dependencygroupIdcom.baidubce/groupIdartifactIdqianfan/artifactIdversion0.0.9/version/dependency第三步创建前端需要的controller
import com.baidubce.qianfan.core.auth.Auth;
import com.lx.vue.common.resp.ResultData;
import com.lx.vue.common.resp.ReturnCodeEnum;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;import com.baidubce.qianfan.Qianfan;
import com.baidubce.qianfan.core.builder.ChatBuilder;
import com.baidubce.qianfan.model.chat.ChatResponse;RestController
public class QianFanController {private static final String APIKey 你的APIKey;private static final String SecretKey 你的SecretKey;private static Qianfan qianfan new Qianfan(Auth.TYPE_OAUTH,APIKey, SecretKey);PostMapping(/ai/sendMsg)public ResultData sendMsg(RequestBody String problem) {String result null;try {result chat(problem);} catch (Exception e) {e.printStackTrace();return new ResultData(ReturnCodeEnum.RC500.getCode(),服务暂不可用,null);}return new ResultData(ReturnCodeEnum.RC200.getCode(),ReturnCodeEnum.RC200.getMessage(),result);}private static String chat(String problem) {ChatBuilder bulder qianfan.chatCompletion().model(ERNIE-Speed-8K);//你要使用的大模型款式最好和我一样其他的很有可能是收费的bulder.addMessage(user,problem);//你的问题 ChatResponse response bulder.execute();return response.getResult();}
}第四步前端进行调用并动态将自己的问题与AI的回答填入Vue页面