《Learning Langchain》阅读笔记2-基于 Gemini 的 Langchain PromptTemplate 实现方式
本文将使用Gemini实现《Learning Langchain》中的PromptTemplate 实现方式,替代书中的调用openai API,白嫖太香了!
调试步骤
我们首先还是先在本地调试是否可以调用Gemini API:
import getpass
import osif "GOOGLE_API_KEY" not in os.environ:os.environ["GOOGLE_API_KEY"] = getpass.getpass("Enter your Google AI API key: ")
import os
import requestsos.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:7890'r = requests.get("https://www.google.com")
print(r.status_code) # 能返回 200 就说明代理成功了
输出为:
200
from langchain_google_genai import ChatGoogleGenerativeAIllm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-001", # 或其他可用模型
)print(llm.invoke("你好呀!你现在通了吗?").content)
输出为:
你好!我一直都在线,随时准备好为你提供帮助。如果你有任何问题或需要我做什么,请随时告诉我。
对照书上示例1
这里书上给的是Openai的API使用方法:
#Openai API
from langchain_openai.chat_models import ChatOpenAI
from langchain_core.messages import HumanMessage
model = ChatOpenAI()
prompt = [HumanMessage('What is the capital of France?')]
completion = model.invoke(prompt)
输出结果:
AIMessage(content=‘The capital of France is Paris.’)
从这里开始,我将会全部替换为gemini的API调用,代码全部都是可以在本地跑通的!
# Gemini API
from langchain_google_genai import ChatGoogleGenerativeAIllm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-001", # 或其他可用模型
)# prompt = ['What is the capital of France?']
prompt = 'What is the capital of France?' # 两种写法都可以,但是不能用[HumanMessage('What is the capital of France?')],会报错
print(llm.invoke(prompt))
输出为:
content='The capital of France is **Paris**.' additional_kwargs={} response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'model_name': 'gemini-2.0-flash-001', 'safety_ratings': []} id='run-758b65ec-13af-4cde-a3e7-1aa7991e98ba-0' usage_metadata={'input_tokens': 7, 'output_tokens': 9, 'total_tokens': 16, 'input_token_details': {'cache_read': 0}}
# 还可以写
print(llm.invoke(prompt).content)
输出为:
The capital of France is **Paris**.
我们已经通过简单调用llm.invoke()实现了用gemini回答我们给出的prompt的功能。如果我们想要传递一个详细的prompt呢?比如如下的prompt:
Answer the question based on the context below. If the question cannot be answered using the information provided answer with “I don’t know”.
Context: The most recent advancements in NLP are being driven by Large Language Models (LLMs). These models outperform their smaller counterparts and have become invaluable for developers who are creating applications with NLP capabilities. Developers can tap into these models through Hugging Face’s
transformers
library, or by utilizing OpenAI and Cohere’s offerings through theopenai
andcohere
libraries respectively.Question: Which model providers offer LLMs?
Answer:
在这个prompt中,Context和Question是固定的,但如果我们想要动态地传递这些值呢?
幸运的是,LangChain提供了prompt template interfaces,可以轻松构建具有动态输入的提示,Python中:
from langchain_core.prompts import PromptTemplatetemplate = PromptTemplate.from_template("""Answer the question based on the context below. If the question cannot be answered using the information provided answer with "I don't know".
Context: {context}
Question: {question}
Answer: """)prompt = template.invoke({"context": "The most recent advancements in NLP are being driven by Large Language Models (LLMs). These models outperform their smaller counterparts and have become invaluable for developers who are creating applications with NLP capabilities. Developers can tap into these models through Hugging Face's `transformers` library, or by utilizing OpenAI and Cohere's offerings through the `openai` and `cohere` libraries respectively.","question": "Which model providers offer LLMs?"
})print(prompt)
输出为:
text='Answer the question based on the context below. If the question cannot be answered using the information provided answer with "I don\'t know".\nContext: The most recent advancements in NLP are being driven by Large Language Models (LLMs). These models outperform their smaller counterparts and have become invaluable for developers who are creating applications with NLP capabilities. Developers can tap into these models through Hugging Face\'s `transformers` library, or by utilizing OpenAI and Cohere\'s offerings through the `openai` and `cohere` libraries respectively.\nQuestion: Which model providers offer LLMs?\nAnswer: '
这里干了什么?简单解释:
它使用了 LangChain 的 PromptTemplate,可以根据不同的上下文(context)和问题(question)来动态生成提示语(prompt),非常适合给大语言模型(像 ChatGPT)提问。
具体说明:
template = PromptTemplate.from_template("""
Answer the question based on the context below...
Context: {context}
Question: {question}
Answer: """)
这是一个带有“空位”的模板,{context} 和 {question} 是将来要填进去的内容。
prompt = template.invoke({"context": "这里是一些关于 NLP 的信息...","question": "哪些模型提供商提供 LLMs?"
})
用 .invoke() 方法把真实的上下文和问题“填空”进模板中,生成完整的提示。
你可以把 PromptTemplate 想成一张带空格的表格,而 invoke() 就是把空格填上具体内容,最后生成一份完整的问题卡片给 AI 回答。
让我们看看如何使用LangChain将此信息流馈送到LLM模型中:
from langchain_core.prompts import PromptTemplate
from langchain_google_genai import ChatGoogleGenerativeAItemplate = PromptTemplate.from_template("""Answer the question based on the context below. If the question cannot be answered using the information provided answer with "I don't know".
Context: {context}
Question: {question}
Answer: """)prompt = template.invoke({"context": "The most recent advancements in NLP are being driven by Large Language Models (LLMs). These models outperform their smaller counterparts and have become invaluable for developers who are creating applications with NLP capabilities. Developers can tap into these models through Hugging Face's `transformers` library, or by utilizing OpenAI and Cohere's offerings through the `openai` and `cohere` libraries respectively.","question": "Which model providers offer LLMs?"
})completion = llm.invoke(prompt)print(completion.content)
输出为:
OpenAI and Cohere
如果您想构建一个 AI 聊天应用程序,则可以使用聊天提示模板,根据聊天消息的角色提供动态输入。首先使用 Python:
from langchain_core.prompts import ChatPromptTemplatetemplate = ChatPromptTemplate.from_messages([('system', 'Answer the question based on the context below. If the question cannot be answered using the information provided answer with "I don\'t know".'),('human', 'Context: {context}'),('human', 'Question: {question}'),
])prompt = template.invoke({"context": "The most recent advancements in NLP are being driven by Large Language Models (LLMs). These models outperform their smaller counterparts and have become invaluable for developers who are creating applications with NLP capabilities. Developers can tap into these models through Hugging Face's `transformers` library, or by utilizing OpenAI and Cohere's offerings through the `openai` and `cohere` libraries respectively.","question": "Which model providers offer LLMs?"
})completion = llm.invoke(prompt)print(completion.content)
输出为:
OpenAI and Cohere are mentioned as LLM providers.
很直观的感受就是:.invoke()方法真的就像是在填空!
首先把你输入的prompt用template.invoke()填充到template模板里,然后再调用llm.invoke(prompt)让llm来为prompt填空。
但这段代码我们注意到它的模板类型不再是PromptTemplate.from_template()而是ChatPromptTemplate.from_messages(),这是专为多轮对话(聊天格式)设计,并且我们在模板里明确指定了system和human,定义了不同的角色。
我们来看看与上文模板的区别:
项目 | 第一段代码 (PromptTemplate ) | 这段代码 (ChatPromptTemplate ) |
---|---|---|
模板类型 | 适用于单条文本提示 | 专为**多轮对话(聊天格式)**设计 |
定义方式 | .from_template() | .from_messages() |
消息角色 | 无 | 明确指定了 system 和 human |
格式 | 一整段字符串,插值变量 {} | 多条消息组成,每条可以有不同角色 |
解释一下这段代码做了什么:
from langchain_core.prompts import ChatPromptTemplatetemplate = ChatPromptTemplate.from_messages([('system', 'Answer the question based on the context below...'),('human', 'Context: {context}'),('human', 'Question: {question}'),
])
这里定义了一个对话格式的模板,有两种角色:
system:系统消息,设置AI行为,比如“根据上下文回答问题,不知道就说不知道”。
human:人类用户的消息,这里有上下文和问题两条信息。
然后用 .invoke({…}) 插入实际内容:
prompt = template.invoke({"context": "...","question": "Which model providers offer LLMs?"
})
最终会生成一组 聊天消息格式的提示,适合用于支持对话结构的模型(比如 OpenAI 的 chat 模型接口)。
总结一句话:
PromptTemplate:更适合一段完整的文字提示。
ChatPromptTemplate:更适合多轮对话式模型,结构更清晰,功能更强大。
我们在这个新的模板基础上开始实际调用大语言模型(LLM)进行预测:
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_core.prompts import ChatPromptTemplate# both `template` and `model` can be reused many times
template = ChatPromptTemplate.from_messages([('system', 'Answer the question based on the context below. If the question cannot be answered using the information provided answer with "I don\'t know".'),('human', 'Context: {context}'),('human', 'Question: {question}'),
])llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-001", # 或其他可用模型
)# `prompt` and `completion` are the results of using template and model once
prompt = template.invoke({"context": "The most recent advancements in NLP are being driven by Large Language Models (LLMs). These models outperform their smaller counterparts and have become invaluable for developers who are creating applications with NLP capabilities. Developers can tap into these models through Hugging Face's `transformers` library, or by utilizing OpenAI and Cohere's offerings through the `openai` and `cohere` libraries respectively.","question": "Which model providers offer LLMs?"
})completion = llm.invoke(prompt)print(completion)
输出为:
content='Based on the context, OpenAI and Cohere offer LLMs.' additional_kwargs={} response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'model_name': 'gemini-2.0-flash-001', 'safety_ratings': []} id='run-d6e9e476-69c6-43d6-90e5-bfcb3553c9bc-0' usage_metadata={'input_tokens': 118, 'output_tokens': 15, 'total_tokens': 133, 'input_token_details': {'cache_read': 0}}
总结这段代码做了什么:
步骤 | 做了什么 |
---|---|
1. 创建模板 | 用 ChatPromptTemplate 定义多轮对话结构 |
2. 插入内容 | 用 .invoke() 方法填入具体 context 和 question |
3. 调用模型 | 用 ChatOpenAI() 模型接收 prompt,并返回回答 |
这就是调用ChatPromptTemplate
的全部内容,欢迎点赞收藏!
相关文章:
《Learning Langchain》阅读笔记2-基于 Gemini 的 Langchain PromptTemplate 实现方式
本文将使用Gemini实现《Learning Langchain》中的PromptTemplate 实现方式,替代书中的调用openai API,白嫖太香了! 调试步骤 我们首先还是先在本地调试是否可以调用Gemini API: import getpass import osif "GOOGLE_API_K…...
LVS+keepalived搭建高可用架构
背景:最近在搭建LVSkeepalived的高可用架构,中间遇到了一些坑比较让人头疼,此处重要就安装部署的步骤进行记录,特别是遇到坑进行说明,希望能对有需要的同学提供给帮助! 坑点1: 在部署LVSkeepalived并且使用…...
【天梯赛练习】L2-035 完全二叉树的层序遍历
后序遍历转层序遍历 后序遍历:左——右——根层序遍历:数组形式存储的完全二叉树的顺序遍历序列其实就正好是其层序遍历序列。 子树根若是 i d id id,左子树 i d ∗ 2 id*2 id∗2,右子树 2 ∗ i d 1 2*id1 2∗id1 所以就是dfs递…...
2025.4.20机器学习笔记:文献阅读
2025.4.20周报 题目信息摘要创新点网络架构实验生成性能对比预测性能对比 结论不足以及展望 题目信息 题目: A novel flood forecasting model based on TimeGAN for data-sparse basins期刊: Stochastic Environmental Research and Risk Assessment作…...
Leetcode 3359. 查找最大元素不超过 K 的有序子矩阵【Plus题】
1.题目基本信息 1.1.题目描述 给定一个大小为 m x n 的二维矩阵 grid。同时给定一个 非负整数 k。 返回满足下列条件的 grid 的子矩阵数量: 子矩阵中最大的元素 小于等于 k。 子矩阵的每一行都以 非递增 顺序排序。 矩阵的子矩阵 (x1, y1, x2, y2) 是通过选择…...
Redis面试——事务
一、Redis原子性是什么? (1)单个命令的原子性 原子性是指一组操作,要么全部执行成功,要么全部失败。Redis 中的单个命令是天然原子性的,因为 Redis 的命令执行采用单线程模型,同一时间只会执行…...
【远程管理绿联NAS】家庭云存储无公网IP解决方案:绿联NAS安装内网穿透
文章目录 前言1. 开启ssh服务2. ssh连接3. 安装cpolar内网穿透4. 配置绿联NAS公网地址 前言 大家好,今天要带给大家一个超级酷炫的技能——如何让绿联NAS秒变‘千里眼’,通过简单的几步操作就能轻松实现内网穿透。想象一下,无论你身处何地&a…...
AI写程序:用 AI 实现一个递归批量转化 GBK/GB2312 转 UTF-8 工具:轻松解决文本编码转换难题
用 AI 实现一个递归批量转化 GBK/GB2312 转 UTF-8 工具 在处理历史文件或与不同系统交互时,我们经常会遇到 GBK 或 GB2312 编码的文本文件。虽然现在 UTF-8 是主流,但手动转换这些旧编码文件既繁琐又容易出错。为了解决这个问题,我开发了一个…...
首席人工智能官(Chief Artificial Intelligence Officer,CAIO)的详细解析
以下是**首席人工智能官(Chief Artificial Intelligence Officer,CAIO)**的详细解析: 1. 职责与核心职能 制定AI战略 制定公司AI技术的长期战略,明确AI在业务中的应用场景和优先级,推动AI与核心业务的深度…...
uview1.0 tabs组件放到u-popup中在微信小程序中滑块样式错乱
解决思路 重新计算布局信息:在弹窗显示后重新调用 init 方法来计算组件的布局信息。使用 nextTick:保证在视图更新之后再进行布局信息的计算。 <u-tabs ref"tabsRef" ></u-tabs> makeClick(){this.makeShowtruethis.$nextTick…...
私人笔记:动手学大模型应用开发llm-universe项目环境创建
项目代码:datawhalechina/llm-universe: 本项目是一个面向小白开发者的大模型应用开发教程,在线阅读地址:https://datawhalechina.github.io/llm-universe/ 项目书:动手学大模型应用开发 一、初始化项目 uv init llm-universe-te…...
基于Django框架的图书索引智能排序系统设计与实现(源码+lw+部署文档+讲解),源码可白嫖!
摘要 时代在飞速进步,每个行业都在努力发展现在先进技术,通过这些先进的技术来提高自己的水平和优势,图书管理系统当然不能排除在外。图书索引智能排序系统是在实际应用和软件工程的开发原理之上,运用Python语言以及Django框架进…...
网络类型学习
网络类型的分类依据-----基于二层(数据链路层)使用的协议不同而导致数据包的封装方式不同,工作方式也不同。 OSPF协议根据链路层协议类型将网络分为四种类型:广播型网络(BMA)、非广播多路访问(…...
ubuntu24.04离线安装deb格式的mysql-community-8.4.4
1,下载解压 参考: https://blog.csdn.net/2202_76101487/article/details/145967039 下载: wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-server_8.4.4-1ubuntu24.04_amd64.deb-bundle.tar 建议个目录mysql8然后把安装包移过去&…...
电控---printf重定向输出
在嵌入式系统开发中,printf 重定向输出是将标准输出(stdout)从默认设备(如主机终端)重新映射到嵌入式设备的特定硬件接口(如串口、LCD、USB等)的过程。 一、核心原理:标准IO库的底层…...
uniapp使用createSelectorQuery,boundingClientRect获取宽度和高度不准确的可用的解决方案
场景展示: uniapp使用createSelectorQuery,boundingClientRect获取宽度和高度不准确的可用的解决方案,正常来说,使用下面的代码是可以正确获得宽高的,但是里面含有图片,在图片没有加载完的情况下,我们可以…...
DSO:牛津大学推出的物理一致性3D模型优化框架
在数字内容创作和制造领域,将2D图像转换为高质量、物理上稳定的3D模型一直是一个挑战。传统的3D建模方法往往需要大量的手动调整以确保生成的物体不仅美观而且符合物理定律,能够在现实世界中稳定存在。牛津大学近期推出了一款名为DSO(Direct Sparse Odometry)的项目,它不仅…...
Delphi Ini文件对UTF8支持不爽的极简替代方案
如题,没太多废话,直接复制走即可。 unit uConfig;interfaceuses classes, Sysutils;typeTConfig class privateFFileName: String;FConfig:TStringList; protectedpublicconstructor Create(ConfigFile:String);destructor Destroy;property FileName…...
Windows平台使用Docker部署Neo4j
✅ Docker 安装 Neo4j 前提条件:安装docker 打开docker desktop docker run \--name neo4j \-p7474:7474 -p7687:7687 \-d \-e NEO4J_AUTHneo4j/password123 \neo4j:5默认用户名是 neo4j,密码是你设置的,比如上面是 password123 ✅用 Pyt…...
FreeRTOS二值信号量详解与实战教程
FreeRTOS二值信号量详解与实战教程 📚 作者推荐:想系统学习FreeRTOS嵌入式开发?请访问我的FreeRTOS开源学习库,内含从入门到精通的完整教程和实例代码! 1. 二值信号量核心概念解析 二值信号量(Binary Semaphore)是Fre…...
数据结构与算法[零基础]---6.算法概况
六、算法概述 (一)算法的概述 任何解决问题的过程都是由一定的步骤组成的,把解决问题的方法和有限的步骤称作算法 (二)算法的基本特征 1.有穷性 算法必须在执行有限个操作之后终止,且每一步都可在有限时间内完成。 2.确定性 算…...
STL简介(了解)
1.什么是STL STL(standard template libaray)是标准模板库,它是C标准库的一部分。C标准库中还有一些其它东西,比如之前用的IO流。它主要是数据结构和算法的库。 2.STL的版本 C3.0出来后就有了模板,此时大家已经深受没有数据结构算法库的痛苦…...
使用 Oh My Posh 自定义 PowerShell 提示符
使用 Oh My Posh 自定义 PowerShell 提示符 由于ai生图,ai视频这方面mac太差了,买N卡,转windows了,这里也记录一下 PowerShell 配置Oh My Posh 先上效果图 一、下载 PowerShell7 默认的 PowerShell5 太差了,下载地…...
4月17号
//1.编码 String str "ai你哟"; byte[] bytes1 str.getBytes(); System.out.println(Arrays.toString(bytes1)); byte[] bytes2 str.getBytes(charsetName: "GBK"); System.out.println(Arrays.toString(bytes2));//2.解码 String str2 new String(byt…...
react-native搭建开发环境过程记录
主要参考:官网的教程 https://reactnative.cn/docs/environment-setup 环境介绍:macos ios npm - 已装node18 - 已装,通过nvm进行版本控制Homebrew- 已装yarn - 已装ruby - macos系统自带的2.2版本。watchman - 正常安装Xcode - 正常安装和…...
自然语言处理(NLP)技术。
自然语言处理(NLP)技术可以应用于多个领域,以下是一些示例: 情感分析:NLP可以用来分析文本中包含的情感,帮助企业了解用户对他们产品或服务的感受。例如,社交媒体平台可以利用情感分析技术来监测…...
Ubuntu 安装WPS Office
文章目录 Ubuntu 安装WPS Office下载安装文件安装WPS问题1.下载缺失字体文件2.安装缺失字体 Ubuntu 安装WPS Office 下载安装文件 需要到 WPS官网 下载最新软件,比如wps-office_12.1.0.17900_amd64.deb 安装WPS 执行命令进行安装 sudo dpkg -i wps-office_12.1…...
【WPF】 自定义控件的自定义属性
文章目录 前言一、自定义控件部分二、在页面中使用总结 前言 在一个页面,重复用到同一个自定义控件时,该如何对控件分别进行数据绑定呢?这时候可以赋予控件一个自定义的属性,来完成此操作。 一、自定义控件部分 为自定以控件设置…...
Unity URP Moblie AR示例工程,真机打包出来,没阴影
效果: unity ar示例演示 现象: 真机打包测试私活没有阴影 Unity版本:2022.3.4f1c1 分析原因: Prefab :ARFeatheredPlane中也有材质,一个用于环境遮挡,一个用于阴影接受。 按理说有啊。 urp …...
如何删除word中的长横线(由三个减号---自动生成/由三个等号===自动生成/由三个###自动生成)_word三个减号回车的横线怎么删除-CSDN博客
方法1、选中前后行ctrlX剪切掉 方法2:如果文件中没有表格就非常简单,直接CtrlA全选整个文档,然后在表格边框里面选择“无框线”OK,如果有表格的话,就从横线的下行开始向上随意选取一部分,同样在表格边框中选…...
函数返回const引用,使用const修饰变量接收
函数返回const引用,使用const修饰变量接收 1、背景 想获取红绿灯时长数组并添加新的值。有个函数是返回红绿灯时长数组的。函数返回类型为const引用,我使用无修饰的变量接收。但是感觉有些问题,并且之前看到const变量变成非const还需要使用…...
在激烈竞争下B端HMI设计怎样打造独特用户体验?
在当今数字化高度发展的时代,B 端市场竞争愈发激烈。对于 B 端 HMI(人机界面)设计而言,打造独特的用户体验已成为在竞争中脱颖而出的关键因素。B 端用户在复杂的工作场景中,对 HMI 设计有着独特的需求和期望࿰…...
数理逻辑(Mathematical Logic)综论与跨学科应用
李升伟 整理 数理逻辑(Mathematical Logic)是现代逻辑学与数学交叉的核心学科,以严格的数学方法研究逻辑推理的形式与规律。其发展深刻影响了数学基础、计算机科学、语言哲学等领域。以下从多个维度综论数理逻辑: 1. 核心分支 命…...
4.17---实现商铺和缓存与数据库双写一致以及宕机处理
实现商铺和缓存与数据库双写一致(以及强双写一致策略) redis点评项目采用的是延时双删策略 双删: 我们更新完数据库之后删除缓存,这样即使有线程并发进来查询,会发现缓存中没有数据,从而会去mysql中查找…...
qt与html通信
**Cef视图(CefView)**是指在使用Chromium Embedded Framework(CEF)时,嵌入到应用程序中的浏览器视图。CEF是一个开源项目,它基于Google的Chromium浏览器,允许开发者将Web浏览器功能嵌入到自己的…...
【从零实现高并发内存池】thread cache、central cache 和 page cache 回收策略详解
📢博客主页:https://blog.csdn.net/2301_779549673 📢博客仓库:https://gitee.com/JohnKingW/linux_test/tree/master/lesson 📢欢迎点赞 👍 收藏 ⭐留言 📝 如有错误敬请指正! &…...
算法5-16 对二进制字符串解码
输入样例: 5 a 4 b 3 c 2 w 1 z 1 100001110101101101100111输出样例: baaacabwbzc ac代码: #include<iostream> #include<queue> #include<map> using namespace std; const int N10010; int idx; int a[N][2]; char b…...
[MySQL数据库] InnoDB存储引擎(三): 内存结构详解
🌸个人主页:https://blog.csdn.net/2301_80050796?spm1000.2115.3001.5343 🏵️热门专栏: 🧊 Java基本语法(97平均质量分)https://blog.csdn.net/2301_80050796/category_12615970.html?spm1001.2014.3001.5482 🍕 Collection与…...
TDengine 存储引擎剖析:数据文件与索引设计(一)
TDengine 存储引擎简介 在物联网、工业互联网等快速发展的今天,时间序列数据呈爆发式增长。这些数据具有产生频率高、依赖采集时间、测点多信息量大等特点,对数据存储和处理提出了极高要求。TDengine 作为一款高性能、分布式、支持 SQL 的时序数据库&am…...
CentOS更换yum源
CentOS更换yum源 视频教程: https://www.bilibili.com/video/BV1yWaSepE6z/?spm_id_from333.1007.top_right_bar_window_history.content.click 步骤: 第一步: cd /etc/yum.repos.d第二步:cp CentOS-Base.repo CentOS-Base.repo…...
【Kubernetes基础--持久化存储原理】--查阅笔记5
目录 持久化存储机制PV 详解PV 关键配置参数PV 生命周期的各个阶段 PVC 详解PVC 关键配置参数PV 和 PVC 的生命周期 StorageClass 详解StorageClass 关键配置参数设置默认的 StorageClass 持久化存储机制 k8s 对于有状态的容器应用或对数据需要持久化的应用,不仅需…...
数据库子查询实验全解析
目录 一、验证性实验:夯实基础(一)查询同班学生信息(二)查询成绩相关信息(三)查询课程选课人数(四)相关子查询(五)EXISTS嵌套子查询(六…...
HTML:表格数据展示区
<!DOCTYPE html> <html lang"zh-CN"><head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>人员信息表</title><link rel"styl…...
webgl入门实例-08索引缓冲区的基本概念
WebGL 索引缓冲区 (Index Buffer) 索引缓冲区(也称为元素数组缓冲区)是WebGL中一种优化渲染性能的重要机制,它允许您重用顶点数据来绘制复杂的几何图形。 基本概念 索引缓冲区的工作原理: 您创建一个顶点缓冲区(包含所有顶点数据)然后创建一个索引缓…...
大数据应用开发——大数据平台集群部署
目录 前言 目录 基础环境 安装虚拟机 基础环境 VMware Workstation 虚拟机版本 : centos7 主机名 ip 用户名 密码 master192.168.245.100root123456slave1192.168.245.101root123456slave2192.168.245.102root123456 安装虚拟机 安装 名称、路径自己改 我有16核&…...
GPT对话UI--通义千问API
GPT对话UI 项目介绍 一个基于 GPT 的智能对话界面,提供简洁优雅的用户体验。本项目使用纯前端技术栈实现,无需后端服务器即可运行。 功能特点 💬 实时对话:支持与 AI 进行实时对话交互🌓 主题切换:支持…...
智能体数据分析
数据概览: 展示智能体的累计对话次数、累计对话用户数、对话满意度、累计曝光次数。数据分析: 统计对话分析、流量分析、用户分析、行为分析数据指标,帮助开发者完成精准的全面分析。 ps:数据T1更新,当日12点更新前一天…...
泛型算法——只读算法(一)
在 C 标准库中,泛型算法的“只读算法”指那些 不会改变它们所操作的容器中的元素,仅用于访问或获取信息的算法,例如查找、计数、遍历等操作。 accumulate std::accumulate()是 C 标准库**numeric**头文件中提供的算法,用于对序列…...
树莓派超全系列教程文档--(29)config.txt介绍
config.txt介绍 什么是 config.txt ?文件格式高级功能include条件过滤 文章来源: http://raspberry.dns8844.cn/documentation 原文网址 什么是 config.txt ? Raspberry Pi 设备使用名为 config.txt 的配置文件,而不是传统 PC …...
第十六届蓝桥杯大赛软件赛省赛 C++ 大学 B 组 部分题解
赛时参加的是Python组,这是赛后写的题解,还有两题暂时还不会,待更新 题目链接题目列表 - 洛谷 | 计算机科学教育新生态 A 移动距离 答案:1576 C 可分解的正整数 Python3 import itertools from functools import cmp_to_ke…...