使用 GPT-4-turbo+Streamlit+wiki+calculator构建Math Agents应用【Step by Step】

  • 💖 Brief:大家好,我是Zeeland。Tags: 大模型创业、LangChain Top Contributor、算法工程师、Promptulate founder、Python开发者。
  • 📝 CSDN主页:Zeeland🔥
  • 📣 个人说明书:Zeeland
  • 📣 个人网站:https://me.zeeland.cn/
  • 📚 Github主页: Undertone0809 (Zeeland)
  • 🎉 支持我:点赞👍+收藏⭐️+留言📝 我会定期在博客、个人说明书、论坛中做一些技术分享。也欢迎大家阅读我的个人说明书,大家可以在这里快速了解我和我做过的事情,期待和你交个朋友,有机会我们一起做一些有意思的事情

Introduction

本文将介绍GPT-4-turbo+Streamlit+wiki+calculator+Promptulate构建Math Agents应用,使用 Agent 进行推理,解决数学问题。

如果你想直接获取代码,可以从https://github.com/Undertone0809/promptulate/tree/main/example/build-math-application-with-agent 获取。

也可以点击https://github.com/Undertone0809/promptulate/fork fork 更多 examples 到自己的仓库里学习。

Summary

本文详细介绍了如何结合GPT-4-turbo、Streamlit、Wikipedia API、计算器功能以及Promptulate框架,构建一个名为“Math Wiz”的数学辅助应用。这个应用旨在帮助用户解决数学问题或逻辑/推理问题。通过这个项目,我们展示了如何利用Promptulate框架中的Agent进行推理,以及如何使用不同的工具来处理用户的查询。

关键步骤总结:

  • 环境搭建:创建了一个新的conda环境,并安装了所有必要的库,包括Promptulate、Wikipedia和numexpr。
  • 应用流程:设计了一个应用流程,其中包含了一个能够利用不同工具(如Wikipedia工具、计算器工具和推理工具)来回答用户查询的Agent。这个Agent使用大型语言模型(LLM)作为其“大脑”,指导它的决策。
  • 理解Promptulate Agent:介绍了Promptulate Agent的概念,这是一个设计用来与语言模型进行更复杂和交互式任务的接口。

逐步实现:

  • 创建了chatbot.py脚本并导入了必要的依赖。
  • 定义了基于OpenAI的语言模型。
  • 创建了三个工具:Wikipedia工具、计算器工具和推理工具。
  • 初始化了Agent,并指定了LLM来帮助它选择使用哪些工具及其顺序。
  • 创建Streamlit应用:使用Streamlit框架来构建应用的前端界面,允许用户输入问题并接收Agent的回答。

测试案例:

  • 通过几个测试案例,展示了“Math Wiz”应用如何处理不同类型的数学和逻辑问题,包括算术运算、历史事实查询和逻辑推理等。

Building a Math Application with promptulate Agents

This demo is how to use promptulates agents to create a custom Math application utilising OpenAI’s GPT3.5 Model.
For the application frontend, there will be using streamlit, an easy-to-use open-source Python framework.
This generative math application, let’s call it “Math Wiz”, is designed to help users with their math or reasoning/logic questions.

Environment Setup

We can start off by creating a new conda environment with python=3.11:conda create -n math_assistant python=3.11

Activate the environment:conda activate math_assistant

Next, let’s install all necessary libraries:
pip install -U promptulate
pip install wikipedia
pip install numexpr

Sign up at OpenAI and obtain your own key to start making calls to the gpt model. Once you have the key, create a .env file in your repository and store the OpenAI key:

OPENAI_API_KEY="your_openai_api_key"

Application Flow

The application flow for Math Wiz is outlined in the flowchart below. The agent in our pipeline will have a set of tools at its disposal that it can use to answer a user query. The Large Language Model (LLM) serves as the “brain” of the agent, guiding its decisions. When a user submits a question, the agent uses the LLM to select the most appropriate tool or a combination of tools to provide an answer. If the agent determines it needs multiple tools, it will also specify the order in which the tools are used.

The application flow for Math Wiz is outlined below:

The agent in our pipeline will have a set of tools at its disposal that it can use to answer a user query. The Large Language Model (LLM) serves as the “brain” of the agent, guiding its decisions. When a user submits a question, the agent uses the LLM to select the most appropriate tool or a combination of tools to provide an answer. If the agent determines it needs multiple tools, it will also specify the order in which the tools are used.

