In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to make intelligent chat robots with Python". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
[The effect is as follows]
[Implementation process]
1. GUI interface production, not much to say.
2. Implementation of intelligent chat robot:
Therefore, I applied for an account (unauthenticated individual users can only reply 3 times/day, and 100 times/day can be realized after authentication; of course, there are more RMB players).
After applying for an account, it is very simple. Send http request through post request, and the response is the reply of Turing robot. The only thing to note is that in the content of the Post request body, key is the apikey value applied by yourself;usrid can be set at will, info is the question entered by the user, as shown in the following figure:
[Sample Code]
# coding= utf-8#@Auther: "Peng Ge Thief Excellent"# @Date : 2019/8/16#@Software: PyCharm
from PyQt5 import QtCore, QtGui, QtWidgetsimport sysimport requests
class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Smart Chatbot") Dialog.resize(582, 434) self.label = QtWidgets.QLabel(Dialog) self.label.setGeometry(QtCore.QRect(40, 30, 361, 51)) self.label.setStyleSheet("color: rgb(0, 0, 255);\n""font: 16pt \" black body\";\n""text-decoration: underline;") self.label.setObjectName("dialog") self.plainTextEdit = QtWidgets.QPlainTextEdit(Dialog) self.plainTextEdit.setGeometry(QtCore.QRect(40, 80, 501, 181)) self.plainTextEdit.setObjectName("plainTextEdit") self.plainTextEdit_2 = QtWidgets.QPlainTextEdit(Dialog) self.plainTextEdit_2.setGeometry(QtCore.QRect(40, 310, 401, 41)) self.plainTextEdit_2.setObjectName("plainTextEdit_2") self.plainTextEdit.setStyleSheet("font: 14pt\" Bold\";\n") self.pushButton = QtWidgets.QPushButton(Dialog) self.pushButton.setGeometry(QtCore.QRect(480, 320, 75, 23)) self.pushButton.setStyleSheet("font: 14pt \" black body\";\n""background-color: rgb(0, 255, 0);") self.pushButton.setObjectName("pushButton") self.label_2 = QtWidgets.QLabel(Dialog) self.label_2.setGeometry(QtCore.QRect(50, 280, 54, 12)) self.label_2.setText("") self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel(Dialog) self.label_3.setGeometry(QtCore.QRect(50, 280, 71, 16)) self.label_3.setStyleSheet("font: 75 12pt \"Aharoni\";") self.label_3.setObjectName("label_3")
self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog): _translate = QtCore.QCoreApplication.translate Dialog.setWindowTitle(_translate("Dialog", "Smart Chatbot")) self.label.setText(_translate("Dialog", "Welcome to Turing Intelligent Chatbot: ")) self.pushButton.setText(_translate("Dialog", "Send")) self.label_3.setText(_translate("Dialog", "Input Box")) self.pushButton.clicked.connect(self.get_response)
def get_response(self): enterstr = self.plainTextEdit_2.toPlainText() url = 'http://www.tuling123.com/openapi/api' data = { 'key':' own key', 'info': enterstr, 'userid': "test", } r = requests.post(url, data=data).json() result = ">> Me: {0}\n \n>> Xiaoqi: {1}#^_^# \n".format(enterstr,r.get("text")) self.plainTextEdit.setPlainText(result) return result
if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) main = QtWidgets.QMainWindow() mainwindow = Ui_Dialog() mainwindow.setupUi(main) main.show() sys.exit(app.exec())"How to use Python to make intelligent chatbots" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.