当前位置: 首页 > news >正文

网站是否正常安阳网络公司

网站是否正常,安阳网络公司,百度推广价格价目表,WordPress加QQ和微信插件近日#xff0c;国产AI DeepSeek在中国、美国的科技圈受到广泛关注#xff0c;甚至被认为是大模型行业的最大“黑马”。在外网#xff0c;DeepSeek被不少人称为“神秘的东方力量”。1月27日#xff0c;DeepSeek应用登顶苹果美国地区应用商店免费APP下载排行榜#xff0c;在… 近日国产AI DeepSeek在中国、美国的科技圈受到广泛关注甚至被认为是大模型行业的最大“黑马”。在外网DeepSeek被不少人称为“神秘的东方力量”。1月27日DeepSeek应用登顶苹果美国地区应用商店免费APP下载排行榜在美区下载榜上超越了ChatGPT。同日苹果中国区应用商店免费榜显示DeepSeek成为中国区第一。总之就是deepseek目前比较火同时也提供了开放平台尝试接入一下也比较方便官网每个接口都提供了各种语言的示例代码java采用的okhttp我用httpurlconnection尝试下 一、获取 API key 开放平台地址DeepSeek 登录deepseek开放平台创建API keys注意创建的时候复制key要不然找不到了 新账号有10元的体验额度不足可以充值10元体验额度的有效期为1个月 v3和R1的收费标准 1. deepseek-chat 模型优惠期至北京时间 2025 年 2 月 8 日 24:00期间 API 调用享历史价格优惠结束后将按每百万输入 tokens 2 元每百万输出 tokens 8 元计费。 2. deepseek-reasoner 模型上线即按每百万输入 tokens 4 元每百万输出 tokens 16 元计费。 二、获取开放API文档 接口地址首次调用 API | DeepSeek API Docs 进入接口文档提供了对话、补全、模型等接口我们找一个【对话补全】接口给了一个上下文让他补充说话 三、JAVA调用API文档 使用java调用API跟其他接口没什么区别方便上手注意下入参和返回参数就可以采用json格式。 -----对话上下文 { content: 欢迎加入虚拟电厂, role: system , name: muyunfei }, { content: 你好虚拟电厂与deepseek结合的方向说一下吧, role: user , name: 路人甲} 组装请求参数 {messages: [{content: 欢迎加入虚拟电厂,role: system,name: muyunfei}, {content: 你好虚拟电厂与deepseek结合的方向说一下吧,role: user,name: 路人甲}],model: deepseek-chat,frequency_penalty: 0,max_tokens: 2048,presence_penalty: 0,response_format: {type: text},stop: null,stream: false,stream_options: null,temperature: 1,top_p: 1,tools: null,tool_choice: none,logprobs: false,top_logprobs: null } 返回数据参数格式 {id: 2fe86f3b-6e3b-4e65-b35a-1127c14c8739,object: chat.completion,created: 1738810567,model: deepseek-chat,choices: [{index: 0,message: {role: assistant,content: Hello! How can I assist you today? },logprobs: null,finish_reason: stop}],usage: {prompt_tokens: 9,completion_tokens: 11,total_tokens: 20,prompt_tokens_details: {cached_tokens: 0},prompt_cache_hit_tokens: 0,prompt_cache_miss_tokens: 9},system_fingerprint: fp_3a5770e1b4} ------------------------------------------------------------------------ --------------------------      完整代码      ------------------------ import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.security.cert.CertificateException; import java.security.cert.X509Certificate;import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager;import net.sf.json.JSONArray; import net.sf.json.JSONObject;/*** 实现了。。。。。。** author 牟云飞**pModification History:/p*pDate Author Description/p*p------------------------------------------------------------------/p*p2025年2月4日 牟云飞 新建/p*/ public class DeepseekTestMain {private static final String DEEPSEEK_API_URL_COMPLETIONS https://api.deepseek.com/chat/completions; // API地址 ——// 对话补全private static final String DEEPSEEK_API_KEY 换成自己的key; // 官网申请的api keypublic static void main(String[] args) {DeepseekTestMain test new DeepseekTestMain();try {test.sendDeepseekChat(DEEPSEEK_API_URL_COMPLETIONS, 虚拟电厂与deepseek结合的方向说一下);} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}/*** 对话补全* * param mess* return* throws IOException*/public String sendDeepseekChat(String deepseekUrl, String context) throws IOException {String result null;URL url_req new URL(deepseekUrl);HttpsURLConnection connection (HttpsURLConnection) url_req.openConnection();// 设置参数connection.setDoOutput(true); // 需要输出connection.setDoInput(true); // 需要输入connection.setUseCaches(false); // 不允许缓存connection.setConnectTimeout(60000); // 设置连接超时connection.setReadTimeout(60000); // 设置读取超时connection.setRequestMethod(POST); // 设置POST方式连接// 设置请求属性connection.setRequestProperty(Content-Type, application/json);connection.setRequestProperty(Accept, application/json);connection.setRequestProperty(Charset, UTF-8);// 设置请求头参数connection.addRequestProperty(Authorization, Bearer DEEPSEEK_API_KEY); // 设置appIdHttpsURLConnection https (HttpsURLConnection) connection;SSLSocketFactory oldSocketFactory trustAllHosts(https);HostnameVerifier oldHostnameVerifier https.getHostnameVerifier();https.setHostnameVerifier(DO_NOT_VERIFY);// 输入数据String requestData { \messages\: [ { \content\: \欢迎加入虚拟电厂\, \role\: \system\ , \name\: \muyunfei\ }, { \content\: \你好虚拟电厂与deepseek结合的方向说一下吧\, \role\: \user\ , \name\: \路人甲\} ], \model\: \deepseek-chat\, \frequency_penalty\: 0, \max_tokens\: 2048, \presence_penalty\: 0, \response_format\: {\n \type\: \text\\n }, \stop\: null, \stream\: false, \stream_options\: null, \temperature\: 1, \top_p\: 1, \tools\: null, \tool_choice\: \none\, \logprobs\: false, \top_logprobs\: null};try (OutputStream os connection.getOutputStream()) {byte[] input requestData.getBytes(utf-8);os.write(input,0,input.length);}// 输出数据InputStream in connection.getInputStream(); // 获取返回数据BufferedInputStream bis new BufferedInputStream(in);ByteArrayOutputStream baos new ByteArrayOutputStream();int c;while (-1 ! (c bis.read())) {baos.write(c);}bis.close();in.close();baos.flush();byte[] data baos.toByteArray();String responseMsg new String(data);System.out.println(responseMsg); // { // id: 2fe86f3b-6e3b-4e65-b35a-1127c14c8739, // object: chat.completion, // created: 1738810567, // model: deepseek-chat, // choices: [{ // index: 0, // message: { // role: assistant, // content: Hello! How can I assist you today? // }, // logprobs: null, // finish_reason: stop // }], // usage: { // prompt_tokens: 9, // completion_tokens: 11, // total_tokens: 20, // prompt_tokens_details: { // cached_tokens: 0 // }, // prompt_cache_hit_tokens: 0, // prompt_cache_miss_tokens: 9 // }, // system_fingerprint: fp_3a5770e1b4 // }JSONObject jsonObject JSONObject.fromObject(responseMsg);JSONArray choices JSONArray.fromObject(jsonObject.get(choices));// 获取补全内容是个数组多个补全回复多个System.out.println(choices.toString());JSONObject item JSONObject.fromObject(JSONObject.fromObject(choices.get(0)).get(message));System.out.println(item.get(content));// 对JSON作解析return result;}private SSLSocketFactory trustAllHosts(HttpsURLConnection connection) {SSLSocketFactory oldFactory connection.getSSLSocketFactory();try {SSLContext sc SSLContext.getInstance(TLS);sc.init(null, trustAllCerts, new java.security.SecureRandom());SSLSocketFactory newFactory sc.getSocketFactory();connection.setSSLSocketFactory(newFactory);} catch (Exception e) {e.printStackTrace();}return oldFactory;}private TrustManager[] trustAllCerts new TrustManager[] { new X509TrustManager() {public java.security.cert.X509Certificate[] getAcceptedIssuers() {return new java.security.cert.X509Certificate[] {};}public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {}public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {}} };private HostnameVerifier DO_NOT_VERIFY new HostnameVerifier() {public boolean verify(String hostname, SSLSession session) {return true;}};}
http://www.dnsts.com.cn/news/26382.html