The agent for our Math Wiz app will be using the following tools:

  1. Wikipedia Tool: this tool will be responsible for fetching the latest information from Wikipedia using the Wikipedia API. While there are paid tools and APIs available that can be integrated inside Promptulate, I would be using Wikipedia as the app’s online source of information.

  2. Calculator Tool: this tool would be responsible for solving a user’s math queries. This includes anything involving numerical calculations. For example, if a user asks what the square root of 4 is, this tool would be appropriate.

  3. Reasoning Tool: the final tool in our application setup would be a reasoning tool, responsible for tackling logical/reasoning-based user queries. Any mathematical word problems should also be handled with this tool.

Now that we have a rough application design, we can begin thinking about building this application.

Understanding promptulate Agents

Promptulate agents are designed to enhance interaction with language models by providing an interface for more complex and interactive tasks. We can think of an agent as an intermediary between users and a large language model. Agents seek to break down a seemingly complex user query, that our LLM might not be able to tackle on its own, into easier, actionable steps.

In our application flow, we defined a few different tools that we would like to use for our math application. Based on the user input, the agent should decide which of these tools to use. If a tool is not required, it should not be used. Promptulate agents can simplify this for us. These agents use a language model to choose a sequence of actions to take. Essentially, the LLM acts as the “brain” of the agent, guiding it on which tool to use for a particular query, and in which order. This is different from Proptulate chains where the sequence of actions are hardcoded in code. Promptulate offers a wide set of tools that can be integrated with an agent. These tools include, and are not limited to, online search tools, API-based tools, chain-based tools etc. For more information on Promptulate agents and their types, see this.

Step-by-Step Implementation

Step 1

Create a chatbot.py script and import the necessary dependencies:

from promptulate.llms import ChatOpenAI
from promptulate.tools.wikipedia.tools import wikipedia_search
from promptulate.tools.math.tools import calculator
import promptulate as pne

Step 2

Next, we will define our OpenAI-based Language Model.The architectural design of promptulate is easily compatible with different large language model extensions. In promptulate, llm is responsible for the most basic part of content generation, so it is the most basic component.By default, ChatOpenAI in promptulate uses the gpt-3.5-turbo model.

llm = pne.LLMFactory.build(model_name="gpt-4-turbo", model_config={"temperature": 0.5})

We would be using this LLM both within our math and reasoning process and as the decision maker for our agent.

Step 3

When constructing your own agent, you will need to provide it with a list of tools that it can use. Difine a tool, the only you need to do is to provide a function to Promptulate. Promptulate will automatically convert it to a tool that can be used by the language learning model (LLM). The final presentation result it presents to LLM is an OpenAI type JSON schema declaration.

Actually, Promptulate will analysis function name, parameters type, parameters attribution, annotations and docs when you provide the function. We strongly recommend that you use the official best practices of Template for function writing. The best implementation of a function requires adding type declarations to its parameters and providing function level annotations. Ideally, declare the meaning of each parameter within the annotations.

We will now create our three tools. The first one will be the online tool using the Wikipedia API wrapper:

# Wikipedia Tool
def wikipedia_tool(keyword: str) -> str:"""search by keyword in web.A useful tool for searching the Internet to find information on world events,issues, dates,years, etc. Worth using for general topics. Use precise questions.Args:keyword: keyword to searchReturns:str: search result"""return wikipedia_search(keyword)

Next, let’s define the tool that we will be using for calculating any numerical expressions. Promptulate offers the calculator which uses the numexpr Python library to calculate mathematical expressions. It is also important that we clearly define what this tool would be used for. The description can be helpful for the agent in deciding which tool to use from a set of tools for a particular user query.

# calculator tool for arithmetics
def math_tool(expression: str):"""Useful for when you need to answer questions about math. This tool is onlyfor math questions and nothing else. Only input math expressions.Args:expression: A mathematical expression, eg: 18^0.43Attention:Expressions can not exist variables!eg: (current age)^0.43 is wrong, you should use 18^0.43 instead.Returns:The result of the evaluation."""return calculator(expression)

