Compare commits
10
Commits
caf8088eac
...
05cb6eacbc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05cb6eacbc | ||
|
|
5ee2f664ff | ||
|
|
6517df00ff | ||
|
|
6215bbc845 | ||
|
|
b947679b07 | ||
|
|
983cb4e13c | ||
|
|
ffd7e9372b | ||
|
|
d2648fc2a1 | ||
|
|
cf504582be | ||
|
|
3b8aab8984 |
@@ -44,17 +44,21 @@
|
||||
| 🧠 **智能篇** | [10 MCP 基础 (Server)](https://github.com/Annyfee/agent-craft/tree/main/m10_mcp_basics) | [🏠](https://blog.csdn.net/2401_87328929/article/details/155660129) | Stdio · Streamable HTTP · FastMCP框架 · Transport通信 · 构建私有 MCP | ⭐⭐ |
|
||||
| | [11 MCP 进阶 (Client)](https://github.com/Annyfee/agent-craft/tree/main/m11_mcp_advanced) | [🏠](https://blog.csdn.net/2401_87328929/article/details/155316396) | langchain-mcp-adapters框架 · 流式输出 · AsyncExitStack · 连接公共MCP | ⭐⭐⭐ |
|
||||
| | [12 Agents SDK & Swarm 模式](https://github.com/Annyfee/agent-craft/tree/main/m12_agents_sdk_swarm) | [🏠](https://blog.csdn.net/2401_87328929/article/details/155890608) | Swarm · Handoff · Agents SDK · 去中心化 ·“航空公司客服”项目 | ⭐⭐⭐⭐ |
|
||||
| 🏁 **实战篇** | [13 Streamlit 快速入门](https://blog.csdn.net/2401_87328929/article/details/156131372) | [🏠](https://github.com/Annyfee/agent-craft/tree/main/m13_streamlit) | Streamlit · st.chat_message · 异步事件流 · 会话持久化 · “智能客服驾驶舱” | ⭐⭐⭐ |
|
||||
| 🏁 **实战篇** | [13 Streamlit 快速入门](https://github.com/Annyfee/agent-craft/tree/main/m13_streamlit) | [🏠](https://blog.csdn.net/2401_87328929/article/details/156131372) | Streamlit · st.chat_message · 异步事件流 · 会话持久化 · “智能客服驾驶舱” | ⭐⭐⭐ |
|
||||
| | 14 综合实战项目 | 🚧撰写中 | LangGraph + RAG + MCP + Streamlit + Vercel | ⭐⭐⭐⭐⭐ |
|
||||
| 🚀 **工程篇** | 15 部署上线与项目总结 | 🚧 | `Ollama` · `LM Studio` · `LangServe` | ⭐⭐⭐ |
|
||||
|
||||
---
|
||||
|
||||
## 🧩 当前学习建议(适用于已完成模块)
|
||||
## 🧩 各模块详细学习建议
|
||||
|
||||
目前已开放模块:**01 ~ 13**。
|
||||
建议按顺序学习,每一章都有完整代码示例与注释。
|
||||
|
||||
<details>
|
||||
|
||||
<summary>💡 点击展开 / 收起各模块学习目标与内容详情</summary>
|
||||
|
||||
### ✅ 模块 01 — Agent 入门 & 环境搭建
|
||||
|
||||
- **目标**:理解 Agent 概念,完成环境配置与首次调用。
|
||||
@@ -122,6 +126,8 @@
|
||||
|
||||
> 📌 后续模块将陆续开放(综合实战等)
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
## 🧠 Agent Craft 的核心学习路径
|
||||
@@ -197,6 +203,6 @@ python "m01_agent_introduction/Agent-demo.py"
|
||||
- 📩 技术交流:微信 a19731567148(备注 Agent)
|
||||
- 📚 博客主页:[CSDN 主页](https://blog.csdn.net/2401_87328929)
|
||||
|
||||
🌟 如果这个项目帮到了你,请给我点个 Star ⭐,让更多人看到它!
|
||||
|
||||
🌟 如果这个项目帮到了你,请给我点个 Star ⭐,这将是我持续更新的最大动力!
|
||||
|
||||
[](https://star-history.com/#Annyfee/agent-craft&Date)
|
||||
+1
-1
@@ -2,6 +2,7 @@
|
||||
|
||||
from pathlib import Path
|
||||
from langchain_huggingface import HuggingFaceEmbeddings
|
||||
from huggingface_hub import snapshot_download
|
||||
|
||||
# 获取embeddings模型 -- 首次调用时自动下载
|
||||
def get_embeddings(model_name="BAAI/bge-small-zh-v1.5",device="cpu",**kwargs):
|
||||
@@ -10,7 +11,6 @@ def get_embeddings(model_name="BAAI/bge-small-zh-v1.5",device="cpu",**kwargs):
|
||||
if not local_dir.exists():
|
||||
print(f'⚠️ 首次使用嵌入模型,正在下载到{local_dir.absolute()}')
|
||||
print("💡 提示:需要联网(必需梯子),完成后可离线使用")
|
||||
from huggingface_hub import snapshot_download
|
||||
# 模型下载工具
|
||||
snapshot_download(
|
||||
repo_id = model_name,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
## 🧩 模块说明:LLM 调用与多轮对话 Agent
|
||||
|
||||
|
||||
📌 **核心知识点**:
|
||||
LLM 调用|Prompt 编写与设计|多轮对话记忆|独立搭建智能体
|
||||
|
||||
@@ -27,3 +28,17 @@ LLM 调用|Prompt 编写与设计|多轮对话记忆|独立搭建智能体
|
||||
- 多轮对话如何保持上下文
|
||||
- Prompt 结构设计
|
||||
- 记忆模块(Memory)的基本用法
|
||||
|
||||
---
|
||||
|
||||
### 3. `s03_llm_temperature`(温度参数对输出的影响)
|
||||
演示不同 temperature 参数对 LLM 输出多样性和创造性的影响。
|
||||
|
||||
🔧 使用提示:
|
||||
想测试不同温度参数的效果?
|
||||
👉 直接修改代码中的 `temperature` 值即可(范围通常为 0-2)。
|
||||
|
||||
✅ 掌握点:
|
||||
- temperature 参数的作用和影响
|
||||
- 如何根据场景选择合适的温度值
|
||||
- 低温度(稳定)与高温度(随机)输出的对比
|
||||
@@ -0,0 +1,30 @@
|
||||
from config import OPENAI_API_KEY
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(api_key=OPENAI_API_KEY, base_url="https://api.deepseek.com")
|
||||
msg = [{"role": "user", "content": "请用一句话生动形象地描述量子力学的奇妙之处。"}]
|
||||
|
||||
response_low_temperature = client.chat.completions.create(
|
||||
model="deepseek-chat",
|
||||
messages=[
|
||||
{"role": "system", "content": "你是一个科学解说员,请用生动形象的语言回答问题。"}, # 提示词角色
|
||||
{"role": "user", "content": "请用一句话描述量子力学的奇妙之处。"}, # 用户输入的对话
|
||||
],
|
||||
temperature=0.1
|
||||
)
|
||||
|
||||
response_high_temperature = client.chat.completions.create(
|
||||
model="deepseek-chat",
|
||||
messages=[
|
||||
{"role": "system", "content": "你是一个科学解说员,请用生动形象的语言回答问题。"}, # 提示词角色
|
||||
{"role": "user", "content": "请用一句话描述量子力学的奇妙之处。"}, # 用户输入的对话
|
||||
],
|
||||
temperature=1.3
|
||||
)
|
||||
|
||||
|
||||
# 测试1:低温度 (稳定)
|
||||
print(f"温度 0.1: {response_low_temperature.choices[0].message.content}")
|
||||
|
||||
# 测试2:高温度 (随机)
|
||||
print(f"温度 1.3: {response_high_temperature.choices[0].message.content}")
|
||||
@@ -38,7 +38,7 @@ print('---Chroma数据库已加载---\n')
|
||||
# --- 模块 B (R-A-G Flow) ---
|
||||
# 1. R-检索--强化版
|
||||
# 1.1 基础检索器(Base Retriever) - '粗召回'
|
||||
base_retriever = db.as_retriever(search_kwargs={"k":50}) # K调大到60
|
||||
base_retriever = db.as_retriever(search_kwargs={"k":50}) # K调大到50
|
||||
# 1.2 Reranker (重排器) - "精排序" -- 首次运行需要耗时下载
|
||||
print('正在加载 Reranker模型 (bge-reranker-base)...')
|
||||
encoder = HuggingFaceCrossEncoder(model_name="BAAI/bge-reranker-base") # 加载Ranker模型
|
||||
|
||||
@@ -16,7 +16,6 @@ from langchain_community.chat_message_histories import ChatMessageHistory
|
||||
from langchain_core.runnables import RunnableWithMessageHistory
|
||||
|
||||
|
||||
|
||||
# 1. 构建一个可复用的 RAG链条
|
||||
def build_rag_chain(llm_instance):
|
||||
print('---正在构建RAG链条---')
|
||||
@@ -144,27 +143,3 @@ if __name__ == '__main__':
|
||||
config={'configurable':{'session_id':session_id}}
|
||||
)
|
||||
print(f"AI:{response['output']}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,9 +37,12 @@ st.caption(f"🚀 实战三:基于 Agents SDK 的多智能体协作 (ID: {st.s
|
||||
|
||||
# 初始化持久化 Session
|
||||
if "session" not in st.session_state:
|
||||
# 使用绝对路径定位数据库,确保跨环境稳定性
|
||||
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
st.session_state.session = SQLiteSession( # 持久化内存,将AI对话历史搬到数据库中
|
||||
session_id=st.session_state.session_id,
|
||||
db_path="./m13_streamlit/conversations.db"
|
||||
db_path=os.path.join(PROJECT_ROOT, "m13_streamlit", "conversations.db")
|
||||
)
|
||||
|
||||
if "display_messages" not in st.session_state: # 存储对话记录
|
||||
|
||||
Reference in New Issue
Block a user