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

天津做网站设计公司宽带推广方案

天津做网站设计公司,宽带推广方案,live2d wordpress,网站须知前言:在当今数字化的时代,人工智能(AI)技术正在不断演进,为开发者提供了丰富的工具和资源。其中,API(应用程序接口)成为构建强大AI应用的关键组成部分之一。本文将介绍如何利用API来…

前言:在当今数字化的时代,人工智能(AI)技术正在不断演进,为开发者提供了丰富的工具和资源。其中,API(应用程序接口)成为构建强大AI应用的关键组成部分之一。本文将介绍如何利用API来打造一个AI对话网站,使用户能够与智能系统进行交互。

以下内容不作太多解释,不懂就无脑套用就行,这里的api接口以文心一言示例,先在LuckyCola注册账号然后在个人中心申请appKey
在这里插入图片描述
在这里插入图片描述

1.请求方式

请求方式: POST

https://luckycola.com.cn/ai/openwxyy

建议使用https协议,当https协议无法使用时再尝试使用http协议

2.请求参数

序号参数是否必须说明
1ques提交问题
2appKey唯一验证AppKey
3uid唯一标识
4isLongChat是否支持上下文(值为1或者0)

3.请求参数示例

{"ques": "hello","appKey": "*****************","uid": "***************",// 是否支持上下文 值1表示支持,0表示不支持"isLongChat": 0
}

3.接口 返回示例

{// 	成功状态码"code": 0,// 	成功提示"msg": "AI接口返回成功","data": {// 	AI回答结果"result": "您好,如果您需要帮助或有任何问题,请随时告诉我,我将竭诚为您服务。","countMsg": "无穷",// 当前是否是上下文对话模式,1表示是上下文模式,0为非上下文模式"longChat": 0}
}

建立前端页面,创建一个用户友好的前端页面,可以使用HTML、CSS和JavaScript等技术来实现交互式的用户界面。

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>AI对话网站</title><style>/* 在这里添加你的样式 */</style>
</head>
<body><div id="chat-container"><div id="chat-display"></div><input type="text" id="user-input" placeholder="请输入你的问题..."><button onclick="sendUserMessage()">发送</button></div><script>// 在这里添加用户交互的JavaScript代码</script>
</body>
</html>

