使用 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.mzph.cn/diannao/7928.shtml

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

相关文章

机器人系统ros2-开发实践07-将机器人的状态广播到 tf2(Python)

上个教程将静态坐标系广播到 tf2,基于这个基础原理这个教程将演示机器人的点位状态发布到tf2 1. 写入广播节点 我们首先创建源文件。转到learning_tf2_py我们在上一教程中创建的包。在src/learning_tf2_py/learning_tf2_py目录中输入以下命令来下载示例广播示例代码…

双ISP住宅IP有何优势?

双ISP住宅IP在当前的互联网环境中具有显著的优势,这些优势主要体现在网络连接的稳定性、安全性、速度以及业务适用范围等方面。以下是对双ISP住宅IP优势的详细分析: 第一点网络连接的稳定性,双ISP住宅IP使用两个不同的互联网服务提供商&…

区块链 | NFT 相关论文:Preventing Content Cloning in NFT Collections(三)

🐶原文: Preventing Content Cloning in NFT Collections 🐶写在前面: 这是一篇 2023 年的 CCF-C 类,本博客只记录其中提出的方法。 F C o l l N F T \mathbf{F_{CollNFT}} FCollNFT​ and Blockchains with Native S…

SpringBoot2 仿B站高性能前端+后端项目(wanjie)

SpringBoot2 仿B站高性能前端后端项目(完结) Spring Boot 2 仿B站高性能前端后端项目:打造高效、稳定、可扩展的应用 在当今的互联网时期,网站的性能、稳定性和可扩展性成为了权衡一个项目胜利与否的关键要素。本文将引见如何运用 Spring Boot 2 构建一…

智启算力平台基本操作

智启算力平台 智启算力平台路径搭载数据集搭载镜像配置 智启算力平台 开发文档 帮助文档 - OpenI - 启智AI开源社区 路径搭载 OpenIOSSG/promote: 启智AI协作平台首页推荐组织及推荐项目申请。 - notice/Other_notes/SDKGetPath.md at master - promote - OpenI - 启智AI开…

数据结构-线性表-应用题-2.2-11

1)算法的基本设计思想&#xff1a; 分别求两个升序序列的中位数a,b 若ab&#xff0c;则a或b即为所求中位数 若a<b&#xff0c;则舍弃A中较小的一半&#xff08;中位数偏小&#xff0c;往后面找&#xff09;&#xff0c;同时舍弃序列B中较大的一半&#xff0c;两次舍弃长度…

【Leetcode每日一题】 穷举vs暴搜vs深搜vs回溯vs剪枝_全排列 - 子集(解法2)(难度⭐⭐)(72)

1. 题目解析 题目链接&#xff1a;78. 子集 这个问题的理解其实相当简单&#xff0c;只需看一下示例&#xff0c;基本就能明白其含义了。 2.算法原理 为了生成一个给定数组 nums 的所有子集&#xff0c;我们可以利用一种称为回溯&#xff08;backtracking&#xff09;的算法…

pytest(二):关于pytest自动化脚本编写中,初始化方式setup_class与fixture的对比

一、自动化脚本实例对比 下面是一条用例,使用pytest框架,放在一个类中,两种实现方式: 1.1 setup_class初始化方式 1. 优点: 代码结构清晰,setup_class 和 teardown_class 看起来像传统的类级别的 setup 和 teardown 方法。2. 缺点: 使用 autouse=True 的 fixture 作为…

Mac 链接 HP 136w 打印机步骤

打开 WI-FI 【1】打开打印机左下角Wi-Fi网络设计【或者点击…按钮进入WI-FI菜单】&#xff0c;找到NetWork选项OK进入&#xff1b; 【2】设置WI-FI选项&#xff1a;在菜单内找到Wi-Fi选项OK进入&#xff1b; 【3】在菜单内找到Wi-Fi Direct选项OK进入&#xff1b; 【4】在菜单…

java:File类概述和构造方法

一、File类概述和构造方法 1.File类的概述 File&#xff1a;它是文件和目录路径名的抽象表示 文件和目录是可以通过File封装成对象的对File而言&#xff0c;其封装并不是一个真正存在的文件&#xff0c;仅仅是一个路径名而已。它可以是存在的&#xff0c;也可以是不存在的。…

