跟着AI 学 AI, 开发一个ChatBot, 集成 Json 数据和查询

按照规律,使用AI生成一个架构图

直接上代码,为了方便学习,直接按照如下方式,复制到你的开发环境即可调试,运行代码。做学习参考。

代码注释多次说明这里,不在赘述。

"type": "carousel","contents": [{"type": "bubble","size": "micro","hero": {"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip10.jpg","size": "full","aspectMode": "cover","aspectRatio": "320:213"},"body": {"type": "box","layout": "vertical","contents": [{"type": "text","text": "Jason Cafe","weight": "bold","size": "sm","wrap": True},{"type": "box","layout": "baseline","contents": [{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gray_star_28.png"},{"type": "text","text": "4.0","size": "xs","color": "#8c8c8c","margin": "md","flex": 0}]},{"type": "box","layout": "vertical","contents": [{"type": "box","layout": "baseline","spacing": "sm","contents": [{"type": "text","text": "Jason's chat bot test1","wrap": True,"color": "#8c8c8c","size": "xs","flex": 5}]}]}],"spacing": "sm","paddingAll": "13px"}},{"type": "bubble","size": "micro","hero": {"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip11.jpg","size": "full","aspectMode": "cover","aspectRatio": "320:213"},"body": {"type": "box","layout": "vertical","contents": [{"type": "text","text": "Jason's chat bot 1","weight": "bold","size": "sm","wrap": True},{"type": "box","layout": "baseline","contents": [{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gray_star_28.png"},{"type": "text","text": "4.0","size": "sm","color": "#8c8c8c","margin": "md","flex": 0}

第二段:

 "type": "bubble","body": {"type": "box","layout": "vertical","contents": [{"type": "box","layout": "horizontal","contents": [{"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip7.jpg","size": "5xl","aspectMode": "cover","aspectRatio": "150:196","gravity": "center","flex": 1},{"type": "box","layout": "vertical","contents": [{"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip8.jpg","size": "full","aspectMode": "cover","aspectRatio": "150:98","gravity": "center"},{"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip9.jpg","size": "full","aspectMode": "cover","aspectRatio": "150:98","gravity": "center"}],"flex": 1}]},{"type": "box","layout": "horizontal","contents": [{"type": "box","layout": "vertical","contents": [{"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip13.jpg","aspectMode": "cover","size": "full"}],"cornerRadius": "100px","width": "72px","height": "72px"},{"type": "box","layout": "vertical","contents": [{"type": "text","contents": [{"type": "span","text": "My chat bot","weight": "bold","color": "#000000"},{"type": "span","text": "     "},{"type": "span","text": "This is my first front end of chat bot test. The website was buit in flex message"}],"size": "sm","wrap": True},{"type": "box","layout": "baseline","contents": [{"type": "text","text": "1,140,753 Like","size": "sm","color": "#bcbcbc"}],"spacing": "sm","margin": "md"}]}],"spacing": "xl","paddingAll": "20px"}],"paddingAll": "0px"}

这里是核心 如何集成

@handler.add(MessageEvent, message=TextMessageContent)
def handle_message(event):text = event.message.textwith ApiClient(configuration) as api_client:line_bot_api = MessagingApi(api_client)# confirm templateif text=="flex-1":   #url= request.url_root +'/MoreType/1.jpg'# 由于一直报错,我使用的博文中的图片。'''url= "https://i-blog.csdnimg.cn/direct/369fc618763c4e6088e5722ac5dfe340.png"app.logger.info('url='+ url)bubble= FlexBubble(direction='1tr'hero=FlexBubble(url =url,size='full',aspect_ratio='20:13',aspect_mode = 'cover',action=URIAction(uri='',label='label')),body=FlexBox(layout='vertical',contents=[#titleFlexText(text='Jasons chat bot',weight='bold',size='x1')#reviewFlexBox(layout='baseline',margin='md',content=[FlexIcon(size='sm',url="")])]))'''elif text == 'flex-2':line_flex_json={
     }line_flex_str = json.dumps(line_flex_json)line_bot_api.reply_message(ReplyMessageRequest(reply_token= event.reply_token,messages=[FlexMessage(alt_text='More Detail',contents=FlexContainer.from_json(line_flex_str))]))else:line_bot_api.reply_message(ReplyMessageRequest(reply_token=event.reply_token,messages=[TextMessage(text=event.message.text)]))

执行效果:

第二段执行效果,

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/63193.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

WPF+MVVM案例实战与特效(三十七)- 实现带有水印和圆角的自定义 TextBox 控件

文章目录 1、概述2、案例实现1、基本功能2、代码实现3、控件应用4、案例效果4、总结1、概述 在开发用户界面时,TextBox 是最常见的输入控件之一。为了提升用户体验,我们经常需要为 TextBox 添加一些额外的功能,例如显示提示文本(水印)和设置圆角边框。本文将详细介绍如何…

使用枚举实现单例模式,不会反序列化破坏攻击,不会被反射破坏攻击。(附带枚举单例的简单实现)

原因分析 1.反序列化方法 ① jdk8中的Enum源码中对反序列化方法进行重写,抛出异常。 java.lang.Enum#readObject方法截图如下 ②java.io.ObjectInputStream#readObject 方法中的 readEnum 方法处理了枚举类型的反序列化,从而确保了枚举的单例特性。 …

Linux下的守护程序

启动流程 嵌入式设备下Linux的内核系统启动的流程并不复杂,从最早的父进程init开始,为创建各种服务进程:系统会从 inittab 文件中,读取每一行作为执行命令👇 # Note: BusyBox init doesnt support runlevels. The r…

2024第十六届蓝桥杯模拟赛(第二期)-Python

# 2024第十六届蓝桥杯模拟赛&#xff08;第二期&#xff09;-Python题解 # 自己改注释# -----------------------1------------------------ # def prime(x): # if x < 2: # return 0 # for i in range(2, int(x ** 0.5) 1): # if x % i 0: # …

MongoDB-副本集

一、什么是 MongoDB 副本集&#xff1f; 1.副本集的定义 MongoDB 的副本集&#xff08;Replica Set&#xff09;是一组 MongoDB 服务器实例&#xff0c;它们存储同一数据集的副本&#xff0c;确保数据的高可用性和可靠性。副本集中的每个节点都有相同的数据副本&#xff0c;但…

《数据结构》(408代码题)

2009 单链表&#xff08;双指针&#xff09; 分析&#xff1a;首先呢&#xff0c;给我们的数据结构是一个带有表头结点的单链表&#xff0c;也不允许我们改变链表的结构。链表的长度不是直接给出的啊&#xff0c;所以这个倒数也很棘手。那我们该如何解决这个“k”呢&#xff0c…

6.1 初探MapReduce

MapReduce是一种分布式计算框架&#xff0c;用于处理大规模数据集。其核心思想是“分而治之”&#xff0c;通过Map阶段将任务分解为多个简单任务并行处理&#xff0c;然后在Reduce阶段汇总结果。MapReduce编程模型包括Map和Reduce两个阶段&#xff0c;数据来源和结果存储通常在…

Cad c#.net 一键修改标注dimension中的文本内容

本例为给标注加前缀&#xff0c;也可定制其他形式&#xff0c;效果如下&#xff1a; public class Demo{[CommandMethod("xx")]//public void Dim(){Document doc Application.DocumentManager.MdiActiveDocument;Database db doc.Database;Editor ed doc.Editor;…

Scala的隐式类

package hfd //隐式类 //任务&#xff1a;给之前的BaseUser添加新的功能&#xff0c;但是不要直接去改代码 //思路&#xff1a;把BaseUser通过隐式转换&#xff0c;改成一个新类型&#xff0c;而这个新类型中有这新的方法 //implicit class一个隐式转换函数类 //作用&#xff1…

旅游系统旅游小程序PHP+Uniapp

旅游门票预订系统&#xff0c;支持景点门票、导游产品便捷预订、美食打卡、景点分享、旅游笔记分享等综合系统 更新日志 V1.3.0 1、修复富文本标签 2、新增景点入驻【高级版本】3、新增门票核销【高级版】4、新增门票端口【高级版】

MacOS系统 快速安装appium 步骤详解

在macOS系统上&#xff0c;你可以通过使用nvm&#xff08;Node Version Manager&#xff09;来管理Node.js的版本&#xff0c;并基于nvm安装的Node.js环境来快捷地安装Appium。以下是具体步骤&#xff1a; 一、安装nvm 下载nvm 访问nvm的GitHub仓库&#xff08;nvm GitHub&…

模型训练中梯度累积步数(gradient_accumulation_steps)的作用

模型训练中梯度累积步数&#xff08;gradient_accumulation_steps&#xff09;的作用 flyfish 在使用训练大模型时&#xff0c;TrainingArguments有一个参数梯度累积步数&#xff08;gradient_accumulation_steps&#xff09; from transformers import TrainingArguments梯…

技术速递|.NET 9 简介

作者&#xff1a;.NET 团队 排版&#xff1a;Alan Wang 今天&#xff0c;我们非常激动地宣布 .NET 9的发布&#xff0c;这是迄今为止最高效、最现代、最安全、最智能、性能最高的 .NET 版本。这是来自世界各地数千名开发人员又一年努力的成果。这个新版本包括数千项性能、安全和…

Vue项目打包部署到服务器

1. Vue项目打包部署到服务器 1.1. 配置 &#xff08;1&#xff09;修改package.json文件同级目录下的vue.config.js文件。 // vue.config.js module.exports {publicPath: ./, }&#xff08;2&#xff09;检查router下的index.js文件下配置的mode模式。   检查如果模式改…

【jpa】springboot使用jpa示例

目录 1. 请求示例2. pom依赖3. application.yaml4.controller5. service6. repository7. 实体8. 启动类 1. 请求示例 curl --location --request POST http://127.0.0.1:8080/user \ --header User-Agent: Apifox/1.0.0 (https://apifox.com) \ --header Content-Type: applic…

uniapp 常用的指令语句

uniapp 是一个使用 Vue.js 开发的跨平台应用框架&#xff0c;因此&#xff0c;它继承了 Vue.js 的大部分指令。以下是一些在 uniapp 中常用的 Vue 指令语句及其用途&#xff1a; v-if / v-else-if / v-else 条件渲染。v-if 有条件地渲染元素&#xff0c;v-else-if 和 v-else 用…

中企出海-德国会计准则和IFRS间的差异

根据提供的网页内容&#xff0c;德国的公认会计准则&#xff08;HGB&#xff09;与国际会计准则&#xff08;IFRS&#xff09;之间的主要差异可以从以下几个方面进行比较&#xff1a; 财务报告的目的&#xff1a; IFRS&#xff1a;财务报告主要是供投资者做决策使用&#xff0c…

NPU是什么?电脑NPU和CPU、GPU区别介绍

随着人工智能技术的飞速发展&#xff0c;计算机硬件架构也在不断演进以适应日益复杂的AI应用场景。其中&#xff0c;NPU&#xff08;Neural Processing Unit&#xff0c;神经网络处理器&#xff09;作为一种专为深度学习和神经网络运算设计的新型处理器&#xff0c;正逐渐崭露头…

使用skywalking,grafana实现从请求跟踪、 指标收集和日志记录的完整信息记录

Skywalking是由国内开源爱好者吴晟开源并提交到Apache孵化器的开源项目&#xff0c; 2017年12月SkyWalking成为Apache国内首个个人孵化项目&#xff0c; 2019年4月17日SkyWalking从Apache基金会的孵化器毕业成为顶级项目&#xff0c; 目前SkyWalking支持Java、 .Net、 Node.js、…

纯CSS实现文本或表格特效(连续滚动与首尾相连)

纯CSS实现文本连续向左滚动首尾相连 1.效果图&#xff1a; 2.实现代码&#xff1a; <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8" /><meta name"viewport" content"widthdevice-width, init…