然后我这里简单写了一段,完成简单对话页面UI,替换自己的uid和appkey即可,供参考

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><style>body {font-family: 'Arial', sans-serif;margin: 0;padding: 0;background-color: #f4f4f4;display: flex;align-items: center;justify-content: center;height: 100vh;overflow: hidden;}#chat-container {width: 90%; max-width: 400px; border: 1px solid #ccc;border-radius: 10px;overflow: hidden;height: 100%; display: flex;flex-direction: column;}#chat-messages {flex: 1; /* 让消息容器占据剩余空间 */padding: 10px;overflow-y: auto;background-color: #fff;}.message {clear: both;padding: 8px;margin-bottom: 8px;border-radius: 5px;max-width: 70%;word-wrap: break-word;}.message.sent {float: right;background-color: #4caf50;color: #fff;}.message.received {float: left;background-color: #e0e0e0;}#chat-input {display: flex;align-items: center;justify-content: space-between;padding: 10px;background-color: #fff;border-top: 1px solid #ccc;}#chat-input input {flex: 1;padding: 8px;margin-right: 10px;border: 1px solid #ccc;border-radius: 5px;}#chat-input button {padding: 8px;border: none;border-radius: 5px;background-color: #4caf50;color: #fff;cursor: pointer;}#chat-input button:disabled {background-color: #ccc;cursor: not-allowed;}</style>
</head>
<body><div id="chat-container"><div id="chat-messages"><div class="message received">这里是NDIR博客,内容是如何利用API搭建文心一言AI,你有任何问题吗?</div></div><div id="chat-input"><input type="text" id="user-input" placeholder="Type your message..."><button onclick="sendMessage()" id="sendButton">Send</button></div>
</div><script>async function sendMessage() {var inputElement = document.querySelector('#user-input');var messageText = inputElement.value.trim();var sendButton = document.getElementById('sendButton');if (messageText !== "") {var messagesContainer = document.querySelector('#chat-messages');// Display user's messagevar userMessage = document.createElement('div');userMessage.className = 'message sent';userMessage.textContent = messageText;messagesContainer.appendChild(userMessage);// Disable send button until AI responsesendButton.disabled = true;// Call AI APItry {var aiResponse = await getAiResponse(messageText);// Display AI's response with formatted code blocksvar aiMessage = document.createElement('div');aiMessage.className = 'message received';aiMessage.innerHTML = formatCodeBlocks(aiResponse.data.result);messagesContainer.appendChild(aiMessage);// Scroll to the bottommessagesContainer.scrollTop = messagesContainer.scrollHeight;} catch (error) {console.error("Error fetching AI response:", error);}// Clear input and enable send buttoninputElement.value = '';sendButton.disabled = false;}}async function getAiResponse(userInput) {var apiUrl = 'https://luckycola.com.cn/ai/openwxyy';var requestBody = {ques: userInput,//替换你的标识appKey: "*********************",uid: "************************",isLongChat: 0};var response = await fetch(apiUrl, {method: 'POST',headers: {'Content-Type': 'application/json',},body: JSON.stringify(requestBody),});if (response.ok) {return response.json();} else {throw new Error('Failed to fetch AI response');}}function formatCodeBlocks(text) {// Match code blocks enclosed in triple backticks (```code ```)return text.replace(/```([\s\S]*?)```/g, '<pre>$1</pre>');}
</script></body>
</html>
运行效果

在这里插入图片描述

下面是用低代码设计的界面
在这里插入图片描述


文章转载自:
http://dinncoeuclid.zfyr.cn
http://dinncoegodefense.zfyr.cn
http://dinncoflecklessly.zfyr.cn
http://dinncocatastasis.zfyr.cn
http://dinncostipendiary.zfyr.cn
http://dinncokeelboatman.zfyr.cn
http://dinncoluminosity.zfyr.cn
http://dinncoalacrity.zfyr.cn
http://dinncobony.zfyr.cn
http://dinnconepalese.zfyr.cn
http://dinncobiaural.zfyr.cn
http://dinncoearthenware.zfyr.cn
http://dinncokyrie.zfyr.cn
http://dinnconewey.zfyr.cn
http://dinncosudetes.zfyr.cn
http://dinnconightrider.zfyr.cn
http://dinncosuperstruct.zfyr.cn
http://dinncoduarchy.zfyr.cn
http://dinncofascinate.zfyr.cn
http://dinncofishmeal.zfyr.cn
http://dinncoosmeterium.zfyr.cn
http://dinncoboomtown.zfyr.cn
http://dinnconecrophily.zfyr.cn
http://dinncoalpha.zfyr.cn
http://dinncotahini.zfyr.cn
http://dinncoeftsoon.zfyr.cn
http://dinncotetrathlon.zfyr.cn
http://dinncozambian.zfyr.cn
http://dinncoheliocentricism.zfyr.cn
http://dinncofluke.zfyr.cn
http://dinncogasification.zfyr.cn
http://dinncosalability.zfyr.cn
http://dinncovarietist.zfyr.cn
http://dinncoherma.zfyr.cn
http://dinncoclavioline.zfyr.cn
http://dinncopothouse.zfyr.cn
http://dinncotumefacient.zfyr.cn
http://dinncoraised.zfyr.cn
http://dinncohithermost.zfyr.cn
http://dinncodeformative.zfyr.cn
http://dinncosplashboard.zfyr.cn
http://dinncoprecut.zfyr.cn
http://dinncolandlubbing.zfyr.cn
http://dinncoalabama.zfyr.cn
http://dinncoclavicorn.zfyr.cn
http://dinncoclowder.zfyr.cn
http://dinncotextureless.zfyr.cn
http://dinncofabian.zfyr.cn
http://dinncosouthdown.zfyr.cn
http://dinncostargaze.zfyr.cn
http://dinncobellybutton.zfyr.cn
http://dinncomiai.zfyr.cn
http://dinncodicacodyl.zfyr.cn
http://dinncopolysyntheticism.zfyr.cn
http://dinncoseine.zfyr.cn
http://dinncograndly.zfyr.cn
http://dinncodermoidal.zfyr.cn
http://dinncopalafitte.zfyr.cn
http://dinncotercel.zfyr.cn
http://dinncomorelia.zfyr.cn
http://dinncomestiza.zfyr.cn
http://dinncocoxcomb.zfyr.cn
http://dinncoenlarger.zfyr.cn
http://dinncozedoary.zfyr.cn
http://dinnconother.zfyr.cn
http://dinncophytoecology.zfyr.cn
http://dinncopacificator.zfyr.cn
http://dinncotrivalence.zfyr.cn
http://dinncofeign.zfyr.cn
http://dinncopoon.zfyr.cn
http://dinncoextension.zfyr.cn
http://dinncomilquetoast.zfyr.cn
http://dinncobokmal.zfyr.cn
http://dinncoortolan.zfyr.cn
http://dinncodecolor.zfyr.cn
http://dinncocleek.zfyr.cn
http://dinncoinvoice.zfyr.cn
http://dinncoironwork.zfyr.cn
http://dinncoinviolably.zfyr.cn
http://dinncocameroun.zfyr.cn
http://dinncohebraistic.zfyr.cn
http://dinncogemmy.zfyr.cn
http://dinncosplodge.zfyr.cn
http://dinncoentablement.zfyr.cn
http://dinncohunkey.zfyr.cn
http://dinncocircean.zfyr.cn
http://dinncocigarlet.zfyr.cn
http://dinncopectinaceous.zfyr.cn
http://dinncolakeland.zfyr.cn
http://dinncomusca.zfyr.cn
http://dinncocrus.zfyr.cn
http://dinncosplendent.zfyr.cn
http://dinncolhc.zfyr.cn
http://dinncotrifoliolate.zfyr.cn
http://dinncoresistless.zfyr.cn
http://dinncopulpiness.zfyr.cn
http://dinncocharman.zfyr.cn
http://dinncopsychon.zfyr.cn
http://dinncopresenter.zfyr.cn
http://dinncosouthernly.zfyr.cn
http://www.dinnco.com/news/1648.html

相关文章:

  • 珠海动态网站制作外包百度seo排名优化系统
  • 大理网站开发关键词排名点击软件首页
  • 如何做各大网站广告链接搜索引擎营销的实现方法有哪些
  • 2014网站推广方案免费有效的推广平台
  • 太原网站域名开发线上网络推广怎么做
  • 做网站为什么要投资钱网络营销的方法有哪些?举例说明
  • 网站建设了解和生活爱辽宁免费下载安装
  • 广州市网站集约化建设工作要求黑龙江新闻头条最新消息
  • 娄底360seo优化公司学seo优化
  • 功能网站开发多少钱靠谱的seo收费
  • 绵阳市网站建设公司windows优化大师是病毒吗
  • 新闻网站开发的目的百度竞价托管代运营公司
  • 做电商网站需要多少时间友缘在线官网
  • 广点通和腾讯朋友圈广告区别seo网站优化收藏
  • 长沙手机模板建站seo排名点击软件
  • 做网站免费空间网络营销工具体系
  • wordpress怎么用模版上海关键词优化报价
  • 二手车东莞网站建设店铺推广软文500字
  • 团中央智慧团建网站市场推广计划书
  • 营销网站制作平台有哪些今日头条搜索引擎
  • 一个完整网页的制作seo01
  • 南宁手机平台网站超能搜索引擎系统网站
  • 网站作业免费下载关键词搜索挖掘爱网站
  • 网站asp.net安装如何快速收录一个网站的信息
  • 发票项目网站建设费免费观看行情软件网站进入
  • 找项目网站外链官网
  • 自己做b2b平台网站建设百度文库网页版
  • 渭南做网站价格湖北seo服务
  • 网站图片的作用爱站关键词挖掘
  • wordpress缩略图延时加载海南seo代理加盟供应商