瑞友天翼应用虚拟化系统SQL注入致远程代码执行漏洞复现

0x01 产品简介 瑞友天翼应用虚拟化系统是西安瑞友信息技术资讯有限公司研发的具有自主知识产权,基于服务器计算架构的应用虚拟化平台。它将用户各种应用软件集中部署在瑞友天翼服务器(群)上,客户端通过WEB即可快速安全的访问经服务器上授权的应用软件,实现集中应用、远程接…

人工智能-2024期中考试

前言 人工智能期中考试&#xff0c;认真准备了但是没考好&#xff0c;结果中游偏下水平。 第4题没拿分 &#xff08;遗传算法&#xff1a;知识点在课堂上一笔带过没有细讲&#xff0c;轮盘赌算法在书本上没有提到&#xff0c;考试的时候也没讲清楚&#xff0c;只能靠猜&…

Python网络协议socket

01 协议基础 01 网络协议 协议&#xff1a;一种规则 网络协议&#xff1a;网络规则&#xff0c;一种在网络通信中的数据包的数据规则 02 TCP/IP协议 osi模型 tcp/ip协议 03 tcp协议 TCP协议提供了一种端到端的、基于连接的、可靠的通信服务。 三次握手 创建连接 四次挥手…

华为:三层交换机与路由器连通上网实验

三层交换机是一种网络交换机&#xff0c;可以实现基于IP地址的高效数据转发和路由功能&#xff0c;通常用于大型企业、数据中心和校园网络等场景。此外&#xff0c;三层交换机还支持多种路由协议&#xff08;如OSPF、BGP等&#xff09;&#xff0c;以实现更为复杂的网络拓扑结构…

深度学习之基于Matlab卷积神经网络验证码识别系统

欢迎大家点赞、收藏、关注、评论啦 &#xff0c;由于篇幅有限&#xff0c;只展示了部分核心代码。 文章目录 一项目简介 二、功能三、系统四. 总结 一项目简介 一、项目背景 随着互联网的发展&#xff0c;验证码作为一种常用的安全验证手段&#xff0c;被广泛应用于各种网站和…

W801学习笔记二十一:英语背单词学习应用——上

英语背单词是比较常见的学习APP&#xff0c;参考唐诗宋词应用&#xff0c;本章做一个类似的应用。 一、单词数据清洗及格式转换 诗词数据的获取渠道很多&#xff0c;一般可以按照年级来分文件。如一到九年级&#xff0c;四六级&#xff0c;雅思等等。 1、先从网上某某地方下载…

python+flask+ldap3搭建简易版IDaaS系统(前端站点)

Python工具开源专栏 Py0006 pythonflaskldap3搭建简易版IDaaS系统&#xff08;前端站点&#xff09; Python工具开源专栏前言目录结构前端网站的部分演示首页查询数据数据同步数据关联查询系统日志 完整代码已在GitHub上开源 前言 pythonflaskldap3搭建简易版IDaaS系统的前端站…

redis分片java实践、redis哨兵机制实现、redis集群搭建

redis分片java实践 linux安装redishttps://mp.csdn.net/mp_blog/creation/editor/134864302复制redis.conf配置文件成redis1.conf、redis2.conf、redis3.conf 修改redis的端口信息和存pid文件的路径。存pid文件的路径只要不同就行了&#xff0c;没什么特别要求。 指定配置文件…

《Fundamentals of Power Electronics》——示例:Buck-Boost转换器模型变为正则形式

为了说明正则电路模型推导的步骤&#xff0c;让我们将buck-boost转换器的等效电路操作成规范形式。buck-boost转换器的一个小信号交流等效电路如下图所示。 为了将上图所示网络转换成正则形式&#xff0c;需要将所有独立源d(t)转换到左侧&#xff0c;而将所有电感转换到右侧与变…

【Qt QML】ComboBox组件

ComboBox 是一个组合的按钮和弹出列表。它提供了一种以最小的屏幕空间呈现选项列表给用户的方式。ComboBox 使用数据模型填充。数据模型通常是一个 JavaScript 数组、一个 ListModel 或一个整数&#xff0c;但也支持其他类型的数据模型。 下面是一个简单的使用方式。 import …