在线网站开发学手机网站建设
2026/1/10 16:45:03 网站建设 项目流程
在线网站开发,学手机网站建设,东莞网站建设设计价格,填报wordpress模板MateChat / Angular 前端智能化场景解决方案UI库#xff0c;轻松构建你的AI应用。已服务于华为内部多个应用智能化改造#xff0c;并助力CodeArts、InsCode AI IDE等智能化助手搭建。 特性 面向智能化场景组件库开箱即用多场景匹配多主题适配#x1f9e9; 对接模型服务 在搭…MateChat / Angular前端智能化场景解决方案UI库轻松构建你的AI应用。已服务于华为内部多个应用智能化改造并助力CodeArts、InsCode AI IDE等智能化助手搭建。特性面向智能化场景组件库开箱即用多场景匹配多主题适配 对接模型服务在搭建完成页面后可以开始对接模型服务如 盘古大模型、ChatGPT 等优秀大模型在注册并生成对应模型的调用API_Key后可以参考如下方法进行调用通过 npm 安装 openai:$ npm install openai使用OpenAI初始化并调用模型接口如下为一段代码示例importOpenAIfromopenai;constclientnewOpenAI({apiKey:,// 模型APIKeybaseURL:,// 模型API地址dangerouslyAllowBrowser:true,});constfetchData(ques){constcompletionawaitclient.chat.completions.create({model:my-model,// 替换为自己的model名称messages:[{role:user,content:ques},],stream:true,// 为 true 则开启接口的流式返回});forawait(constchunkofcompletion){console.log(content: ,chunk.choices[0]?.delta?.content||);console.log(chatId: ,chunk.id);}}那么参考以上步骤【快速开始】中示例可调整下代码。将以下代码onSubmit(evt){this.inputValue;// 用户发送消息this.messages.push({from:user,content:evt,});setTimeout((){// 模型返回消息this.messages.push({from:model,content:evt,});},200);};修改为importOpenAIfromopenai;clientnewOpenAI({apiKey:,// 模型APIKeybaseURL:,// 模型API地址dangerouslyAllowBrowser:true,});onSubmitasync(evt){this.inputValue;// 用户发送消息this.messages.push({from:user,content:evt,avatarConfig:{name:user},});this.fetchData(evt);};fetchDataasync(ques){this.messages.push({from:model,content:,avatarConfig:{name:model},id:,loading:true,});constcompletionawaitthis.client.chat.completions.create({model:my-model,// 替换为自己的model名称messages:[{role:user,content:ques}],stream:true,// 为 true 则开启接口的流式返回});forawait(constchunkofcompletion){this.messages[this.messages.length-1].loadingfalse;constcontentchunk.choices[0]?.delta?.content||;constchatIdchunk.id;this.messages[this.messages.length-1].contentcontent;this.messages[this.messages.length-1].idchatId;}};完成模型API地址与APIKey填充后即拥有了一个对接大模型的简单应用。ModelArts Studio 大模型即服务平台集模型体验、精调、部署、管理、应用开发于一体降低企业使用大模型的开发门槛加速AI应用落地。在ModelArts StudioMaaS预置服务中开通商用服务MaaS预置服务的商用服务为企业用户提供高性能、高可用的推理API服务支持按Token用量计费的模式。该服务适用于需要商用级稳定性、更高调用频次和专业支持的场景。操作场景企业智能客服企业希望利用推理API优化客服系统实现智能问答、意图识别提升客服效率与客户满意度。内容创作辅助媒体、广告公司借助推理API进行文案创作、创意生成提高内容产出的效率与质量。智能数据分析金融、电商企业通过推理API对海量数据深度分析挖掘数据价值辅助决策制定。importrequestsimportjsonif__name____main__:urlhttps://api.modelarts-maas.com/v2/chat/completions#API地址 api_keyMAAS_API_KEY# 把MAAS_API_KEY替换成已获取的APIKey # Send request.headers{Content-Type:application/json,Authorization:fBearer {api_key}}data{model:DeepSeek-V3,# model参数messages:[{role:system,content:You are a helpful assistant.},{role:user,content:你好}]}responserequests.post(url,headersheaders,datajson.dumps(data),verifyFalse)# Print result.print(response.status_code)print(response.text)修改为非openai的模式import{Component,signal}fromangular/core;import{CommonModule}fromangular/common;import{BubbleModule,InputModule,MarkdownCardModule}frommatechat/ng;Component({selector:app-root,standalone:true,imports:[CommonModule,BubbleModule,InputModule,MarkdownCardModule],templateUrl:./app.html,styleUrl:./app.less,})exportclassApp{protectedreadonly titlesignal(matechat-demo);theme:stringdefault;// 或其他类型inputValue;messages:any[];newPagetrue;questionList[帮我写一篇文章,你可以帮我做些什么,帮我写一个快速排序,使用 js 格式化时间,];avatarConfig{imgSrc:https://matechat.gitcode.com/png/demo/userAvatar.svg,};modelAvatar{imgSrc:https://matechat.gitcode.com/logo.svg,};onSubmit(evt:any){this.newPagefalse;this.inputValue;// 用户发送消息this.messages.push({from:user,content:evt,});this.fetchData(evt);setTimeout((){// 模型返回消息this.messages.push({from:model,content:evt,});},200);};fetchDataasync(ques:string){consturlhttps://api.modelarts-maas.com/v2/chat/completions;constapiKey替换自己的吧小样;// 替换为实际的API Key// 添加loading状态消息this.messages.push({from:model,content:,avatarConfig:{name:model},id:,loading:true,});constresponseawaitfetch(url,{method:POST,headers:{Content-Type:application/json,Authorization:Bearer${apiKey}},body:JSON.stringify({model:DeepSeek-V3,messages:[{role:user,content:ques}],stream:true// 开启流式返回})});if(!response.ok){thrownewError(HTTP error! status:${response.status});}if(!response.body){thrownewError(Response body is null or undefined.);}constreaderresponse.body.getReader();constdecodernewTextDecoder();letaccumulatedContent;letchatId;while(true){const{done,value}awaitreader.read();if(done)break;constchunkdecoder.decode(value);constlineschunk.split(\n);for(constlineoflines){if(line.startsWith(data: )line!data: [DONE]){try{constjsonDataJSON.parse(line.slice(6));if(jsonData.id){chatIdjsonData.id;this.messages[this.messages.length-1].idchatId;}constcontentjsonData.choices?.[0]?.delta?.content||;if(content){accumulatedContentcontent;this.messages[this.messages.length-1].contentaccumulatedContent;this.messages[this.messages.length-1].loadingfalse;}}catch(e){// 忽略解析错误继续处理下一个数据块}}}}};}前端智能化场景解决方案UI库轻松构建你的AI应用。已服务于华为内部多个应用智能化改造并助力CodeArts、InsCode AI IDE等智能化助手搭建。MateChat官网https://matechat.gitcode.com。完成模型API地址与APIKey填充后即拥有了一个对接大模型的简单应用。DevUI官网https://devui.design/home。那么参考以上步骤【快速开始】中示例可调整下代码。MateChathttps://gitcode.com/DevCloudFE/MateChatMateChat官网https://matechat.gitcode.comDevUI官网https://devui.design/home

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询