相关文章:

  • c2c电子商务网站用到的技术网络公关什么意思
  • 网站开发系统需求说明书怎么做婚恋网站
  • 网站正在建设中 htmlamh wordpress 伪静态
  • 东莞网站建设外贸哪里有html5网站建设
  • 廊坊网站建设公司哪家好网站改标题降权
  • 宁晋seo网站优化排名wordpress 自定义面板
  • 上海金山网站建设公司电子网站商业策划书
  • 做网站制作大概多少钱厦门网站建设合同
  • 正规的南昌网站建设网站pc端建设
  • 旅游网站内容规划网站调用微信js视频
  • python做电子商务网站lovephoto wordpress
  • 网站做seo有什么作用广告策划公司
  • 珠海市官网网站建设价格网站建设合同英文
  • 网站建设发言材料为什么要建立企业网站
  • 网站地链接结构杭州广告公司网站建设
  • 网站服务器哪些好辽宁最好的男科医院
  • 做网站的边框江阴网站建设工作室
  • 国外什么网站是做外贸网页设计基础心得体会
  • 室内设计毕业设计代做网站建站平台免代码
  • 云服务器建立多个网站wordpress增加分类
  • 推荐网站在线看兄弟们腾讯广告投放平台
  • 脉脉用的什么技术做网站赣州市南康区建设局网站
  • 招代理商的网站网站制作公司拟
  • 适合设计师的网站自己做的网站打不开怎么回事
  • 做物流网站费用多少惠州小程序开发
  • 十大景观设计网站保险咨询免费
  • 做视频哪个网站收入高详情页设计英文翻译
  • ps做的网站稿怎么做成网站加盟做地方门户网站
  • 库尔勒网站建设wordpress下载的主题不完整
  • 商城网站怎么自己搭建近期的时事热点或新闻事件