diff --git a/README.md b/README.md
index c29842b..c962c9b 100644
--- a/README.md
+++ b/README.md
@@ -6037,8 +6037,6 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 矛盾内容
* 例:同一段回答中前后逻辑冲突(如先说“地球是平的”,后又说“地球绕太阳公转”)
-
-
* 幻觉产生的根本原因
* **训练数据的局限性**
@@ -6274,8 +6272,6 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* **为啥检索到词条后,还可以用调整输出内容,更加友好?**
* **什么是嵌入大模型?和前面学的LLM大模型有啥区别?**
-
-
### RAG 检索增强生成之Loader实战
#### RAG系统链路和数据加载Loaders技术
@@ -7496,8 +7492,6 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* **LLM大模型的RAG原理:用户输入自然语言query,找到最相关的文档**
* 这些场景的共同点:需要量化两个事物的相似程度,向量空间中的"方向感"
-
-
* 什么是余弦相似度?
* 基础定义:余弦相似度(Cosine Similarity)用于衡量两个向量在方向上的相似程度,忽略其绝对长度
@@ -8910,27 +8904,8 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
| **静态Schema** | 严格字段定义 | 数据结构固定的业务(用户画像) |
| **动态Schema** | 允许灵活字段(需Milvus 2.3+) | 日志类多变数据 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#### 第2集 Milvus索引操作和最佳实践避坑指南
-
-**简介: Milvus索引操作和最佳实践避坑指南**
+#### Milvus索引操作和最佳实践避坑指南
* 为什么需要索引?
@@ -8952,7 +8927,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 创建索引
- ```
+ ```python
# 导入MilvusClient和DataType模块,用于连接Milvus服务器并操作数据类型
from pymilvus import MilvusClient, DataType
@@ -9012,7 +8987,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 查看索引信息
- ```
+ ```python
#列出索引名称
res = client.list_indexes(
collection_name="customized_setup"
@@ -9032,7 +9007,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 删除前需确保无查询正在使用该索引
* 删除后需重新创建索引才能进行有效查询
- ```
+ ```python
#如果不再需要索引,可以直接将其删除。
client.drop_index(
collection_name="customized_setup",
@@ -9071,27 +9046,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
| "主键冲突" | 插入前检查ID唯一性,或使用自动生成ID |
| "向量维度错误" | 校验dim参数与数据实际维度 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#### 第3集 Milvus向量数据库的DML操作实战
-
-**简介: Milvus向量数据库的DML操作实战**
+#### Milvus向量数据库的DML操作实战
* 核心DML操作实战
@@ -9100,7 +9055,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* `auto_id=True`时无需手动指定主键
* 动态字段(`enable_dynamic_field=True`)允许灵活扩展非预定义字段
- ```
+ ```python
# 导入MilvusClient和DataType模块,用于连接Milvus服务器并操作数据类型
from pymilvus import MilvusClient, DataType
@@ -9133,7 +9088,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 插入数据(Insert)支持单条或批量插入【可视化工具那边需要加载,包括查询等都是需要加载状态才可以操作】
- ```
+ ```python
data = [
{"id": 1, "vector": [0.1]*128, "text": "Sample text 1"},
{"id": 2, "vector": [0.2]*128, "text": "Sample text 2"}
@@ -9149,7 +9104,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 删除数据(Delete)通过主键或条件表达式删除
- ```
+ ```python
# 按主键删除
client.delete(
collection_name="my_collection",
@@ -9165,7 +9120,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 更新数据(Update)Milvus不支持直接更新,需通过“删除+插入”实现:
- ```
+ ```python
# 删除旧数据
client.delete(collection_name="my_collection", ids=[3])
@@ -9176,29 +9131,8 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
)
```
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#### 第4集 Milvus向量Search查询综合案例实战《上》
-
-**简介: Milvus向量Search查询综合案例实战**
+#### Milvus向量Search查询综合案例实战
* 需求说明
@@ -9211,7 +9145,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 核心参数说明
- ```
+ ```python
results = client 或 collection.search(
data=[[0.12, 0.23, ..., 0.88]], # 查询向量(必须)
anns_field="vector", # 要搜索的向量字段名(必须)
@@ -9235,7 +9169,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 准备数据
- ```
+ ```python
from pymilvus import (
connections,MilvusClient,
FieldSchema, CollectionSchema, DataType,
@@ -9295,7 +9229,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 创建索引
- ```
+ ```python
# 准备索引参数,为"vector"字段创建索引
index_params = MilvusClient.prepare_index_params()
@@ -9318,7 +9252,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 执行查询【执行查询前需要加载才可以使用】
- ```
+ ```python
client.load_collection(collection_name="book") # 加载集合到内存
# 生成查询向量
query_vector = [random.random() for _ in range(4)]
@@ -9343,24 +9277,6 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
print("-" * 30)
```
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#### 第5集 Milvus向量Search查询综合案例实战《下》
-
-**简介: Milvus向量Search查询综合案例实战**
-
* 向量数据库完整工作流程示意图
```
@@ -9379,7 +9295,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 测试是否有 output_fields 字段,返回结果的差异
- ```
+ ```python
# 案例1:基础向量查询
basic_res = client.search(
collection_name="book",
@@ -9406,7 +9322,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 集合状态
- ```
+ ```python
# 验证集合状态
print(client.describe_collection("book"))
@@ -9426,30 +9342,9 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
| 错误处理 | 异常类捕获 | 统一错误码系统 |
| 动态字段支持 | 需要额外配置 | 参数开启即可 |
+### MMR搜索和LangChain整合Milvus实战
-
-
-
-
-
-
-
-
-
-
-
-
-
- **愿景:"IT路上的持续充电平台,让技术不再难学"**
-**更多高级课程请访问 xdclass.net**
-
-### 第四十一章 MMR搜索和LangChain整合Milvus实战
-
-
-
-#### 第1集 相似度Similarity和MMR最大边界相关搜索
-
-**简介: 相似度Similarity和MMR最大边界相关搜索**
+#### 相似度Similarity和MMR最大边界相关搜索
* 搜索的行业应用案例:电商推荐系统(明白两个差异)
@@ -9465,13 +9360,11 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
"用户浏览历史多样 → 推荐跨品类商品"
```
-
-
* 基础相似度搜索(Similarity Search)
* **原理**:通过向量空间中的距离计算(余弦相似度/L2距离等)找出最接近目标向量的结果
-
+
* 核心特点
@@ -9481,7 +9374,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 参数配置模板,方法 `vector_store.similarity_search( )`
- ```
+ ```python
vector_store.as_retriever(
search_type="similarity",
search_kwargs={
@@ -9513,7 +9406,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 设计初衷是解决传统相似性搜索(如余弦相似度)可能导致的“信息冗余”问题,在需要覆盖多角度信息或推荐多样化内容的场景中效果显著
* **原理**:在相似度和多样性之间进行权衡,避免结果冗余
-
+
* 算法原理图解
@@ -9531,7 +9424,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 参数配置模板, 方法 `vector_store.max_marginal_relevance_search( )`
- ```
+ ```python
mmr_retriever = vector_store.as_retriever(
search_type="mmr",
search_kwargs={
@@ -9573,25 +9466,9 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 企业推荐系统架构示例
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-#### 第2集 新版LangChain向量数据库VectorStore设计
-
-**简介: 新版LangChain向量数据库VectorStore设计**
+#### 新版LangChain向量数据库VectorStore设计
* LangChain 向量存储体系架构
@@ -9619,7 +9496,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
from langchain_core.vectorstores import VectorStore
```
-
+
* VectorStore 核心方法详解
@@ -9636,7 +9513,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 初始化方法
- ```
+ ```python
@classmethod
def from_documents(
cls,
@@ -9683,7 +9560,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 相似性搜索方法
- ```
+ ```python
def similarity_search(
self,
query: str,
@@ -9702,7 +9579,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 最大边界相关算法(MMR)
- ```
+ ```python
def max_marginal_relevance_search(
self,
query: str,
@@ -9730,27 +9607,9 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 场景:知识库冷启动
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-#### 第3集 LangChain整合Milvus新增和删除实战
-
-**简介: LangChain整合Milvus新增和删除实战**
+#### LangChain整合Milvus新增和删除实战
* 需求
@@ -9763,7 +9622,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 准备数据
- ```
+ ```python
from langchain_community.embeddings import DashScopeEmbeddings
#from langchain.vectorstores import Milvus
from langchain_milvus import Milvus
@@ -9829,7 +9688,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 插入
- ```
+ ```python
ids = [ str(i+1) for i in range(len(documents))]
print(ids)
result = vector_store.add_documents(documents=documents, ids=ids)
@@ -9838,25 +9697,14 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 删除
- ```
+ ```python
result = vector_store.delete(ids=["1"])
print(result)
#(insert count: 0, delete count: 1, upsert count: 0, timestamp: 456798840753225732, success count: 0, err count: 0
```
-
-
-
-
-
-
-
-
-
-#### 第4集 LangChain实战MMR和相似性搜索实战
-
-**简介: LangChain实战MMR和相似性搜索实战**
+#### LangChain实战MMR和相似性搜索实战
* 需求
@@ -9867,7 +9715,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 准备数据【**执行多次有多条重复记录,向量数据库不会去重,方便测试MMR**】
- ```
+ ```python
from langchain_community.embeddings import DashScopeEmbeddings
#from langchain.vectorstores import Milvus
from langchain_milvus import Milvus
@@ -9907,7 +9755,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 相似性搜索(向量数据库插入多个重复数据,看是否会返回一样的)
- ```
+ ```python
# 相似性搜索
query = "如何进行数据库集成?"
results = vector_store.similarity_search(query, k=2)
@@ -9926,7 +9774,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* MMR搜索(跨类搭配,向量数据库插入多个重复数据,看是否会返回一样的)
- ```
+ ```python
# MMR推荐(跨类搭配)
diverse_results = vector_store.max_marginal_relevance_search(
query="如何进行数据库集成",
@@ -9943,32 +9791,10 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
print(diverse_results)
```
-
-
-
-
-
-
-
-
-
-
-
+### Retrievers检索器+RAG文档助手项目实战
-
-
-
- **愿景:"IT路上的持续充电平台,让技术不再难学"**
-**更多高级课程请访问 xdclass.net**
-
-### 第四十二章 Retrievers检索器+RAG文档助手项目实战
-
-
-
-#### 第1集 LangChain检索器Retrievers案例实战
-
-**简介: LangChain检索器Retrievers案例实战**
+#### LangChain检索器Retrievers案例实战
* 什么是`Retriever`
@@ -9980,7 +9806,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* **RAG中的角色**:作为检索增强生成(RAG)流程的“数据入口”,为生成模型提供精准上下文
-
+
* 有多个实现:VectorStoreRetriever、MultiQueryRetriever、SelfQueryRetriever等
@@ -10004,7 +9830,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 基础使用参考案例
- ```
+ ```python
#将文档嵌入为向量,通过相似度计算(如余弦相似度)检索
from langchain_community.vectorstores import FAISS
retriever = FAISS.from_documents(docs, embeddings).as_retriever(
@@ -10019,7 +9845,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 源码
- ```
+ ```python
def as_retriever(self, **kwargs: Any) -> VectorStoreRetriever:
tags = kwargs.pop("tags", None) or [] + self._get_retriever_tags()
return VectorStoreRetriever(vectorstore=self, tags=tags, **kwargs)
@@ -10038,7 +9864,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
| `"mmr"` | 多样性结果优化 | `max_marginal_relevance_search()` |
| `"similarity_score_threshold"` | 阈值过滤检索 | `search()` + `score_threshold` |
- ```
+ ```python
# MMR 检索配置示例
mmr_retriever = vector_store.as_retriever(
search_type="mmr",
@@ -10062,7 +9888,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 默认是similarity search
- ````
+ ````python
from langchain_community.embeddings import DashScopeEmbeddings
from langchain_milvus import Milvus
from langchain_core.documents import Document
@@ -10114,28 +9940,11 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
retriever = vector_store.as_retriever(search_type="mmr",search_kwargs={"k": 2})
```
-
-
-
-
-
-
-
-
-
-
-
-
-
-#### 第2集 大厂面试题-如何提升大模型召回率和实战
-
-**简介: 大厂面试题-如何提升大模型召回率和案例实战**
+#### 大厂面试题-如何提升大模型召回率和实战
* **LLM大模型开发高频面试题:如何提升大模型召回率和准确率?**
-
-
* 需求背景
* 当原始查询不够明确时,或者当文档库中的内容使用不同的术语表达同一概念时
@@ -10152,11 +9961,11 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* **查询扩展技术**:通过LLM生成N个相关查询(如改写、扩展、翻译),合并结果去重,生成多个变体查询
* **双重增强效果**:提升召回率(+25%↑)和准确率(+18%↑)的平衡
- 
+ 
* 用法
- ```
+ ```python
retriever = MultiQueryRetriever.from_llm(
retriever=base_retriever,
llm=ChatOpenAI()
@@ -10172,7 +9981,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 案例实战
- ```
+ ```python
from langchain_community.embeddings import DashScopeEmbeddings
#from langchain.vectorstores import Milvus
from langchain_milvus import Milvus
@@ -10248,21 +10057,8 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
# print(vector_store)
```
-
-
-
-
-
-
-
-
-
-
-
-
-#### 第3集 RAG综合项目实战-AI文档问答助手《上》
-**简介: RAG综合项目实战-AI文档问答助手《上》**
+#### RAG综合项目实战-AI文档问答助手
* **需求:在线文档的问答助手,方便查找相关手册和接口API**
@@ -10282,24 +10078,24 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 向量存储与检索
-
+
- 使用`Milvus`作为向量数据库,创建名为`doc_qa_db`的Collection。
-
+
- 将生成的向量嵌入存储到Milvus中,并支持相似性检索。
* 基于RAG的问答
-
+
- 初始化`ChatOpenAI`模型,使用`qwen-plus`作为LLM模型。
-
+
- 定义`PromptTemplate`,用于构建输入给LLM的提示信息。
-
+
- 构建RAG链,结合相似性检索结果和LLM生成回答。
* 编码实战
- ```
+ ```python
from langchain_community.document_loaders import WebBaseLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_milvus import Milvus
@@ -10372,23 +10168,10 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
retriever = vector_store.as_retriever()
```
-
-
-
-
-
-
-
-
-
-
-#### 第4集 RAG综合项目实战-AI文档问答助手《下》
-
-**简介: RAG综合项目实战-AI文档问答助手《下》**
* 编码测试实战
- ```
+ ```python
# 定义PromptTemplate,用于构建输入给LLM的prompt。
template = """你是AI文档助手,使用以下上下文来回答最后的问题。
如果你不知道答案,就说你不知道,不要试图编造答案。
@@ -10424,7 +10207,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 大家的疑惑点(下一章讲解)
- ```
+ ```python
# 构建Retrieval-Augmented Generation链。
rag_chain = (
{"context": retriever, "question": RunnablePassthrough()}
@@ -10442,30 +10225,9 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* `retriever`完成检索后,会自动把结果赋值给`context`。
* 检索结果`context`和用户输入`question`一并传给提示模板`prompt_template`。
+### 解析和多实现类案例实战
-
-
-
-
-
-
-
-
-
-
-
-
-
- **愿景:"IT路上的持续充电平台,让技术不再难学"**
-**更多高级课程请访问 xdclass.net**
-
-### 第四十三章 Runnable深度解析和多实现类案例实战
-
-
-
-#### 第1集 LangChain核心之Runnable接口底层实现
-
-**简介: LangChain核心之Runnable接口底层实现**
+#### LangChain核心之Runnable接口底层实现
* 什么是`Runnable`接口
@@ -10494,7 +10256,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 执行 LCEL链调用的方法(invoke/stream/batch),链中的每个组件也调用对应的方法,将输出作为下一个组件的输入
- ```
+ ```python
#RunnableSequence.invoke 的源码解读
def invoke(
@@ -10543,7 +10305,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* Runnable接口定义了以下核心方法,支持多种执行模式
- ```
+ ```python
class Runnable(Generic[Input, Output]):
#处理单个输入,返回输出。
def invoke(self, input: Input) -> Output: ...
@@ -10571,23 +10333,13 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
| `RunnableParallel` | 并行执行 | 多任务独立处理 |
| `RunnablePassthrough` | 数据透传 | 保留原始输入 |
-
-
-
-
-
-
-
-
-#### 第2集 RunnablePassthrough介绍和透传参数实战
-
-**简介: RunnablePassthrough介绍和透传参数实战**
+#### RunnablePassthrough介绍和透传参数实战
* `RunnablePassthrough`
* 核心功能:用于在链中直接传递输入数据,不进行任何修改,或通过 `.assign()` 扩展上下文字段
- 
+ 
* 应用场景:
@@ -10596,7 +10348,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 基础用法
- ```
+ ```python
from langchain_core.runnables import RunnablePassthrough
# 直接传递输入
@@ -10608,7 +10360,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 案例一
- ```
+ ```python
# 使用 assign() 添加新字段
from langchain_core.runnables import RunnablePassthrough
@@ -10627,7 +10379,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 案例二(伪代码)
- ```
+ ```python
# 构建包含原始问题和处理上下文的链
chain = (
RunnablePassthrough.assign(
@@ -10651,7 +10403,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 检索结果`context`和用户输入`question`一并传给提示模板`prompt_template`。
* **输出**:模型根据检索到的上下文生成答案
- ```
+ ```python
from langchain_community.embeddings import DashScopeEmbeddings
from langchain_milvus import Milvus
from langchain_core.documents import Document
@@ -10704,15 +10456,8 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
print(result)
```
-
-
-
-
-
-#### 第3集 AI智能推荐实战之RunnableParallel并行链
-
-**简介: AI智能推荐实战之RunnableParallel并行链**
+#### AI智能推荐实战之RunnableParallel并行链
* `RunnableParallel` 介绍
@@ -10728,7 +10473,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 在 LCEL 链上,会将字典隐形转换为`RunnableParallel`
- ```
+ ```python
multi_retrieval_chain = (
RunnableParallel({
"context1": retriever1, #数据源一
@@ -10759,11 +10504,11 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
| **并行执行** | 所有子Runnable同时运行 | 3个任务耗时2秒(而非累加) |
| **类型安全** | 强制校验输入输出类型 | 自动检测字典字段类型 |
-
+
* API 与用法, 构造函数所有子链接收相同的输入
- ```
+ ```python
from langchain_core.runnables import RunnableParallel
runnable = RunnableParallel(
@@ -10794,7 +10539,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 多模型对比系统
- ```
+ ```python
model_comparison = RunnableParallel({
"gpt4": gpt4_chain,
"claude": claude_chain,
@@ -10804,7 +10549,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 智能文档处理系统
- ```
+ ```python
document_analyzer = RunnableParallel({
"summary": summary_chain, # 摘要生成
"toc": toc_generator, # 目录提取
@@ -10821,7 +10566,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 场景:并行生成景点与书籍推荐
- ```
+ ```python
from langchain_core.runnables import RunnableParallel
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
@@ -10865,17 +10610,8 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
print(output)
```
-
-
-
-
-
-
-
-#### 第4集 RunnableLambda介绍和包装链式函数实战
-
-**简介: RunnableLambda介绍和包装链式函数实战**
+#### RunnableLambda介绍和包装链式函数实战
* `RunnableLambda`
@@ -10908,7 +10644,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* API 与用法
- ```
+ ```python
from langchain_core.runnables import RunnableLambda
def log_input(x):
@@ -10922,7 +10658,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 基础文本处理链
- ```
+ ```python
from langchain_core.runnables import RunnableLambda
text_clean_chain = (
@@ -10937,7 +10673,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 打印中间结果并过滤敏感词(在链中插入自定义处理逻辑)
- ```
+ ```python
from langchain_core.runnables import RunnableLambda
from langchain_openai import ChatOpenAI
def filter_content(text: str) -> str:
@@ -10961,23 +10697,8 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
print(result) # 输出过滤后的结果
```
-
-
-
-
-
-
-
-
-
-
-
-
-
-#### 第5集 智能客服路由实战之RunnableBranch条件分支
-
-**简介: 智能客服路由实战之RunnableBranch条件分支**
+#### 智能客服路由实战之RunnableBranch条件分支
* `RunnableBranch`
@@ -10985,7 +10706,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* API 与用法
- ```
+ ```python
from langchain_core.runnables import RunnableBranch
#条件函数:接收输入,返回布尔值。
@@ -11007,7 +10728,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
"""
```
-
+
* 适合场景:
@@ -11028,7 +10749,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 智能路由系统(根据输入类型路由处理方式)
- ```
+ ```python
# 定义分类函数
def detect_topic(input_text):
if "天气" in input_text:
@@ -11063,7 +10784,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 导入依赖
- ```
+ ```python
from langchain_core.runnables import RunnableBranch, RunnableLambda
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
@@ -11072,7 +10793,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 定义模型
- ```
+ ```python
#定义模型
model = ChatOpenAI(
model_name = "qwen-plus",
@@ -11084,7 +10805,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 定义子链
- ```
+ ```python
# 技术支持链
tech_prompt = ChatPromptTemplate.from_template(
"你是一名技术支持专家,请回答以下技术问题:{input}"
@@ -11106,7 +10827,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 定义路由条件函数
- ```
+ ```python
def is_tech_question(input: dict) -> bool:
# 获取 "input" 键对应的值
input_value = input.get("input", "")
@@ -11122,7 +10843,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 构建 RunnableBranch
- ```
+ ```python
branch = RunnableBranch(
(is_tech_question, tech_chain), # 技术问题 → tech_chain
(is_billing_question, billing_chain), # 账单问题 → billing_chain
@@ -11134,7 +10855,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
* 测试案例
- ```
+ ```python
# 测试技术问题
tech_response = full_chain.invoke("我的账号登录失败,提示技术故障")
print("技术问题响应:", tech_response)
@@ -11169,7 +10890,7 @@ public JsonData list(@RequestParam(value = "parent_id")Long parentId){
- 添加日志中间件(通过 `RunnableLambda`)记录路由决策过程
- ```
+ ```python
def log_decision(input_data):
print(f"路由检查输入:{input_data}")
return input_data
diff --git a/img/0-2288864.png b/img/0-2288864.png
new file mode 100644
index 0000000..8df7513
Binary files /dev/null and b/img/0-2288864.png differ
diff --git a/img/0.png b/img/0.png
new file mode 100644
index 0000000..1594974
Binary files /dev/null and b/img/0.png differ
diff --git a/img/1-1073680.png b/img/1-1073680.png
new file mode 100644
index 0000000..303781c
Binary files /dev/null and b/img/1-1073680.png differ
diff --git a/img/1-1579900.png b/img/1-1579900.png
new file mode 100644
index 0000000..aec1667
Binary files /dev/null and b/img/1-1579900.png differ
diff --git a/img/1-1859494.png b/img/1-1859494.png
new file mode 100644
index 0000000..6c2dd9e
Binary files /dev/null and b/img/1-1859494.png differ
diff --git a/img/1-2537508.png b/img/1-2537508.png
new file mode 100644
index 0000000..22891ed
Binary files /dev/null and b/img/1-2537508.png differ
diff --git a/img/1-2540349.png b/img/1-2540349.png
new file mode 100644
index 0000000..3f0c2c0
Binary files /dev/null and b/img/1-2540349.png differ
diff --git a/img/1-2885071.png b/img/1-2885071.png
new file mode 100644
index 0000000..f172480
Binary files /dev/null and b/img/1-2885071.png differ
diff --git a/img/1-2901569.png b/img/1-2901569.png
new file mode 100644
index 0000000..c023169
Binary files /dev/null and b/img/1-2901569.png differ
diff --git a/img/1.png b/img/1.png
new file mode 100644
index 0000000..4073fd1
Binary files /dev/null and b/img/1.png differ
diff --git a/img/2-1580890.png b/img/2-1580890.png
new file mode 100644
index 0000000..19e6338
Binary files /dev/null and b/img/2-1580890.png differ
diff --git a/img/2-2287117.png b/img/2-2287117.png
new file mode 100644
index 0000000..8673f32
Binary files /dev/null and b/img/2-2287117.png differ
diff --git a/img/2-2540359.png b/img/2-2540359.png
new file mode 100644
index 0000000..bb22523
Binary files /dev/null and b/img/2-2540359.png differ
diff --git a/img/2-2902256.png b/img/2-2902256.png
new file mode 100644
index 0000000..11dede2
Binary files /dev/null and b/img/2-2902256.png differ
diff --git a/img/2.png b/img/2.png
new file mode 100644
index 0000000..eea5dbd
Binary files /dev/null and b/img/2.png differ
diff --git a/img/3-2540810.png b/img/3-2540810.png
new file mode 100644
index 0000000..65d095b
Binary files /dev/null and b/img/3-2540810.png differ
diff --git a/img/3-2907855.png b/img/3-2907855.png
new file mode 100644
index 0000000..a291fbd
Binary files /dev/null and b/img/3-2907855.png differ
diff --git a/img/4.png b/img/4.png
new file mode 100644
index 0000000..fbc2112
Binary files /dev/null and b/img/4.png differ
diff --git a/img/collection-explained.png b/img/collection-explained.png
new file mode 100644
index 0000000..e3baf84
Binary files /dev/null and b/img/collection-explained.png differ
diff --git a/img/export_4232z.png b/img/export_4232z.png
new file mode 100644
index 0000000..1465bab
Binary files /dev/null and b/img/export_4232z.png differ
diff --git a/img/export_a9yct.png b/img/export_a9yct.png
new file mode 100644
index 0000000..952b255
Binary files /dev/null and b/img/export_a9yct.png differ
diff --git a/img/export_j1u9v.png b/img/export_j1u9v.png
new file mode 100644
index 0000000..c7f03dc
Binary files /dev/null and b/img/export_j1u9v.png differ
diff --git a/img/export_qtyb85.png b/img/export_qtyb85.png
new file mode 100644
index 0000000..03cc425
Binary files /dev/null and b/img/export_qtyb85.png differ
diff --git a/img/image-20250301140503525.png b/img/image-20250301140503525.png
new file mode 100644
index 0000000..d2c8f5d
Binary files /dev/null and b/img/image-20250301140503525.png differ
diff --git a/img/image-20250301140529990.png b/img/image-20250301140529990.png
new file mode 100644
index 0000000..9670d7b
Binary files /dev/null and b/img/image-20250301140529990.png differ
diff --git a/img/image-20250301140650448.png b/img/image-20250301140650448.png
new file mode 100644
index 0000000..acef8db
Binary files /dev/null and b/img/image-20250301140650448.png differ
diff --git a/img/image-20250301141529448.png b/img/image-20250301141529448.png
new file mode 100644
index 0000000..46e8d17
Binary files /dev/null and b/img/image-20250301141529448.png differ
diff --git a/img/image-20250301152117731.png b/img/image-20250301152117731.png
new file mode 100644
index 0000000..bab12bc
Binary files /dev/null and b/img/image-20250301152117731.png differ
diff --git a/img/image-20250313142026018.png b/img/image-20250313142026018.png
new file mode 100644
index 0000000..292f052
Binary files /dev/null and b/img/image-20250313142026018.png differ
diff --git a/img/image-20250313151603856.png b/img/image-20250313151603856.png
new file mode 100644
index 0000000..73b20e2
Binary files /dev/null and b/img/image-20250313151603856.png differ
diff --git a/img/image-20250313151657094.png b/img/image-20250313151657094.png
new file mode 100644
index 0000000..e0a2b86
Binary files /dev/null and b/img/image-20250313151657094.png differ
diff --git a/img/image-20250313151724171.png b/img/image-20250313151724171.png
new file mode 100644
index 0000000..2a0f715
Binary files /dev/null and b/img/image-20250313151724171.png differ
diff --git a/img/image-20250313151918579.png b/img/image-20250313151918579.png
new file mode 100644
index 0000000..d3dfde2
Binary files /dev/null and b/img/image-20250313151918579.png differ
diff --git a/img/image-20250313161943645.png b/img/image-20250313161943645.png
new file mode 100644
index 0000000..1eebb76
Binary files /dev/null and b/img/image-20250313161943645.png differ
diff --git a/img/image-20250313162742811.png b/img/image-20250313162742811.png
new file mode 100644
index 0000000..b6f711f
Binary files /dev/null and b/img/image-20250313162742811.png differ
diff --git a/img/image-20250313162827278.png b/img/image-20250313162827278.png
new file mode 100644
index 0000000..231f2e8
Binary files /dev/null and b/img/image-20250313162827278.png differ
diff --git a/img/image-20250313164754696.png b/img/image-20250313164754696.png
new file mode 100644
index 0000000..57c8f86
Binary files /dev/null and b/img/image-20250313164754696.png differ
diff --git a/img/image-20250313170520819.png b/img/image-20250313170520819.png
new file mode 100644
index 0000000..3dae382
Binary files /dev/null and b/img/image-20250313170520819.png differ
diff --git a/img/image-20250313170904153.png b/img/image-20250313170904153.png
new file mode 100644
index 0000000..19ac851
Binary files /dev/null and b/img/image-20250313170904153.png differ
diff --git a/img/image-20250313210027704.png b/img/image-20250313210027704.png
new file mode 100644
index 0000000..eb58111
Binary files /dev/null and b/img/image-20250313210027704.png differ
diff --git a/img/image-20250313212722723.png b/img/image-20250313212722723.png
new file mode 100644
index 0000000..18fdb8d
Binary files /dev/null and b/img/image-20250313212722723.png differ
diff --git a/img/image-20250313215608473.png b/img/image-20250313215608473.png
new file mode 100644
index 0000000..b644103
Binary files /dev/null and b/img/image-20250313215608473.png differ
diff --git a/img/image-20250314122237372.png b/img/image-20250314122237372.png
new file mode 100644
index 0000000..342612d
Binary files /dev/null and b/img/image-20250314122237372.png differ
diff --git a/img/image-20250315152627015.png b/img/image-20250315152627015.png
new file mode 100644
index 0000000..4cfac3d
Binary files /dev/null and b/img/image-20250315152627015.png differ
diff --git a/img/image-20250318151846918.png b/img/image-20250318151846918.png
new file mode 100644
index 0000000..752a7c8
Binary files /dev/null and b/img/image-20250318151846918.png differ
diff --git a/img/image-20250318155633751.png b/img/image-20250318155633751.png
new file mode 100644
index 0000000..0d0498b
Binary files /dev/null and b/img/image-20250318155633751.png differ
diff --git a/img/image-20250318190605311.png b/img/image-20250318190605311.png
new file mode 100644
index 0000000..9172b4e
Binary files /dev/null and b/img/image-20250318190605311.png differ
diff --git a/img/image-20250318201255473.png b/img/image-20250318201255473.png
new file mode 100644
index 0000000..bff38dd
Binary files /dev/null and b/img/image-20250318201255473.png differ
diff --git a/img/milvus-adopters.png b/img/milvus-adopters.png
new file mode 100644
index 0000000..529db03
Binary files /dev/null and b/img/milvus-adopters.png differ