[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-onlyphantom--llm-python":3,"tool-onlyphantom--llm-python":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":80,"owner_email":81,"owner_twitter":82,"owner_website":83,"owner_url":84,"languages":85,"stars":94,"forks":95,"last_commit_at":96,"license":97,"difficulty_score":23,"env_os":98,"env_gpu":99,"env_ram":100,"env_deps":101,"category_tags":111,"github_topics":112,"view_count":23,"oss_zip_url":82,"oss_zip_packed_at":82,"status":16,"created_at":122,"updated_at":123,"faqs":124,"releases":154},2276,"onlyphantom\u002Fllm-python","llm-python","Large Language Models (LLMs) tutorials & sample scripts, ft. langchain, openai, llamaindex, gpt, chromadb & pinecone","llm-python 是一套专为 Python 开发者打造的开源学习资源库，汇集了构建大语言模型（LLM）应用所需的教程、代码示例和实战脚本。它旨在解决初学者在入门 LLM 开发时面临的“理论多、实操少”的痛点，通过提供独立且聚焦的代码片段，帮助用户快速掌握如何利用 LangChain、LlamaIndex、OpenAI、ChromaDB 及 Pinecone 等主流框架搭建智能应用。\n\n无论是希望构建问答系统、本地知识库查询工具，还是想尝试离线部署开源模型或开发 AI 游戏，llm-python 都提供了从基础 API 调用到复杂 Agent 构建的完整路径。其独特亮点在于“视频 + 代码”的双模教学模式：每个核心概念都配有作者亲自讲解的 YouTube 视频教程，并与仓库中的自包含代码一一对应，让用户能边看边练，直观理解嵌入向量、提示词工程及缓存优化等关键技术。\n\n这套资源非常适合具有一定 Python 基础的软件工程师、技术爱好者及希望转型 AI 领域的研究人员使用。如果你不想被冗长的文档劝退，而是希望通过动手实践快速上手大模型开发，llm-python 将是你理想的起步伙伴。","# llm-python\n\nA set of instructional materials, code samples and Python scripts featuring LLMs (GPT etc) through interfaces like llamaindex, LangChain, OpenAI's Agent SDK, Chroma (Chromadb), Pinecone etc.\n\nThe code examples are aimed at helping you learn how to build LLM applications and Agents using Python. The code is designed to be self-contained and singularly focused, so you can pick and choose the usage patterns most relevant to your needs.\n\nMany examples have accompanying videos [on my YouTube channel](https:\u002F\u002Fwww.youtube.com\u002Fsamuelchan).\n\n\u003C!-- \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fonlyphantom_llm-python_readme_408188b8f5a6.png\" width=\"50%\" alt=\"LangChain youtube tutorials\" \u002F> -->\n\n![LangChain youtube tutorials](assets\u002Fllmseries.png)\n\nLearn LangChain from my YouTube channel (~9 hours of LLM hands-on building tutorials); Each lesson is accompanied by the corresponding code in this repo and is designed to be self-contained -- while still focused on some key concepts in LLM (large language model) development and tooling.\n\nFeel free to pick and choose your starting point based on your learning goals:\n\n| Part | LLM Tutorial                                                                         | Link                                                          | Video Duration |\n| ---- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------- | -------------- |\n| 1    | OpenAI tutorial and video walkthrough                                                | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002Fskw-togjY7Q)                | 26:56          |\n| 2    | LangChain + OpenAI tutorial: Building a Q&A system w\u002F own text data                  | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002FDYOU_Z0hAwo)                | 20:00          |\n| 3    | LangChain + OpenAI to chat w\u002F (query) own Database \u002F CSV                             | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002FFz0WJWzfNPI)                | 19:30          |\n| 4    | LangChain + HuggingFace's Inference API (no OpenAI credits required!)                | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002FdD_xNmePdd0)                | 24:36          |\n| 5    | Understanding Embeddings in LLMs                                                     | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002F6uyBc0jm1xQ)                | 29:22          |\n| 6    | Query any website with LLamaIndex + GPT3 (ft. Chromadb, Trafilatura)                 | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002F6K1lyyzpxtk)                | 11:11          |\n| 7    | Locally-hosted, offline LLM w\u002FLlamaIndex + OPT (open source, instruction-tuning LLM) | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002FqAvHs6UNb2k)                | 32:27          |\n| 8    | Building an AI Language Tutor: Pinecone + LlamaIndex + GPT-3 + BeautifulSoup         | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002Fk8G1EDZgF1E)                | 51:08          |\n| 9    | Building a queryable journal 💬 w\u002F OpenAI, markdown & LlamaIndex 🦙                  | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002FOzDhJOR5IfQ)                | 40:29          |\n| 10   | Making a Sci-Fi game w\u002F Cohere LLM + Stability.ai: Generative AI tutorial            | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002FuR93yTNGtP4)                | 1:02:20        |\n| 11   | GPT builds entire party invitation app from prompt (ft. SMOL Developer)              | [Tutorial Video](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=Ll_VIsIjuFg) | 41:33          |\n| 12   | A language for LLM prompt design: Guidance                                           | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002Fk4Ejc3bLQiU)                | 43:15          |\n| 13   | You should use LangChain's Caching!                                                  | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002FUk_SJSnQRU8)                | 25:37          |\n| 14   | Build Chat AI apps with Steamlit + LangChain                                         | [Tutorial Video](https:\u002F\u002Fyoutu.be\u002F7QR6hXx_Nms)                | 32:11          |\n\nThe full lesson playlist can be found [here](https:\u002F\u002Fwww.youtube.com\u002Fplaylist?list=PLXsFtK46HZxUQERRbOmuGoqbMD-KWLkOS).\n\n## Updates\n\n### Multi-Agent and Agentic Patterns Update: May 3rd 2025\n\nI've pushed 6 new scripts to the repo, `19_agents_handsoff.py` to `24_agents_guardrails.py`, intended to be used as code reference to this public course:\n\n- [Agentic Patterns: two day workshop](https:\u002F\u002Fsupertype.ai\u002Fevents\u002Fagentic-patterns)\n\nThese additions to the repo illustrates 6 key patterns in building AI Agents (especially multi-agent systems) and use the latest version of OpenAI's Agent SDK (`openai-agents`) as of May 2025.\n\nThese 6 Agentic Patterns are (in order of appearance in this repo):\n\n- 1 The Hand-off and Delegation Pattern (`19_agents_handsoff.py`)\n- 2 The Tool-Use and Function Calling Pattern (`20_agents_tooluse.py`)\n- 3 The Deterministic and Sequential Chain Pattern (`21_agents_deterministic.py`)\n- 4 The Judge and Critic Pattern (`22_agents_critic.py`)\n- 5 The Parallelization Pattern (`23_agents_parallelization.py`)\n- 6 The Guardrails Pattern (`24_agents_guardrails.py`)\n\n### Update: Feb 5th 2025\n\nI've pushed 4 new scripts to the repo, `15_sql.py` to `18_chroma.py`, which are intended to be used as code reference to this public course:\n\n- [Building search engines in the age of AI: full course materials (free)](https:\u002F\u002Fsectors.app\u002Fbulletin\u002Fai-search)\n- [Building search engines in the age of AI: two day workshop](https:\u002F\u002Fsupertype.ai\u002Fevents\u002Fai-search)\n\nAdditionally, I'm now also hosting example code in this repo for the following [Generative AI Series](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F01-background) by Sectors.\n\n1. [Generative AI for Finance](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F01-background): An overview of designing Generative AI systems for the finance industry and the motivation for retrieval-augmented generation (RAG) systems.\n\n2. [Tool-Use Retrieval Augmented Generation (RAG)](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F02-tool-use): Practical guide to building RAG systems leveraging on information retrieval tools (known as \"tool-use\" or \"function-calling\" in LLM)\n\n3. [Structured Output from AIs](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F03-structured-output): From using Generative AI to extract from unstructured data or perform actions like database queries, API calls, JSON parsing and more, we need schema and structure in the AI's output.\n\n4. [Tool-use ReAct Agents w\u002F Streaming](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F04-conversational): Updated for LangChain v0.3.2, we explore streaming, LCEL expressions and ReAct agents following the most up-to-date practices for creating conversational AI agents.\n\n5. [Conversational Memory AI Agents](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F05-memory-ai): Updated for LangChain v0.2.3, we dive into Creating AI Agents with Conversational Memory\n\nBoth of these series are public and free to access. The code in this repo is intended to be used as a reference for these courses.\n\n### Quick Start\n\n1. Clone this repo\n2. Install requirements: `pip install -r requirements.txt`\n3. Some sample data are provided to you in the `news` foldeer, but you can use your own data by replacing the content (or adding to it) with your own text files.\n4. Create a `.env` file which contains your OpenAI API key. You can get one from [here](https:\u002F\u002Fbeta.openai.com\u002F). `HUGGINGFACEHUB_API_TOKEN` and `PINECONE_API_KEY` are optional, but they are used in some of the lessons.\n   - [Lesson 10](.\u002F11_worldbuilding.py) uses Cohere and Stability AI, both of which offers a free tier (no credit card required). You can add the respective keys as `COHERE_API_KEY` and `STABILITY_API_KEY` in the `.env` file.\n   - Some of the most advanced examples that feature tool-use, function-calling Agents will require you working with a real-world financial data API. My team at Supertype and I built a LLM-first financial API platform called [Sectors](https:\u002F\u002Fsectors.app). You can register for a free account, read our [API documentation and Generative AI 5-course series](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F01-background) to learn how to use the API to build sophisticated LLM application. Examples of these applications are all in the repo.\n\nYour `.env` file should look like this:\n\n```\n# recommended\nOPENAI_API_KEY=...\n\n# optionals but useful\nSECTORS_API_KEY=...\nGROQ_API_KEY=...\n\n# completely optional (pick and choose based on your needs)\nHUGGINGFACEHUB_API_TOKEN=...\nPINECONE_API_KEY=...\nDEEPSEEK_API_KEY=...\nCOHERE_API_KEY=...\nSTABILITY_API_KEY=...\n```\n\nHuggingFace and Pinecone are optional but is recommended if you want to use the Inference API and explore those models outside of the OpenAI ecosystem. This is demonstrated in Part 3 of the tutorial series.\n\n5. Run the examples in any order you want. For example, `python 6_team.py` will run the website Q&A example, which uses GPT-3 to answer questions about a company and the team of people working at Supertype.ai. Watch the corresponding video to follow along each of the examples.\n\n### Dependencies\n\n> 💡 Thanks to the work of @VanillaMacchiato, this project is updated as of **2023-06-30** to use the latest version of LlamaIndex (0.6.31) and LangChain (0.0.209). Installing the dependencies should be as simple as `pip install -r requirements.txt`. If you encounter any issues, please let me know.\n>\n> If you're watching the LLM video tutorials, they may have very minor differences (typically 1-2 lines of code that needs to be changed) from the code in this repo since these videos have been released with the respective versions at the time of recording (LlamaIndex 0.5.7 and LangChain 0.0.157). Please refer to the code in this repo for the latest version of the code.\n\nI will try to keep this repo up to date with the latest version of the libraries, but if you encounter any issues, please: (1) raise a discussion through Issues or (2) volunteer a PR to update the code.\n\nNOTE: `triton` package is supported only for the **x86_64** architecture. If you have problems with installing it, see the [triton compatibility guide](https:\u002F\u002Fgithub.com\u002Fopenai\u002Ftriton?tab=readme-ov-file#compatibility). Specifically, errors like `ERROR: Could not find a version that satisfies the requirement triton (from versions: none)\nERROR: No matching distribution found for triton`.\n`uname -p` should give you the processor's name.\n\n### Mentorship and Support\n\nI run a mentorship program under [Supertype Fellowship](https:\u002F\u002Ffellowship.supertype.ai). The program is self-paced and free, with a community of other learners and practitioners around the world (English-speaking). You can optionally book a 1-on-1 session with my team of mentors to help you through video tutoring and code reviews.\n\n### License\n\nMIT © [Supertype](https:\u002F\u002Fsupertype.ai) 2024\n","# llm-python\n\n一组教学材料、代码示例和 Python 脚本，重点介绍使用 LLM（如 GPT 等）并通过 llamaindex、LangChain、OpenAI 的 Agent SDK、Chroma (Chromadb)、Pinecone 等接口实现的应用。\n\n这些代码示例旨在帮助您学习如何使用 Python 构建 LLM 应用程序和智能体。代码设计为自包含且目标单一，您可以根据自身需求选择最相关的使用模式。\n\n许多示例都配有视频，可在我的 YouTube 频道观看：[samuelchan](https:\u002F\u002Fwww.youtube.com\u002Fsamuelchan)。\n\n\u003C!-- \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fonlyphantom_llm-python_readme_408188b8f5a6.png\" width=\"50%\" alt=\"LangChain youtube tutorials\" \u002F> -->\n\n![LangChain YouTube 教程](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fonlyphantom_llm-python_readme_09972fe14b81.png)\n\n通过我的 YouTube 频道学习 LangChain（约 9 小时的 LLM 实战构建教程）；每节课都附有本仓库中的对应代码，并且设计为自包含——同时聚焦于 LLM（大型语言模型）开发与工具链中的关键概念。\n\n请根据您的学习目标自由选择起点：\n\n| 部分 | LLM 教程                                                                         | 链接                                                          | 视频时长 |\n| ---- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------- | ---------- |\n| 1    | OpenAI 教程及视频演示                                                            | [教程视频](https:\u002F\u002Fyoutu.be\u002Fskw-togjY7Q)                | 26 分 56 秒          |\n| 2    | LangChain + OpenAI 教程：基于自有文本数据构建问答系统                  | [教程视频](https:\u002F\u002Fyoutu.be\u002FDYOU_Z0hAwo)                | 20 分钟          |\n| 3    | LangChain + OpenAI 与自有数据库\u002FCSV 对话                             | [教程视频](https:\u002F\u002Fyoutu.be\u002FFz0WJWzfNPI)                | 19 分 30 秒          |\n| 4    | LangChain + HuggingFace 推理 API（无需 OpenAI 积分！）                | [教程视频](https:\u002F\u002Fyoutu.be\u002FdD_xNmePdd0)                | 24 分 36 秒          |\n| 5    | 理解 LLM 中的嵌入技术                                                     | [教程视频](https:\u002F\u002Fyoutu.be\u002F6uyBc0jm1xQ)                | 29 分 22 秒          |\n| 6    | 使用 LlamaIndex + GPT3 查询任意网站（结合 Chromadb、Trafilatura）                 | [教程视频](https:\u002F\u002Fyoutu.be\u002F6K1lyyzpxtk)                | 11 分 11 秒          |\n| 7    | 使用 LlamaIndex + OPT 在本地部署离线 LLM（开源、指令微调 LLM） | [教程视频](https:\u002F\u002Fyoutu.be\u002FqAvHs6UNb2k)                | 32 分 27 秒          |\n| 8    | 构建 AI 语言辅导助手：Pinecone + LlamaIndex + GPT-3 + BeautifulSoup         | [教程视频](https:\u002F\u002Fyoutu.be\u002Fk8G1EDZgF1E)                | 51 分 08 秒          |\n| 9    | 使用 OpenAI、Markdown 和 LlamaIndex 🦙 构建可查询的日志 💬                  | [教程视频](https:\u002F\u002Fyoutu.be\u002FOzDhJOR5IfQ)                | 40 分 29 秒          |\n| 10   | 使用 Cohere LLM + Stability.ai 制作科幻游戏：生成式 AI 教程            | [教程视频](https:\u002F\u002Fyoutu.be\u002FuR93yTNGtP4)                | 1 小时 02 分 20 秒        |\n| 11   | GPT 根据提示词构建完整的派对邀请应用（联合 SMOL Developer）              | [教程视频](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=Ll_VIsIjuFg) | 41 分 33 秒          |\n| 12   | 一种用于 LLM 提示词设计的语言：指导原则                                           | [教程视频](https:\u002F\u002Fyoutu.be\u002Fk4Ejc3bLQiU)                | 43 分 15 秒          |\n| 13   | 您应该使用 LangChain 的缓存功能！                                                  | [教程视频](https:\u002F\u002Fyoutu.be\u002FUk_SJSnQRU8)                | 25 分 37 秒          |\n| 14   | 使用 Streamlit + LangChain 构建聊天 AI 应用                                         | [教程视频](https:\u002F\u002Fyoutu.be\u002F7QR6hXx_Nms)                | 32 分 11 秒          |\n\n完整课程播放列表请见：[这里](https:\u002F\u002Fwww.youtube.com\u002Fplaylist?list=PLXsFtK46HZxUQERRbOmuGoqbMD-KWLkOS)。\n\n## 更新\n\n### 多智能体与代理模式更新：2025 年 5 月 3 日\n\n我向仓库推送了 6 个新脚本，从 `19_agents_handsoff.py` 到 `24_agents_guardrails.py`，旨在作为本公开课程的代码参考：\n\n- [代理模式：为期两天的工作坊](https:\u002F\u002Fsupertype.ai\u002Fevents\u002Fagentic-patterns)\n\n这些新增内容展示了构建 AI 智能体（尤其是多智能体系统）的 6 种关键模式，并采用了截至 2025 年 5 月的最新版 OpenAI Agent SDK (`openai-agents`)。\n\n这 6 种代理模式按在本仓库中的出现顺序如下：\n\n- 1 手动交接与委派模式 (`19_agents_handsoff.py`)\n- 2 工具使用与函数调用模式 (`20_agents_tooluse.py`)\n- 3 确定性与顺序链模式 (`21_agents_deterministic.py`)\n- 4 评判与批评模式 (`22_agents_critic.py`)\n- 5 并行化模式 (`23_agents_parallelization.py`)\n- 6 安全约束模式 (`24_agents_guardrails.py`)\n\n### 更新：2025 年 2 月 5 日\n\n我向仓库推送了 4 个新脚本，从 `15_sql.py` 到 `18_chroma.py`，旨在作为以下公开课程的代码参考：\n\n- [AI 时代下的搜索引擎构建：完整课程资料（免费）](https:\u002F\u002Fsectors.app\u002Fbulletin\u002Fai-search)\n- [AI 时代下的搜索引擎构建：为期两天的工作坊](https:\u002F\u002Fsupertype.ai\u002Fevents\u002Fai-search)\n\n此外，我还在此仓库中托管了 Sectors 发布的 [生成式 AI 系列](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F01-background) 的示例代码。\n\n1. [金融领域的生成式 AI](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F01-background)：概述了为金融行业设计生成式 AI 系统的方法，以及检索增强生成（RAG）系统的动机。\n\n2. [工具使用型检索增强生成（RAG）](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F02-tool-use)：利用信息检索工具构建 RAG 系统的实用指南（在 LLM 中称为“工具使用”或“函数调用”）。\n\n3. [AI 的结构化输出](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F03-structured-output)：从使用生成式 AI 从非结构化数据中提取信息，到执行数据库查询、API 调用、JSON 解析等操作，AI 的输出都需要明确的模式和结构。\n\n4. [带有流式处理的 ReAct 智能体](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F04-conversational)：针对 LangChain v0.3.2 进行了更新，我们探讨了流式处理、LCEL 表达式以及 ReAct 智能体，遵循创建对话型 AI 智能体的最新实践。\n\n5. [具有会话记忆的 AI 智能体](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F05-memory-ai)：针对 LangChain v0.2.3 进行了更新，深入探讨了具有会话记忆的 AI 智能体的创建方法。\n\n以上两个系列均为公开且免费开放。本仓库中的代码旨在作为这些课程的参考。\n\n### 快速入门\n\n1. 克隆此仓库\n2. 安装依赖：`pip install -r requirements.txt`\n3. `news` 文件夹中提供了一些示例数据，但你也可以用自己的数据替换（或添加）文本文件。\n4. 创建一个 `.env` 文件，其中包含你的 OpenAI API 密钥。你可以从 [这里](https:\u002F\u002Fbeta.openai.com\u002F) 获取。`HUGGINGFACEHUB_API_TOKEN` 和 `PINECONE_API_KEY` 是可选的，但在部分课程中会用到。\n   - [第 10 课](.\u002F11_worldbuilding.py) 使用了 Cohere 和 Stability AI，两者都提供免费层级（无需信用卡）。你可以在 `.env` 文件中添加相应的密钥：`COHERE_API_KEY` 和 `STABILITY_API_KEY`。\n   - 一些涉及工具使用和函数调用智能体的高级示例，需要与真实的金融数据 API 集成。我和 Supertype 团队构建了一个以 LLM 为核心的金融 API 平台 [Sectors](https:\u002F\u002Fsectors.app)。你可以注册一个免费账户，阅读我们的 [API 文档和生成式 AI 五课系列](https:\u002F\u002Fdocs.sectors.app\u002Frecipes\u002Fgenerative-ai-python\u002F01-background)，学习如何使用该 API 构建复杂的 LLM 应用程序。这些应用的示例都包含在本仓库中。\n\n你的 `.env` 文件应如下所示：\n\n```\n# 推荐\nOPENAI_API_KEY=...\n\n# 可选但有用\nSECTORS_API_KEY=...\nGROQ_API_KEY=...\n\n# 完全可选（根据需求选择）\nHUGGINGFACEHUB_API_TOKEN=...\nPINECONE_API_KEY=...\nDEEPSEEK_API_KEY=...\nCOHERE_API_KEY=...\nSTABILITY_API_KEY=...\n```\n\nHuggingFace 和 Pinecone 是可选的，但如果你希望使用推理 API 并探索 OpenAI 生态之外的模型，建议安装。这在教程系列的第 3 部分中有演示。\n5. 按任意顺序运行示例。例如，`python 6_team.py` 将运行网站问答示例，该示例使用 GPT-3 回答关于公司及 Supertype.ai 团队成员的问题。观看对应的视频，可以跟随每个示例的操作步骤。\n\n### 依赖项\n\n> 💡 感谢 @VanillaMacchiato 的工作，该项目已于 **2023-06-30** 更新至使用最新版本的 LlamaIndex (0.6.31) 和 LangChain (0.0.209)。安装依赖只需执行 `pip install -r requirements.txt` 即可。如遇任何问题，请随时告知我。\n>\n> 如果你正在观看 LLM 视频教程，它们可能与本仓库中的代码存在细微差异（通常只需更改 1-2 行代码），因为这些视频是在录制时使用相应版本发布的（LlamaIndex 0.5.7 和 LangChain 0.0.157）。请参考本仓库中的代码以获取最新版本。\n\n我会尽量保持本仓库与最新库版本同步，但如果你遇到任何问题，请：(1) 通过 Issues 提出讨论；或 (2) 自愿提交 PR 来更新代码。\n\n注意：`triton` 包仅支持 **x86_64** 架构。如果安装遇到问题，请参阅 [triton 兼容性指南](https:\u002F\u002Fgithub.com\u002Fopenai\u002Ftriton?tab=readme-ov-file#compatibility)。常见错误包括：`ERROR: Could not find a version that satisfies the requirement triton (from versions: none)\nERROR: No matching distribution found for triton`。\n运行 `uname -p` 命令可查看处理器名称。\n\n### 导师指导与支持\n\n我在 [Supertype Fellowship](https:\u002F\u002Ffellowship.supertype.ai) 下运营一个导师计划。该计划为自定进度、免费形式，拥有来自全球各地（英语使用者）的学习者和从业者社区。你还可以选择预约与我的导师团队进行一对一辅导，获得视频教学和代码审查的帮助。\n\n### 许可证\n\nMIT © [Supertype](https:\u002F\u002Fsupertype.ai) 2024","# llm-python 快速上手指南\n\n`llm-python` 是一个包含丰富教学材料、代码示例和 Python 脚本的开源项目，旨在帮助开发者利用 LlamaIndex、LangChain、OpenAI Agent SDK、Chroma、Pinecone 等工具构建大语言模型（LLM）应用和智能体（Agents）。本项目代码独立且专注，适合按需选取学习。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**：支持 Linux、macOS 或 Windows。\n    *   *注意*：部分依赖（如 `triton`）仅支持 **x86_64** 架构。若使用 ARM 架构（如 Apple M1\u002FM2\u002FM3），安装 `triton` 时可能会报错，可根据需求选择性安装或跳过相关示例。\n*   **Python 版本**：建议 Python 3.9 或更高版本。\n*   **API Keys**：\n    *   **必需**：OpenAI API Key (`OPENAI_API_KEY`)。\n    *   **可选**：根据您想运行的具体示例，可能需要配置 HuggingFace Token、Pinecone Key、Cohere Key 或 Sectors API Key 等。\n\n## 安装步骤\n\n1.  **克隆仓库**\n    将项目代码下载到本地：\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002Fsamuelchan\u002Fllm-python.git\n    cd llm-python\n    ```\n\n2.  **安装依赖**\n    推荐使用国内镜像源加速安装（如清华源）：\n    ```bash\n    pip install -r requirements.txt -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n    ```\n    *注：若遇到 `triton` 安装失败且您不需要运行本地离线模型示例，可尝试手动移除 `requirements.txt` 中的 `triton` 后重新安装。*\n\n3.  **配置环境变量**\n    在项目根目录下创建 `.env` 文件，并填入您的 API 密钥。\n    \n    ```bash\n    touch .env\n    ```\n    \n    编辑 `.env` 文件，内容如下（至少需配置 `OPENAI_API_KEY`）：\n    ```text\n    # 推荐配置 (必需)\n    OPENAI_API_KEY=sk-...\n\n    # 可选配置 (根据具体示例需求添加)\n    SECTORS_API_KEY=...\n    GROQ_API_KEY=...\n    HUGGINGFACEHUB_API_TOKEN=...\n    PINECONE_API_KEY=...\n    COHERE_API_KEY=...\n    STABILITY_API_KEY=...\n    ```\n\n4.  **准备数据（可选）**\n    项目 `news` 文件夹中已提供示例文本数据。您可以直接运行示例，或替换该文件夹内容为自己的文本文件以测试私有数据问答。\n\n## 基本使用\n\n本项目包含多个独立的脚本，每个脚本对应一个特定的 LLM 应用场景（如问答系统、数据库查询、多智能体协作等）。\n\n**运行示例：**\n您可以直接运行任意脚本。例如，运行第 6 个示例（基于 GPT-3 的网站\u002F团队问答系统）：\n\n```bash\npython 6_team.py\n```\n\n**探索更多场景：**\n*   **构建问答系统**：参考 `2_qa_system.py` (配合自有文本数据)。\n*   **查询数据库\u002FCSV**：参考 `3_csv_db.py`。\n*   **使用开源模型 (无需 OpenAI)**：参考 `4_huggingface.py`。\n*   **多智能体模式 (2025 更新)**：运行 `19_agents_handsoff.py` 至 `24_agents_guardrails.py` 体验最新的智能体协作模式（如任务移交、工具调用、并行处理等）。\n\n建议结合项目对应的 YouTube 教程视频（需网络访问）或 Sectors 文档进行深入学习，视频链接通常位于各脚本的注释或项目 README 表格中。","某初创公司的数据分析师需要快速构建一个能基于公司内部 PDF 文档和 CSV 销售数据进行智能问答的原型系统，以向投资人演示 AI 落地能力。\n\n### 没有 llm-python 时\n- 开发者需在 LangChain、LlamaIndex 和向量数据库之间反复摸索，缺乏标准化的代码参考，导致环境配置和依赖安装耗时数天。\n- 面对“如何连接私有数据”、“如何处理 Embedding\"等关键问题，只能零散搜索碎片化教程，难以形成完整的开发链路。\n- 缺乏针对特定场景（如查询 CSV 或本地离线模型）的独立脚本，每次尝试新功能都要重写大量样板代码，试错成本极高。\n- 无法快速验证想法，往往在基础架构搭建阶段就耗尽精力，导致原型演示延期甚至取消。\n\n### 使用 llm-python 后\n- 直接复用仓库中\"LangChain + OpenAI 构建问答系统”或“查询数据库\u002FCSV\"的自包含脚本，几小时内即可跑通核心功能。\n- 依托配套的视频教程与分模块代码，清晰掌握从数据加载、向量化存储到检索生成的完整流程，学习曲线大幅平缓。\n- 按需选取“本地离线 LLM\"或\"Pinecone 向量检索”等特定场景示例，无需修改底层逻辑即可快速迁移到自己的业务数据上。\n- 借助成熟的代码模板迅速完成原型开发，将节省下来的时间专注于优化提示词工程和业务逻辑调整，按时高质量完成演示。\n\nllm-python 通过提供模块化、视频配套的实战代码库，将大应用开发的入门门槛从“数周摸索”降低为“数小时落地”，极大加速了 AI 原型的迭代效率。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fonlyphantom_llm-python_09972fe1.png","onlyphantom","Samuel Chan","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fonlyphantom_c43974f1.jpg","Cofounder of @supertypeai and @teamalgoritma. Subscribe on YouTube for programming content: https:\u002F\u002Fwww.youtube.com\u002Fc\u002Fsamuelchan","@supertypeai @teamalgoritma ","Indonesia","samuel@outlook.sg",null,"https:\u002F\u002Fsupertype.ai\u002Fp\u002Fsamuel","https:\u002F\u002Fgithub.com\u002Fonlyphantom",[86,90],{"name":87,"color":88,"percentage":89},"Jupyter Notebook","#DA5B0B",53.5,{"name":91,"color":92,"percentage":93},"Python","#3572A5",46.5,916,316,"2026-04-02T11:19:18","MIT","Linux, macOS, Windows","非必需。仅在使用本地托管的开源模型（如 OPT）或特定架构包（如 triton）时可能需要；triton 包仅支持 x86_64 架构。","未说明",{"notes":102,"python":103,"dependencies":104},"1. 必须配置 .env 文件并设置 OPENAI_API_KEY，其他 API 密钥（如 HuggingFace, Pinecone, Cohere 等）为可选。2. 核心依赖包 triton 仅支持 x86_64 架构处理器，在其他架构上安装可能会失败。3. 代码示例旨在独立运行，部分高级示例需要访问真实的金融数据 API（如 Sectors）。4. 教程视频中的代码可能与仓库最新代码有细微差异，请以仓库代码为准。","未说明 (需支持 pip 安装 requirements.txt)",[105,106,107,108,109,110],"llamaindex>=0.6.31","langchain>=0.0.209","openai-agents","chromadb","pinecone-client","triton (仅限 x86_64)",[13,53,26],[113,108,114,115,116,117,118,119,120,121],"langchain","gpt-3","langchain-python","llamaindex","openai-api","llm","llmops","pinecone","tutorial","2026-03-27T02:49:30.150509","2026-04-06T05:19:36.180582",[125,130,135,140,145,150],{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},10455,"在 Windows 上安装 requirements.txt 时遇到 uvloop 或 triton 报错怎么办？","这两个包仅支持 Linux，Windows 用户可以直接在 requirements.txt 中注释掉这两行：\n# triton==2.0.0\n# uvloop==0.17.0\n然后重新运行 pip install -r requirements.txt。如果其他包编译失败，可能需要安装 Microsoft C++ Build Tools（通过 Visual Studio 安装器选择\"Desktop development with C++\"工作负载）。","https:\u002F\u002Fgithub.com\u002Fonlyphantom\u002Fllm-python\u002Fissues\u002F11",{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},10456,"为什么使用 AMD GPU 运行大模型时程序看似卡死无响应？","这不是程序卡死，而是因为 AMD GPU 在 Windows 上不支持 CUDA，PyTorch 的 ROCm 后端也仅限 Linux。移除 CUDA 设备指定后，模型会回退到 CPU 运行，导致速度极慢（1.3B 参数模型单次查询可能需 30-60 分钟）。解决方案：\n1. 换用更小的模型如 facebook\u002Fopt-125m 或 facebook\u002Fopt-350m\n2. 在 Linux 系统上使用支持 ROCm 的 AMD GPU\n3. 耐心等待 CPU 推理完成（观察 RAM 占用可确认模型正在运行）","https:\u002F\u002Fgithub.com\u002Fonlyphantom\u002Fllm-python\u002Fissues\u002F4",{"id":136,"question_zh":137,"answer_zh":138,"source_url":139},10457,"如何正确将 Chroma 向量存储与 LlamaIndex 集成？","不要直接使用 chroma_collection 参数，应按以下方式重构代码：\n```python\nvector_store = ChromaVectorStore(chroma_collection)\nstorage_context = StorageContext.from_defaults(vector_store=vector_store)\nindex = GPTVectorStoreIndex.from_documents(documents, storage_context=storage_context)\n```\n参考官方文档示例：https:\u002F\u002Fgpt-index.readthedocs.io\u002Fen\u002Flatest\u002Fexamples\u002Fvector_stores\u002Fchroma_auto_retriever.html","https:\u002F\u002Fgithub.com\u002Fonlyphantom\u002Fllm-python\u002Fissues\u002F8",{"id":141,"question_zh":142,"answer_zh":143,"source_url":144},10458,"LangChain 版本更新后出现'NoneType' object has no attribute 'info'错误如何解决？","需要更新导入路径并调整代码结构：\n1. 修改导入语句：\n   from langchain_community.document_loaders import DirectoryLoader, TextLoader\n   from langchain_text_splitters import CharacterTextSplitter\n   from langchain_openai import OpenAIEmbeddings, OpenAI\n   from langchain_community.vectorstores import Chroma\n2. 由于 RetrievalQA 已被移除，改用以下模式：\n   retriever = docsearch.as_retriever()\n   llm = OpenAI()\n   # 自定义查询函数替代原有链式调用","https:\u002F\u002Fgithub.com\u002Fonlyphantom\u002Fllm-python\u002Fissues\u002F15",{"id":146,"question_zh":147,"answer_zh":148,"source_url":149},10459,"Python 版本不匹配导致依赖安装失败如何处理？","部分依赖包（如 uvloop）对 Python 版本有严格要求。如果遇到版本冲突：\n1. 检查项目推荐的 Python 版本（本项目部分组件推荐 3.8-3.9）\n2. 创建虚拟环境时指定兼容版本：python3.9 -m venv venv\n3. 对于 Windows 用户，优先注释掉平台不支持的包（见问题 1）\n4. 参考项目最新 commit 中的 requirements.txt 调整（相关修复已在 issue #7 合并）","https:\u002F\u002Fgithub.com\u002Fonlyphantom\u002Fllm-python\u002Fissues\u002F2",{"id":151,"question_zh":152,"answer_zh":153,"source_url":139},10460,"Chroma 集合创建后计数为 0 且无法查询数据的原因是什么？","根本原因是向量存储初始化方式错误。必须通过 StorageContext 显式传递 vector_store 参数，而不是直接传入 chroma_collection。正确做法：\n```python\nvector_store = ChromaVectorStore(chroma_collection)\nstorage_context = StorageContext.from_defaults(vector_store=vector_store)\nindex = GPTVectorStoreIndex.from_documents(documents, storage_context=storage_context)\n```\n之后验证：\nprint(chroma_collection.count())  # 应显示文档数量\nprint(chroma_collection.get()['documents'])  # 应返回文档内容",[]]