Finally, we will be defining the tool for logic/reasoning-based queries. We will first create a prompt to instruct the model with executing the specific task. Then we will create a simple AssistantMessage for this tool, passing it the LLM and the prompt.

# reasoning based tool
def word_problem_tool(question: str) -> str:"""Useful for when you need to answer logic-based/reasoning questions.Args:question(str): Detail question, the description of the problem requires adetailed question context. Include a description of the problemReturns:question answer"""system_prompt: str = """You are a reasoning agent tasked with solving t he user's logic-based questions.Logically arrive at the solution, and be factual.In your answers, clearly detail the steps involved and give the final answer.Provide the response in bullet points."""  # noqallm = ChatOpenAI()return llm(f"{system_prompt}\n\nQuestion:{question}Answer:")

Step 4

We will now initialize our agent with the tools we have created above. We will also specify the LLM to help it choose which tools to use and in what order:

# agent
agent = pne.ToolAgent(tools=[wikipedia_tool, math_tool, word_problem_tool],llm=llm)resp: str = agent.run("I have 3 apples and 4 oranges.I give half of my oranges away and buy two dozen new ones,along with three packs of strawberries.Each pack of strawberry has 30 strawberries.How many total pieces of fruit do I have at the end?")
print(resp)
[31;1m[1;3m[Agent] Tool Agent start...[0m
[36;1m[1;3m[User instruction] I have 3 apples and 4 oranges.I give half of my oranges away and buy two dozen new ones,along with three packs of strawberries.Each pack of strawberry has 30 strawberries.How many total pieces of fruit do I have at the end?[0m
[33;1m[1;3m[Thought] I should break down the problem step by step and calculate the total number of fruits at the end.[0m
[33;1m[1;3m[Action] word_problem_tool args: {'question': 'I have 3 apples and 4 oranges. I give half of my oranges away and buy two dozen new ones, along with three packs of strawberries. Each pack of strawberry has 30 strawberries. How many total pieces of fruit do I have at the end?'}[0m
[33;1m[1;3m[Observation] To solve this problem, we can break it down into steps and calculate the total number of fruit pieces you have at the end:Initial fruits:
- 3 apples
- 4 orangesGiving away half of the oranges:
- You have 4 oranges, so you give away 4/2 = 2 oranges.
- After giving away 2 oranges, you have 4 - 2 = 2 oranges remaining.Buying new fruits:
- You buy 2 dozen new oranges, where 1 dozen is equal to 12.
- 2 dozen oranges is 2 * 12 = 24 oranges.
- You also buy 3 packs of strawberries, with each pack having 30 strawberries.
- Total strawberries bought = 3 * 30 = 90 strawberries.Calculating total fruit pieces at the end:
- After giving away half of your oranges, you have 2 oranges left.
- Adding the new oranges bought, you have a total of 2 + 24 = 26 oranges.
- You initially had 3 apples, so the total apples remain 3.
- You bought 90 strawberries.
- Total fruits at the end = Total oranges + Total apples + Total strawberries
- Total fruits = 26 oranges + 3 apples + 90 strawberries = 26 + 3 + 90 = 119 pieces of fruitTherefore, at the end of the scenario, you have a total of 119 pieces of fruit.[0m
[32;1m[1;3m[Agent Result] You have a total of 119 pieces of fruit at the end of the scenario.[0m
[38;5;200m[1;3m[Agent] Agent End.[0m
You have a total of 119 pieces of fruit at the end of the scenario.

The app’s response to a logic question is following:

Creating streamlit application

We will be using Streamlit, an open-source Python framework, to build our application. With Streamlit, you can build conversational AI applications with a few simple lines of code. Using streamlit to build the demo of application is demonstrated in the peer child file chabot.py of the notebook file. You can run the file directly with the command streamlit run chatbot.py to view the effect and debug the web page.

Let’s begin by importing the Streamlit package to our chatbot.py script: pip install Streamlit == 1.28

import streamlit as st

Then,let’s build a lifecycle class to display the intermediate state of the agent response on the chat page.If you want to learn more about the life cycle, please click here

from promptulate.hook import Hook, HookTableclass MidStepOutHook:@staticmethoddef handle_agent_revise_plan(*args, **kwargs):messages = f"[Revised Plan] {kwargs['revised_plan']}"st.chat_message("assistant").write(messages)@staticmethoddef handle_agent_action(*args, **kwargs):messages = f"[Thought] {kwargs['thought']}\n"messages += f"[Action] {kwargs['action']} args: {kwargs['action_input']}"st.chat_message("assistant").write(messages)@staticmethoddef handle_agent_observation(*args, **kwargs):messages = f"[Observation] {kwargs['observation']}"st.chat_message("assistant").write(messages)@staticmethoddef registry_hooks():"""Registry and enable stdout hooks. StdoutHook can print colorfulinformation."""Hook.registry_hook(HookTable.ON_AGENT_REVISE_PLAN,MidStepOutHook.handle_agent_revise_plan,"component",)Hook.registry_hook(HookTable.ON_AGENT_ACTION, MidStepOutHook.handle_agent_action, "component")Hook.registry_hook(HookTable.ON_AGENT_OBSERVATION,MidStepOutHook.handle_agent_observation,"component",)

Next,Let’s build a function,and We will be adding our LLM, tools and agent initialization code to this function.

def build_agent(api_key: str) -> pne.ToolAgent:MidStepOutHook.registry_hooks()# calculator tool for arithmeticsdef math_tool(expression: str):"""Useful for when you need to answer questions about math. This tool is onlyfor math questions and nothing else. Only input math expressions.Args:expression: A mathematical expression, eg: 18^0.43Attention:Expressions can not exist variables!eg: (current age)^0.43 is wrong, you should use 18^0.43 instead.Returns:The result of the evaluation."""return calculator(expression)# reasoning based tooldef word_problem_tool(question: str) -> str:"""Useful for when you need to answer logic-based/reasoning questions.Args:question(str): Detail question, the description of the problem requires adetailed question context. Include a description of the problemReturns:question answer"""system_prompt: str = """You are a reasoning agent tasked with solving t he user's logic-based questions.Logically arrive at the solution, and be factual.In your answers, clearly detail the steps involved and give the final answer.Provide the response in bullet points."""  # noqallm = ChatOpenAI(private_api_key=api_key)return llm(f"{system_prompt}\n\nQuestion:{question}Answer:")# Wikipedia Tooldef wikipedia_tool(keyword: str) -> str:"""search by keyword in web.A useful tool for searching the Internet to find information on world events,issues, dates,years, etc. Worth using for general topics. Use precise questions.Args:keyword: keyword to searchReturns:str: search result"""return wikipedia_search(keyword)llm = ChatOpenAI(model="gpt-4-1106-preview", private_api_key=api_key)return pne.ToolAgent(tools=[wikipedia_tool, math_tool, word_problem_tool], llm=llm)

Set the style of our application

# Create a sidebar to place the user parameter configuration
with st.sidebar:openai_api_key = st.text_input("OpenAI API Key", key="chatbot_api_key", type="password")"[Get an OpenAI API key](https://platform.openai.com/account/api-keys)""[View the source code](https://github.com/hizeros/llm-streamlit/blob/master/Chatbot.py)"  # noqa# Set title
st.title("💬 Math Wiz")
st.caption("🚀 Hi there! 👋 I am a reasoning tool by Promptulate to help you ""with your math or logic-based reasoning questions.")

Next, check our session state and render the user input and agent response to the chat page, so that we successfully build a simple math application using streamlit

# Determine whether to initialize the message variable
# otherwise initialize a message dictionary
if "messages" not in st.session_state:st.session_state["messages"] = [{"role": "assistant", "content": "How can I help you?"}]# Traverse messages in session state
for msg in st.session_state.messages:st.chat_message(msg["role"]).write(msg["content"])# User input
if prompt := st.chat_input():if not openai_api_key:st.info("Please add your OpenAI API key to continue.")st.stop()agent: pne.ToolAgent = build_agent(api_key=openai_api_key)# Add the message entered by the user to the list of messages in the session statest.session_state.messages.append({"role": "user", "content": prompt})# Display in the chat interfacest.chat_message("user").write(prompt)response: str = agent.run(prompt)st.session_state.messages.append({"role": "assistant", "content": response})st.chat_message("assistant").write(response)

Let’s try to run it:streamlit run chatbot.py
The running result is as follows:

Examples of other questions are given below for testing reference:

  1. Question 1
    • I have 3 apples and 4 oranges.I give half of my oranges away and buy two dozen new ones,along with three packs of strawberries.Each pack of strawberry has 30 strawberries.How many total pieces of fruit do I have at the end?
    • correct answer = 119
  2. Question 2
    • What is the cube root of 625?
    • correct answer = 8.5498
  3. Question 3
    • what is cube root of 81? Multiply with 13.27, and subtract 5.
    • correct answer = 52.4195
  4. Question 4
    • Steve’s sister is 10 years older than him. Steve was born when the cold war
      ended. When was Steve’s sister born?
    • correct answer = 1991 - 10 = 1981
  5. Question 5
    • Tell me the year in which Tom Cruise’s Top Gun was released, and calculate the square of that year.
    • correct answer = 1986**2 = 3944196

Summary

本项目展示了如何利用当前的AI技术和工具来构建一个实用的数学辅助应用。“Math Wiz”能够处理从简单的数学计算到复杂的逻辑推理问题,是一个结合了多种技术的创新示例。通过这个应用,用户可以得到快速准确的数学问题解答,同时也展示了人工智能在教育和日常生活中的潜力。

对于希望深入了解或自行构建此类应用的开发者,本文提供的详细步骤和代码示例是一个宝贵的资源。此外,通过提供的GitHub链接,读者可以直接访问完整的代码,进一步探索和修改以满足特定的需求或兴趣。

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

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

相关文章

蓝桥杯单片机之模块代码《AT24C02》

过往历程 历程1:秒表 历程2:按键显示时钟 历程3:列矩阵按键显示时钟 历程4:行矩阵按键显示时钟 历程5:新DS1302 历程6:小数点精确后两位ds18b20 历程7:35定时器测量频率 文章目录 过往历…

Android Studio查看xml文件的修改时间和记录

Android Studio查看xml文件的修改时间和记录 Android Studio里面如果是Java/Kotlin编写界面,可以点击函数开头上面的提交在直接,然后在编辑界面的左侧查看历史时间上的修改记录,但是xml文件里面没有直观的这样操作方式。 但xml里面可以通过快…

使用xshell工具连接ubuntu的root账户被拒绝的解决方法

问题描述: 我在使用xshell工具远程连接Ubuntu虚拟机的过程中,如果连接的是的普通用户则xshell工具可以正常连接,但是当我向连接ubuntu系统的root用户,即便是密码输入正确但还是不能连接成功。不能连接成功的截图如下: …

每日两题 / 138. 随机链表的复制 148. 排序链表(LeetCode热题100)

138. 随机链表的复制 - 力扣(LeetCode) 用哈希表记录原链表中的节点是否被复制过 遍历原链表并通过哈希表维护新链表 /* // Definition for a Node. class Node { public:int val;Node* next;Node* random;Node(int _val) {val _val;next NULL;rand…

python网络爬虫学习——编写一个网络爬虫

参考资料:用Python写网络爬虫(第2版) 1、编写一个函数 (1)用于下载网页,且当下载网页发生错误时能及时报错。 # 导入库 import urllib.request from urllib.error import URLError,HTTPError,ContentTooS…

什么是web3D?应用场景有哪些?如何实现web3D展示?

Web3D是一种将3D技术与网络技术完美结合的全新领域,它可以实现将数字化的3D模型直接在网络浏览器上运行,从而实现在线交互式的浏览和操作。 Web3D通过将多媒体技术、3D技术、信息网络技术、计算机技术等多种技术融合在一起,实现了它在网络上…

js宏任务微任务输出解析

第一种情况 setTimeout(function () {console.log(setTimeout 1) //11 宏任务new Promise(function (resolve) {console.log(promise 1) //12 同步函数resolve()}).then(function () {console.log(promise then) //13 微任务})})async function async1() {console.log(async1 s…

【Pytorch】5.DataLoder的使用

什么是DataLoader 个人理解是,如果Dataset的所有数据相当于一副扑克牌,DataLoader就相当于从扑克牌中抽取几张,我们可以规定一次抽取的张数,或者以什么规则进行抽取 DataLoader的使用 查阅官网的文档,主要有这几个参数…

c#教程——索引器

前言: 索引器(Indexer)可以像操作数组一样来访问对象的元素。它允许你使用索引来访问对象中的元素,就像使用数组索引一样。在C#中,索引器的定义方式类似于属性,但具有类似数组的访问方式。 索引器&#x…

[Kubernetes] Rancher 2.7.5 部署 k8s

server: 192.168.66.100 master: 192.168.66.101 node1: 192.168.66.102 文章目录 1.rancher server 安装docker2.部署k8s3.kubeconfig 1.rancher server 安装docker 所有主机开通ipv4 vi /etc/sysctl.conf#加入 net.ipv4.ip_forward 1#配置生效 sysctl -prancher-server开通…

探秘WebSQL:轻松构建前端数据库

欢迎来到我的博客,代码的世界里,每一行都是一个故事 探秘WebSQL:轻松构建前端数据库 前言WebSQL简介WebSQL的基本操作WebSQL的实际应用WebSQL的局限性和替代方案 前言 在Web的世界里,我们总是追求更好的用户体验和更快的响应速度…

k8s 资源文件参数介绍

Kubernetes资源文件yaml参数介绍 yaml 介绍 yaml 是一个类似 XML、JSON 的标记性语言。它强调以数据为中心,并不是以标识语言为重点例如 SpringBoot 的配置文件 application.yml 也是一个 yaml 格式的文件 语法格式 通过缩进表示层级关系不能使用tab进行缩进&am…

02-Fortran基础--Fortran操作符与控制结构

02-Fortran基础--Fortran操作符与控制结构 0 引言1 操作符1.1 数学运算符1.2 逻辑运算符1.3 关系运算符 2 控制流程2.1 条件结构2.2 循环结构2.3 分支结构 0 引言 运算符和控制流程对编程语言是必须的,Fortran的操作符和控制流程涉及到各种数学运算符、逻辑运算符以及控制结构。…

Python高级编程-DJango2

Python高级编程-DJango2 没有清醒的头脑,再快的脚步也会走歪;没有谨慎的步伐,再平的道路也会跌倒。 目录 Python高级编程-DJango2 1.显示基本网页 2.输入框的形式: 1)文本输入框 2)单选框 3&#xff…

elementui+vue通过下拉框多选字段进行搜索模糊匹配

从字典中选择的值为["01","03"],在最开始的时候进行的处理是类似于表单提交的时候将json对象转换成了String类型 nature:["01","03"] this.queryParams.nature JSON.stringify(this.queryParams.nature); mapper层 <if test&quo…

截图工具Snipaste:不仅仅是截图,更是效率的提升

在数字时代&#xff0c;截图工具已成为我们日常工作和生活中不可或缺的一部分。无论是用于工作汇报、学习笔记&#xff0c;还是日常沟通&#xff0c;一款好用的截图工具都能大大提升我们的效率。今天&#xff0c;我要向大家推荐一款功能强大且易于使用的截图软件——Snipaste。…

Pycharm无法链接服务器环境(host is unresponsived)

困扰了很久的一个问题&#xff0c;一开始是在服务器ubuntu20.04上安装pycharm community&#xff0c;直接运行服务器上的pycharm community就识别不了anaconda中的环境 后来改用pycharm professional也无法远程连接上服务器的环境&#xff0c;识别不了服务器上的环境&#xff…

关系型数据库MySQL开发要点之多表设计案例详解代码实现

什么是多表设计 项目开发中 在进行数据库表结构设计时 根据数据模型和业务关系 会根据业务需求和业务模块之间的关系分析设计表结构 由于业务之间互相关联 所以表结构之间也存在着各种联系 主要分为以下三种 一对多 每个部门下是有多个员工的 但是一个员工只能归属一个部…

【C/C++】设计模式——单例模式

创作不易&#xff0c;本篇文章如果帮助到了你&#xff0c;还请点赞 关注支持一下♡>&#x16966;<)!! 主页专栏有更多知识&#xff0c;如有疑问欢迎大家指正讨论&#xff0c;共同进步&#xff01; &#x1f525;c系列专栏&#xff1a;C/C零基础到精通 &#x1f525; 给大…

类加载器aa

一&#xff0c;关系图及各自管辖范围 &#xff08;不赘述&#xff09; 二&#xff0c;查看关系 package com.jiazai;public class Main {public static void main(String[] args) {ClassLoader appClassLoader ClassLoader.getSystemClassLoader();//默认System.out.println…