前言

大家好,我是三木,今天分享一个有趣的Python编程教程!

在这个教程中,我们将一起学习如何使用Python调用智谱AI的免费大模型,最终制作一个属于你自己的AI聊天机器人。

你只需要有一点Python编程的基础知识,比如知道什么是变量、函数和基本的字符串操作。

准备好了吗?让我们开始这段有趣的AI冒险之旅吧!

第一部分:了解智谱AI和GLM-4-Flash模型

什么是智谱AI?

智谱AI是中国一家领先的AI研究机构,他们开发了自己的大语言模型(LLM)。

大语言模型是一种能够理解和生成人类语言的AI系统,可以用来回答问题、创作文章、编写代码等。

GLM-4-Flash模型简介

智谱AI的GLM-4-Flash是他们推出的一个免费大模型API,速度非常快,适合用来处理各种任务,比如文章创作、代码调试、知识库问答等。

它是一个多语言模型,能够处理中文和英文,特别适合我们这样的中文学习者使用。

为什么选择GLM-4-Flash?

GLM-4-Flash特别适合我们使用有几个原因:

  1. 它是免费的,我们可以不用担心成本问题
  2. 它运行速度快,能够快速响应我们的请求
  3. 它功能强大,能够处理多种任务
  4. 它有专门的Python SDK,方便我们调用

第二部分:准备环境

安装Python

首先,我们需要确保电脑上已经安装了Python。

推荐使用Python 3.8到3.12版本。

