使用 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:
-
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.
-
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.
-
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:
- 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
- Question 2
- What is the cube root of 625?
- correct answer = 8.5498
- Question 3
- what is cube root of 81? Multiply with 13.27, and subtract 5.
- correct answer = 52.4195
- 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
- Steve’s sister is 10 years older than him. Steve was born when the cold war
- 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链接,读者可以直接访问完整的代码,进一步探索和修改以满足特定的需求或兴趣。
相关文章:
使用 GPT-4-turbo+Streamlit+wiki+calculator构建Math Agents应用【Step by Step】
💖 Brief:大家好,我是Zeeland。Tags: 大模型创业、LangChain Top Contributor、算法工程师、Promptulate founder、Python开发者。📝 CSDN主页:Zeeland🔥📣 个人说明书:Zeeland&…...
[240514] OpenAI 发布 GPT-4o,人机交互的历史性时刻 | 苹果芯片进军服务器剑指AI | 谷歌大会以AI为主
目录 OpenAI 发布 GPT-4o,人机交互的历史时刻苹果芯片进军服务器,剑指生成式 AI2024年谷歌开发者大会将围绕 AI 展开 OpenAI 发布 GPT-4o,人机交互的历史时刻 OpenAI 发布了 GPT-4o,大家一直都想要现在终于等到的语音助手 : 勿需…...
Maximo 在 Automation Script 中访问数据库
在 Automation Script 中我们通常使用 mbo 对象来操作数据,但有时候当数据量较大时,使用 mbo 对象来操作数据会比较慢。这时候,我们可以使用 JDBC 的方式来直接访问数据库,从而提高操作数据的效率。 下面看看使用 JavaScript 脚本…...
gitee 简易使用 上传文件
Wiki - Gitee.com 官方教程 1.gitee 注册帐号 (直接选择初始化选项即可,无需下载git) 2.下载git 安装 http://git-scm.com/downloads 3. 桌面 鼠标右键 或是开始菜单 open git bash here 输入(复制 ,粘贴) 运行…...
iOS Xcode 升级Xcode15报错: SDK does not contain ‘libarclite
一 iOS Xcode 升级Xcode15报错: SDK does not contain libarclite 1.1 报错信息 SDK does not contain libarclite at the path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/ lib/arc/libarclite_iphonesimulator.a; try increasin…...
即插即用篇 | YOLOv8引入轴向注意力 Axial Attention | 多维变换器中的轴向注意力
本改进已集成到 YOLOv8-Magic 框架。 我们提出了Axial Transformers,这是一个基于自注意力的自回归模型,用于图像和其他组织为高维张量的数据。现有的自回归模型要么因高维数据的计算资源需求过大而受到限制,要么为了减少资源需求而在分布表达性或实现的便捷性上做出妥协。相…...
【芯片制造】【常用术语】CP、FT、WAT
背景: 在我们讲wafer加工好以后,需要进行相关测试,在此阶段,有很多提及到的常用术语,我们依次进行解释。主要单词含义: CP : Chip Probing(probe card),wafer…...
计算机vcruntime140.dll找不到如何修复,分享5种靠谱的修复教程
当您在运行某个应用程序或游戏时遇到提示“找不到vcruntime140.dll”,这通常意味着系统中缺少了Visual C Redistributable for Visual Studio 2015或更高版本的一个重要组件。这个错误通常发生在运行某些程序时,系统无法找到所需的动态链接库文件。小编将…...
超级简单的地图操作工具开发可疑应急,地图画点,画线,画区域,获取地图经纬度等
使用echars的地图画点,画线,画区域,获取地图经纬度等 解压密码:10086007 地图也是用临时的bmap.js和china.js纯离线二选一 一共就这么多文件 画点,画线,画区域 点击地图获取经纬度-打印到控制台,这样就能渲染航迹,多变形,结合其他算法算圆等等操作 下载资源:https://download…...
25_NumPy数组np.round将ndarray舍入为偶数
25_NumPy数组np.round将ndarray舍入为偶数 使用 np.round() 将 NumPy 数组 ndarray 的元素值舍入为任意位数。请注意,0.5 由于舍入到偶数而不是一般舍入而舍入为 0.0。 本文介绍了一般舍入的实现示例。 如何使用 np.round() 基本用法指定要舍入的位数:…...
Java字符串去除空格的方法
前言 在Java编程实践中,处理字符串中的空格是一项基本且频繁的操作。本文将深入探讨如何使用Java原生方法以及Apache Commons Lang库中的StringUtils类,全方位解决字符串去空格的需求,让你的代码更加健壮和高效。 1. Java原生方法 a. trim…...
【Python】【应用】Python应用之如何操作WiFi之一——使用pywifi
🐚作者简介:花神庙码农(专注于Linux、WLAN、TCP/IP、Python等技术方向)🐳博客主页:花神庙码农 ,地址:https://blog.csdn.net/qxhgd🌐系列专栏:Python应用&…...
2024OD机试卷-分割均衡字符串 (java\python\c++)
题目:分割均衡字符串 题目描述 均衡串定义: 字符串 中只包含两种字符,且这两种字符的个数相同。 给定一个均衡字符串,请给出可分割成新的均衡子串的最大个数。 约定:字符串中只包含大写的 X 和 Y 两种字符。 输入描述 字符串的长度:[2, 10000]。 给定的字符串均为均…...
完整版解答!2024年数维杯数学建模挑战赛B题
B题 生物质和煤共热解问题的研究 技术文档第一问1.1问题一分析1.2数据预处理1.3问题一Spearman相关性分析 数据代码资料获取 技术文档 第一问 1.1问题一分析 对于问题一,题目要求分析出正己烷不溶物对焦油产率、水产率、焦渣产率这三个指标是否有显著影响&#x…...
Android开发,日志级别
5个日志级别 Verbose (VERBOSE): 这是最低的日志级别,用于输出最为详尽的信息,包括开发和调试过程中的各种细节。在Log类中对应的方法是Log.v()。Debug (DEBUG): 此级别用于输出调试信息,帮助开发者理解程序运行流程或状态。通过Log.d()方法…...
Docker 部署 MySQL 数据库
文章目录 MySQL 镜像创建缩主机目录my.cnf 配置文件docker-compose.yml给 Test 账号添加权限 Docker 与 docker-compose 安装这里不做介绍。 MySQL 镜像 根据需要选择版本 # 5.7 版本 docker pull mysql:5.7 # 8.2 版本 docker pull mysql:8.2创建缩主机目录 cd home # 创建…...
代码技巧: 类中同一个函数可以同时存在常函数版本和普通函数版本(c++)
在类中如果我们希望在常函数中修改某属性的值可以使用mutable来实现。 如果有下面的场景,假设我们有一个函数hobby()需要在非const的对象调用的时候,应该去修改内部的属性,在const修饰的对象调用的时候可以满足不修改内部的属性。 鉴于上面的…...
2024OD机试卷-转盘寿司 (java\python\c++)
题目:转盘寿司 题目描述 寿司店周年庆,正在举办 优惠活动 回馈新老客户。 寿司转盘上总共有 n 盘寿司,prices[i] 是第 i 盘寿司的价格, 如果客户选择了第 i 盘寿司,寿司店免费赠送客户距离第 i 盘寿司最近的下一盘寿司 j,前提是 prices[j] < prices[i],如果没有满足…...
MongoDB创建或删除用户并验证数据库权限
本文假设在Ubuntu中安装了MongoDB,并用命令行工具mongosh演示。 一、创建用户并设置数据库权限 用户和数据库是关联的,要在登录时验证某个数据库,需要在相应的数据库内创建用户,即先切换到该数据库再创建用户。除非是root最高权…...
半小时搞懂STM32面经知识——RCC
1. 时钟的概念 时钟是由电路产生的具有周期性的脉冲信号,相当于单片机的心脏,要想使用单片机的外设必须开启时钟。 时钟对单片机有什么作用? 1. 驱动外设的本质是寄存器,而寄存器需要时钟触发才能改写值。 2. 时钟频率越高&#…...
简易版抽奖活动的设计技术方案
1.前言 本技术方案旨在设计一套完整且可靠的抽奖活动逻辑,确保抽奖活动能够公平、公正、公开地进行,同时满足高并发访问、数据安全存储与高效处理等需求,为用户提供流畅的抽奖体验,助力业务顺利开展。本方案将涵盖抽奖活动的整体架构设计、核心流程逻辑、关键功能实现以及…...
在鸿蒙HarmonyOS 5中实现抖音风格的点赞功能
下面我将详细介绍如何使用HarmonyOS SDK在HarmonyOS 5中实现类似抖音的点赞功能,包括动画效果、数据同步和交互优化。 1. 基础点赞功能实现 1.1 创建数据模型 // VideoModel.ets export class VideoModel {id: string "";title: string ""…...
智慧工地云平台源码,基于微服务架构+Java+Spring Cloud +UniApp +MySql
智慧工地管理云平台系统,智慧工地全套源码,java版智慧工地源码,支持PC端、大屏端、移动端。 智慧工地聚焦建筑行业的市场需求,提供“平台网络终端”的整体解决方案,提供劳务管理、视频管理、智能监测、绿色施工、安全管…...
线程与协程
1. 线程与协程 1.1. “函数调用级别”的切换、上下文切换 1. 函数调用级别的切换 “函数调用级别的切换”是指:像函数调用/返回一样轻量地完成任务切换。 举例说明: 当你在程序中写一个函数调用: funcA() 然后 funcA 执行完后返回&…...
Java-41 深入浅出 Spring - 声明式事务的支持 事务配置 XML模式 XML+注解模式
点一下关注吧!!!非常感谢!!持续更新!!! 🚀 AI篇持续更新中!(长期更新) 目前2025年06月05日更新到: AI炼丹日志-28 - Aud…...
unix/linux,sudo,其发展历程详细时间线、由来、历史背景
sudo 的诞生和演化,本身就是一部 Unix/Linux 系统管理哲学变迁的微缩史。来,让我们拨开时间的迷雾,一同探寻 sudo 那波澜壮阔(也颇为实用主义)的发展历程。 历史背景:su的时代与困境 ( 20 世纪 70 年代 - 80 年代初) 在 sudo 出现之前,Unix 系统管理员和需要特权操作的…...
【Oracle】分区表
个人主页:Guiat 归属专栏:Oracle 文章目录 1. 分区表基础概述1.1 分区表的概念与优势1.2 分区类型概览1.3 分区表的工作原理 2. 范围分区 (RANGE Partitioning)2.1 基础范围分区2.1.1 按日期范围分区2.1.2 按数值范围分区 2.2 间隔分区 (INTERVAL Partit…...
Go 并发编程基础:通道(Channel)的使用
在 Go 中,Channel 是 Goroutine 之间通信的核心机制。它提供了一个线程安全的通信方式,用于在多个 Goroutine 之间传递数据,从而实现高效的并发编程。 本章将介绍 Channel 的基本概念、用法、缓冲、关闭机制以及 select 的使用。 一、Channel…...
MinIO Docker 部署:仅开放一个端口
MinIO Docker 部署:仅开放一个端口 在实际的服务器部署中,出于安全和管理的考虑,我们可能只能开放一个端口。MinIO 是一个高性能的对象存储服务,支持 Docker 部署,但默认情况下它需要两个端口:一个是 API 端口(用于存储和访问数据),另一个是控制台端口(用于管理界面…...
GraphQL 实战篇:Apollo Client 配置与缓存
GraphQL 实战篇:Apollo Client 配置与缓存 上一篇:GraphQL 入门篇:基础查询语法 依旧和上一篇的笔记一样,主实操,没啥过多的细节讲解,代码具体在: https://github.com/GoldenaArcher/graphql…...