如果你还没有安装Python,可以从官方网站(https://www.python.org)下载并安装。

安装必要的库

接下来,我们需要安装智谱AI的Python SDK。

打开你的终端或命令行工具,运行以下命令:

pip install zhipuai

这个命令会安装智谱AI的Python SDK,让我们能够方便地调用他们的API。

第三部分:获取API密钥

为了使用智谱AI的API,我们需要获取一个API密钥。

API密钥就像是进入智谱AI世界的通行证,它允许我们访问他们的模型。

注册智谱AI账号

  1. 访问智谱AI的官方网站:https://open.bigmodel.cn
  2. 点击”注册”按钮,创建一个新的账号
  3. 注册完成后,登录你的账号

获取API密钥

  1. 登录后,找到”API密钥”或”API Key”的选项
  2. 创建一个新的API密钥
  3. 记下生成的API密钥,这是个重要的字符串,我们需要在代码中使用它

第四部分:编写基本的Python代码调用智谱AI

现在,我们已经准备好编写代码来调用智谱AI的GLM-4-Flash模型了。

基本调用代码

以下是一个基本的Python代码示例,展示了如何使用智谱AI的Python SDK调用GLM-4-Flash模型:

from zhipuai import Client
# 初始化客户端,需要替换成你自己的API密钥
client = Client(api_key="YOUR_API_KEY")
# 调用GLM-4-Flash模型
response = client.chat.completions.create(
    model="glm-4-flash",
    messages=[
        {"role": "user", "content": "你好,世界!"},  # 这是我们发送给AI的提问
    ]
)
# 打印AI的回复
print("AI的回复:", response.choices[0].message["content"])

这段代码做了以下几件事:

  1. 导入智谱AI的Client类
  2. 使用你的API密钥初始化一个客户端
  3. 调用chat.completions.create方法,这是发送聊天请求的主要方法
  4. 指定使用”glm-4-flash”模型
  5. 发送一条消息,内容是”你好,世界!”
  6. 打印AI的回复

理解代码结构

让我们详细解释这段代码的每一部分:

  1. 导入Client类from zhipuai import Client
    • 这行代码导入了智谱AI Python SDK中的Client类,它是我们与智谱AI交互的入口。
  2. 初始化客户端client = Client(api_key="YOUR_API_KEY")
    • 这行代码创建了一个Client实例,需要替换成你自己的API密钥。
    • API密钥用于验证你的身份,确保你有权访问智谱AI的服务。
  3. 调用模型client.chat.completions.create(...)
    • 这是发送聊天请求的主要方法。
    • chat.completions.create表示我们要创建一个新的聊天完成(即发送一个聊天请求)。
  4. 指定模型model="glm-4-flash"
    • 这指定了我们要使用GLM-4-Flash模型。
    • 智谱AI可能有多个模型可供选择,这里我们特别选择了免费的GLM-4-Flash模型。
  5. 发送消息messages=[{"role": "user", "content": "你好,世界!"}]
    • 这是一个包含消息的列表,消息以字典形式表示。
    • 每个消息都有一个”role”(角色)和”content”(内容)。
    • “role”可以是”user”(用户)、“assistant”(助手)或”system”(系统),表示消息的来源。
    • 在这个例子中,我们发送了一条用户角色的消息,内容是”你好,世界!”。
  6. 获取并打印回复print("AI的回复:", response.choices[0].message["content"])
    • response包含了AI的回复。
    • response.choices是一个列表,包含了可能的多个回复。
    • 我们取第一个回复(choices[0]),然后获取它的消息内容(message["content"])。
    • 最后,我们打印出AI的回复。

第五部分:创建一个简单的命令行聊天机器人

现在,我们来创建一个更完整的聊天机器人,它可以在命令行中与用户交互。

完整的命令行聊天机器人代码

from zhipuai import Client
# 请替换为你自己的API密钥
API_KEY = "YOUR_API_KEY"
# 初始化客户端
client = Client(api_key=API_KEY)
# 欢迎消息
print("你好!我是一个AI聊天机器人,我可以回答你的问题。")
print("你可以随时输入'退出'来结束对话。")
# 保持对话历史
messages = []
while True:
    # 获取用户输入
    user_input = input("你:")
    
    # 如果用户输入'退出',则结束程序
    if user_input.lower() == "退出":
        print("好的,很高兴与你聊天!再见!")
        break
    
    # 将用户的消息添加到对话历史中
    messages.append({"role": "user", "content": user_input})
    
    # 调用AI模型获取回复
    response = client.chat.completions.create(
        model="glm-4-flash",
        messages=messages
    )
    
    # 获取AI的回复
    ai_response = response.choices[0].message["content"]
    
    # 打印AI的回复
    print("AI:", ai_response)
    
    # 将AI的回复添加到对话历史中
    messages.append({"role": "assistant", "content": ai_response})

这段代码创建了一个简单的命令行聊天机器人,它能够:

  1. 显示欢迎消息
  2. 保持对话历史
  3. 获取用户输入
  4. 调用智谱AI获取回复
  5. 显示AI的回复
  6. 维护对话历史,以便AI能够理解上下文

运行聊天机器人

  1. 将上述代码保存为一个Python文件,比如chatbot.py
  2. 在终端或命令行中运行这个文件:python chatbot.py
  3. 按照提示输入你的消息,与AI进行交流
  4. 输入”退出”结束对话

第六部分:创建图形化界面的AI聊天机器人

现在,我们将升级我们的聊天机器人,给它添加一个图形化界面,使其更加友好和有趣。

安装必要的GUI库

为了创建图形界面,我们需要使用一个GUI库。

PyQt5是一个功能强大的库,适合创建桌面应用程序。我们需要安装它:

pip install pyqt5

完整的GUI聊天机器人代码

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QTextEdit, QPushButton
from PyQt5.QtCore import Qt
from zhipuai import Client
# 请替换为你自己的API密钥
API_KEY = "YOUR_API_KEY"
# 初始化智谱AI客户端
client = Client(api_key=API_KEY)
class ChatBotGUI(QWidget):
    def __init__(self):
        super().__init__()
        
        # 设置窗口标题和大小
        self.setWindowTitle("AI聊天机器人")
        self.setGeometry(100, 100, 600, 400)
        
        # 创建布局
        self.main_layout = QVBoxLayout()
        self.setLayout(self.main_layout)
        
        # 创建聊天区域
        self.chat_area = QTextEdit()
        self.chat_area.setReadOnly(True)
        self.main_layout.addWidget(self.chat_area)
        
        # 创建输入区域和发送按钮
        self.input_layout = QHBoxLayout()
        self.input_text = QTextEdit()
        self.input_text.setMaximumHeight(100)
        self.send_button = QPushButton("发送")
        self.send_button.clicked.connect(self.send_message)
        
        self.input_layout.addWidget(self.input_text)
        self.input_layout.addWidget(self.send_button)
        self.main_layout.addLayout(self.input_layout)
        
        # 保持对话历史
        self.messages = []
        
        # 显示欢迎消息
        self.chat_area.append("你好!我是一个AI聊天机器人,我可以回答你的问题。")
    
    def send_message(self):
        # 获取用户输入
        user_input = self.input_text.toPlainText().strip()
        
        if not user_input:
            return
        
        # 将用户的消息添加到聊天区域
        self.chat_area.append(f"你:{user_input}")
        
        # 将用户的消息添加到对话历史中
        self.messages.append({"role": "user", "content": user_input})
        
        # 调用AI模型获取回复
        response = client.chat.completions.create(
            model="glm-4-flash",
            messages=self.messages
        )
        
        # 获取AI的回复
        ai_response = response.choices[0].message["content"]
        
        # 将AI的回复添加到聊天区域
        self.chat_area.append(f"AI:{ai_response}")
        
        # 将AI的回复添加到对话历史中
        self.messages.append({"role": "assistant", "content": ai_response})
        
        # 清空输入框
        self.input_text.clear()
    
    def keyPressEvent(self, event):
        # 按下回车键时发送消息
        if event.key() == Qt.Key_Return and event.modifiers() == Qt.NoModifier:
            self.send_message()
        else:
            super().keyPressEvent(event)
if __name__ == "__main__":
    app = QApplication(sys.argv)
    chatbot = ChatBotGUI()
    chatbot.show()
    sys.exit(app.exec_())

这段代码创建了一个图形化的聊天机器人界面,它包含:

  1. 一个显示聊天历史的文本区域
  2. 一个用于输入消息的文本框
  3. 一个”发送”按钮
  4. 支持通过回车键发送消息
  5. 自动维护对话历史

运行GUI聊天机器人

  1. 将上述代码保存为一个Python文件,比如gui_chatbot.py
  2. 在终端或命令行中运行这个文件:python gui_chatbot.py
  3. 界面会自动显示,你可以在输入框中输入消息,点击”发送”按钮或按回车键发送
  4. AI会显示在聊天区域中

第七部分:美化你的聊天机器人界面

现在,我们来美化一下聊天机器人界面,让它看起来更加漂亮和专业。

修改样式表

我们可以通过修改PyQt5的样式表来改变界面的外观。

以下是添加样式表后的完整代码:

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QTextEdit, QPushButton
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QTextCursor
from zhipuai import Client
# 请替换为你自己的API密钥
API_KEY = "YOUR_API_KEY"
# 初始化智谱AI客户端
client = Client(api_key=API_KEY)
class ChatBotGUI(QWidget):
    def __init__(self):
        super().__init__()
        
        # 设置窗口标题和大小
        self.setWindowTitle("AI聊天机器人")
        self.setGeometry(100, 100, 600, 400)
        
        # 创建布局
        self.main_layout = QVBoxLayout()
        self.setLayout(self.main_layout)
        
        # 创建聊天区域
        self.chat_area = QTextEdit()
        self.chat_area.setReadOnly(True)
        self.chat_area.setStyleSheet("""
            background-color: #f0f0f0;
            border: 1px solid #ccc;
            border-radius: 8px;
            padding: 10px;
            font-family: Arial, sans-serif;
            font-size: 14px;
            color: #333;
        """)
        self.main_layout.addWidget(self.chat_area)
        
        # 创建输入区域和发送按钮
        self.input_layout = QHBoxLayout()
        self.input_text = QTextEdit()
        self.input_text.setMaximumHeight(100)
        self.input_text.setStyleSheet("""
            background-color: #fff;
            border: 1px solid #ccc;
            border-radius: 8px;
            padding: 10px;
            font-family: Arial, sans-serif;
            font-size: 14px;
            color: #333;
        """)
        self.send_button = QPushButton("发送")
        self.send_button.setStyleSheet("""
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 8px;
            padding: 10px 20px;
            font-family: Arial, sans-serif;
            font-size: 14px;
            cursor: pointer;
        """)
        self.send_button.clicked.connect(self.send_message)
        
        self.input_layout.addWidget(self.input_text)
        self.input_layout.addWidget(self.send_button)
        self.main_layout.addLayout(self.input_layout)
        
        # 保持对话历史
        self.messages = []
        
        # 显示欢迎消息
        self.chat_area.append("你好!我是一个AI聊天机器人,我可以回答你的问题。")
        self.chat_area.moveCursor(QTextCursor.End)
    
    def send_message(self):
        # 获取用户输入
        user_input = self.input_text.toPlainText().strip()
        
        if not user_input:
            return
        
        # 将用户的消息添加到聊天区域
        self.chat_area.append(f"<font color='blue'>你:{user_input}</font>")
        
        # 将用户的消息添加到对话历史中
        self.messages.append({"role": "user", "content": user_input})
        
        # 调用AI模型获取回复
        response = client.chat.completions.create(
            model="glm-4-flash",
            messages=self.messages
        )
        
        # 获取AI的回复
        ai_response = response.choices[0].message["content"]
        
        # 将AI的回复添加到聊天区域
        self.chat_area.append(f"<font color='green'>AI:{ai_response}</font>")
        
        # 将AI的回复添加到对话历史中
        self.messages.append({"role": "assistant", "content": ai_response})
        
        # 清空输入框
        self.input_text.clear()
        
        # 滚动到聊天区域的底部
        self.chat_area.moveCursor(QTextCursor.End)
    
    def keyPressEvent(self, event):
        # 按下回车键时发送消息
        if event.key() == Qt.Key_Return and event.modifiers() == Qt.NoModifier:
            self.send_message()
        else:
            super().keyPressEvent(event)
if __name__ == "__main__":
    app = QApplication(sys.argv)
    chatbot = ChatBotGUI()
    chatbot.show()
    sys.exit(app.exec_())

这个版本的代码添加了样式表,使界面看起来更加现代和美观:

  1. 聊天区域有浅灰色背景
  2. 用户消息显示为蓝色
  3. AI消息显示为绿色
  4. 按钮有绿色背景,看起来像一个现代按钮
  5. 所有文本使用Arial字体,大小为14px

第八部分:添加错误处理和API限制提示

为了使聊天机器人更加健壮和用户友好,我们需要添加错误处理和API限制提示。

完整代码(包含错误处理)

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QTextEdit, QPushButton, QMessageBox
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QTextCursor
from zhipuai import Client
import traceback
# 请替换为你自己的API密钥
API_KEY = "YOUR_API_KEY"
# 初始化智谱AI客户端
client = Client(api_key=API_KEY)
class ChatBotGUI(QWidget):
    def __init__(self):
        super().__init__()
        
        # 设置窗口标题和大小
        self.setWindowTitle("AI聊天机器人")
        self.setGeometry(100, 100, 600, 400)
        
        # 创建布局
        self.main_layout = QVBoxLayout()
        self.setLayout(self.main_layout)
        
        # 创建聊天区域
        self.chat_area = QTextEdit()
        self.chat_area.setReadOnly(True)
        self.chat_area.setStyleSheet("""
            background-color: #f0f0f0;
            border: 1px solid #ccc;
            border-radius: 8px;
            padding: 10px;
            font-family: Arial, sans-serif;
            font-size: 14px;
            color: #333;
        """)
        self.main_layout.addWidget(self.chat_area)
        
        # 创建输入区域和发送按钮
        self.input_layout = QHBoxLayout()
        self.input_text = QTextEdit()
        self.input_text.setMaximumHeight(100)
        self.input_text.setStyleSheet("""
            background-color: #fff;
            border: 1px solid #ccc;
            border-radius: 8px;
            padding: 10px;
            font-family: Arial, sans-serif;
            font-size: 14px;
            color: #333;
        """)
        self.send_button = QPushButton("发送")
        self.send_button.setStyleSheet("""
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 8px;
            padding: 10px 20px;
            font-family: Arial, sans-serif;
            font-size: 14px;
            cursor: pointer;
        """)
        self.send_button.clicked.connect(self.send_message)
        
        self.input_layout.addWidget(self.input_text)
        self.input_layout.addWidget(self.send_button)
        self.main_layout.addLayout(self.input_layout)
        
        # 保持对话历史
        self.messages = []
        
        # 显示欢迎消息
        self.chat_area.append("你好!我是一个AI聊天机器人,我可以回答你的问题。")
        self.chat_area.moveCursor(QTextCursor.End)
    
    def send_message(self):
        try:
            # 获取用户输入
            user_input = self.input_text.toPlainText().strip()
            
            if not user_input:
                return
            
            # 将用户的消息添加到聊天区域
            self.chat_area.append(f"<font color='blue'>你:{user_input}</font>")
            
            # 将用户的消息添加到对话历史中
            self.messages.append({"role": "user", "content": user_input})
            
            # 调用AI模型获取回复
            response = client.chat.completions.create(
                model="glm-4-flash",
                messages=self.messages
            )
            
            # 获取AI的回复
            ai_response = response.choices[0].message["content"]
            
            # 将AI的回复添加到聊天区域
            self.chat_area.append(f"<font color='green'>AI:{ai_response}</font>")
            
            # 将AI的回复添加到对话历史中
            self.messages.append({"role": "assistant", "content": ai_response})
            
            # 清空输入框
            self.input_text.clear()
            
            # 滚动到聊天区域的底部
            self.chat_area.moveCursor(QTextCursor.End)
            
        except Exception as e:
            # 显示错误消息
            error_message = f"发生了一个错误:{str(e)}"
            self.chat_area.append(f"<font color='red'>[错误] {error_message}</font>")
            
            # 显示详细的错误信息在消息框中
            detailed_error = traceback.format_exc()
            QMessageBox.critical(self, "错误", f"{error_message}\n\n详细信息:\n{detailed_error}")
    
    def keyPressEvent(self, event):
        # 按下回车键时发送消息
        if event.key() == Qt.Key_Return and event.modifiers() == Qt.NoModifier:
            self.send_message()
        else:
            super().keyPressEvent(event)
if __name__ == "__main__":
    app = QApplication(sys.argv)
    chatbot = ChatBotGUI()
    chatbot.show()
    sys.exit(app.exec_())

这个版本的代码添加了错误处理机制:

  1. 使用try-except块捕获可能发生的错误
  2. 在聊天区域显示红色的错误消息
  3. 使用 QMessageBox 显示详细的错误信息
  4. 使用traceback模块获取详细的错误堆栈信息

第九部分:添加API调用限制提示

智谱AI的API可能有一些调用限制,特别是对于免费版本。

我们需要向用户提示这些限制。

完整代码(包含API限制提示)

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QTextEdit, QPushButton, QMessageBox
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QTextCursor
from zhipuai import Client
import traceback
# 请替换为你自己的API密钥
API_KEY = "YOUR_API_KEY"
# 初始化智谱AI客户端
client = Client(api_key=API_KEY)
class ChatBotGUI(QWidget):
    def __init__(self):
        super().__init__()
        
        # 设置窗口标题和大小
        self.setWindowTitle("AI聊天机器人")
        self.setGeometry(100, 100, 600, 400)
        
        # 创建布局
        self.main_layout = QVBoxLayout()
        self.setLayout(self.main_layout)
        
        # 创建聊天区域
        self.chat_area = QTextEdit()
        self.chat_area.setReadOnly(True)
        self.chat_area.setStyleSheet("""
            background-color: #f0f0f0;
            border: 1px solid #ccc;
            border-radius: 8px;
            padding: 10px;
            font-family: Arial, sans-serif;
            font-size: 14px;
            color: #333;
        """)
        self.main_layout.addWidget(self.chat_area)
        
        # 创建输入区域和发送按钮
        self.input_layout = QHBoxLayout()
        self.input_text = QTextEdit()
        self.input_text.setMaximumHeight(100)
        self.input_text.setStyleSheet("""
            background-color: #fff;
            border: 1px solid #ccc;
            border-radius: 8px;
            padding: 10px;
            font-family: Arial, sans-serif;
            font-size: 14px;
            color: #333;
        """)
        self.send_button = QPushButton("发送")
        self.send_button.setStyleSheet("""
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 8px;
            padding: 10px 20px;
            font-family: Arial, sans-serif;
            font-size: 14px;
            cursor: pointer;
        """)
        self.send_button.clicked.connect(self.send_message)
        
        self.input_layout.addWidget(self.input_text)
        self.input_layout.addWidget(self.send_button)
        self.main_layout.addLayout(self.input_layout)
        
        # 保持对话历史
        self.messages = []
        
        # 显示欢迎消息和API限制
        self.chat_area.append("你好!我是一个AI聊天机器人,我可以回答你的问题。")
        self.chat_area.append("<font color='gray'>[提示] 这个聊天机器人使用智谱AI的GLM-4-Flash模型,属于免费版本,可能会有调用限制。</font>")
        self.chat_area.append("<font color='gray'>[提示] 请合理使用,避免频繁调用。</font>")
        self.chat_area.moveCursor(QTextCursor.End)
    
    def send_message(self):
        try:
            # 获取用户输入
            user_input = self.input_text.toPlainText().strip()
            
            if not user_input:
                return
            
            # 将用户的消息添加到聊天区域
            self.chat_area.append(f"<font color='blue'>你:{user_input}</font>")
            
            # 将用户的消息添加到对话历史中
            self.messages.append({"role": "user", "content": user_input})
            
            # 调用AI模型获取回复
            response = client.chat.completions.create(
                model="glm-4-flash",
                messages=self.messages
            )
            
            # 获取AI的回复
            ai_response = response.choices[0].message["content"]
            
            # 将AI的回复添加到聊天区域
            self.chat_area.append(f"<font color='green'>AI:{ai_response}</font>")
            
            # 将AI的回复添加到对话历史中
            self.messages.append({"role": "assistant", "content": ai_response})
            
            # 清空输入框
            self.input_text.clear()
            
            # 滚动到聊天区域的底部
            self.chat_area.moveCursor(QTextCursor.End)
            
        except Exception as e:
            # 显示错误消息
            error_message = f"发生了一个错误:{str(e)}"
            self.chat_area.append(f"<font color='red'>[错误] {error_message}</font>")
            
            # 显示详细的错误信息在消息框中
            detailed_error = traceback.format_exc()
            QMessageBox.critical(self, "错误", f"{error_message}\n\n详细信息:\n{detailed_error}")
    
    def keyPressEvent(self, event):
        # 按下回车键时发送消息
        if event.key() == Qt.Key_Return and event.modifiers() == Qt.NoModifier:
            self.send_message()
        else:
            super().keyPressEvent(event)
if __name__ == "__main__":
    app = QApplication(sys.argv)
    chatbot = ChatBotGUI()
    chatbot.show()
    sys.exit(app.exec_())

这个版本的代码添加了API限制提示:

  1. 在欢迎消息中添加了关于API限制的灰色提示信息
  2. 提醒用户这是一个免费版本,可能会有调用限制
  3. 建议用户合理使用,避免频繁调用

第十部分:测试和优化你的聊天机器人

现在,你的AI聊天机器人已经完成了!是时候进行测试和优化了。

测试聊天机器人

  1. 运行你的聊天机器人应用程序
  2. 输入一些简单的问题,比如”你好”、”今天天气怎么样”等
  3. 观察AI的回复是否合理
  4. 测试错误处理功能是否正常工作
  5. 尝试达到API的调用限制,看看程序是否能够优雅地处理

优化聊天机器人

根据测试结果,你可以考虑以下优化:

  1. 添加输入验证,确保用户输入的内容有意义
  2. 实现API调用的节流,避免达到调用限制
  3. 添加缓存机制,减少重复调用
  4. 实现多线程,避免界面在等待API响应时冻结
  5. 添加更多样式,使界面更加美观
  6. 实现消息的语音朗读功能
  7. 添加更多的交互功能,比如文件上传等

结论

通过这个教程,你已经学会了如何使用Python调用智谱AI的免费大模型GLM-4-Flash,并创建了一个图形化界面的AI聊天机器人。

这个项目不仅能够帮助你学习Python编程和AI应用开发,还能让你体验如何与大语言模型进行交互。
希望你喜欢这个教程!

继续探索和学习,你可以通过添加更多功能和改进界面,使你的聊天机器人更加完善。

记得始终遵循API提供商的使用条款,并合理使用免费资源。
如果你有任何问题或建议,欢迎随时告诉我!

让我们一起探索AI世界的无限可能!

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。