摘要: Creational patterns provide object creation mechanisms that increase flexibility and reuse of existing code. Factory method: Provides an interface for 阅读全文
posted @ 2024-01-23 15:11 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要: Just for fun... Given a number (always positive) as a type. Your type should return the number decreased by one. For example: type Zero = MinusOne<1> 阅读全文
posted @ 2022-10-07 22:57 Zhentiw 阅读(64) 评论(0) 推荐(0)
摘要: Blog: https://www.geeksforgeeks.org/es6-trampoline-function/ Stackoverflow problem for recursion: const sumBelow = (number, sum = 0) => ( number 0 ? s 阅读全文
posted @ 2022-08-18 14:32 Zhentiw 阅读(52) 评论(0) 推荐(0)
摘要: Serverless framework with AWS Link to each sections Table of Content: Part 0: Serverless Project structure Part 1: DynamoDB & ApiGateway Part 2: Event 阅读全文
posted @ 2021-05-17 15:15 Zhentiw 阅读(166) 评论(0) 推荐(0)
摘要: Storage Services: S3 Glacier CloudFront Elastic Block Store (EBS) Storage Gateway Snow family Database Overview Block storage: Used on local networks 阅读全文
posted @ 2021-03-15 03:06 Zhentiw 阅读(160) 评论(0) 推荐(0)
摘要: S3 Features Prefiees and delimiters For example: the file name in S3 can be: `marking/plans/kpi_2021_1.pdf`. The point is make it looks like a folder 阅读全文
posted @ 2021-03-12 17:34 Zhentiw 阅读(164) 评论(0) 推荐(0)
摘要: In our previous code, we have seen this partten for operators: // #region operators const concat = curry((broadcaster, listener) => { let string = ''; 阅读全文
posted @ 2020-10-25 21:54 Zhentiw 阅读(162) 评论(0) 推荐(0)
该文被密码保护。 阅读全文
posted @ 2020-05-07 18:22 Zhentiw 阅读(0) 评论(0) 推荐(0)
摘要: Generators can yield promises which can work with the "for await of" loop syntax. This lesson shows how all the pieces fit together and explains why t 阅读全文
posted @ 2020-03-22 02:59 Zhentiw 阅读(175) 评论(0) 推荐(0)
摘要: In this post, we are going to see how to use Ramda Lens. For example, we have data: R.lens: R.lens takes a getter and a setter: R.lensProp: There is a 阅读全文
posted @ 2019-02-24 20:12 Zhentiw 阅读(723) 评论(0) 推荐(0)
摘要: Just like the State ADT an Array is also an Applicative Functor. That means we can do the same tricks with liftA2 with Array that we have been doing w 阅读全文
posted @ 2019-01-16 16:30 Zhentiw 阅读(718) 评论(0) 推荐(0)
摘要: Use custom Cypress command for reusable assertions We’re duplicating quite a few commands between the registration and login of our user for assertion 阅读全文
posted @ 2018-12-06 21:13 Zhentiw 阅读(438) 评论(0) 推荐(0)
摘要: Use Cypress to test user registration Let’s write a test to fill out our registration form. Because we’ll be running this against a live backend, we n 阅读全文
posted @ 2018-12-05 15:54 Zhentiw 阅读(361) 评论(0) 推荐(0)
摘要: Despite the fact that Cypress is an application that runs natively on your machine, you can install it and add it as a dependency just like all other 阅读全文
posted @ 2018-12-05 02:38 Zhentiw 阅读(589) 评论(0) 推荐(0)
摘要: Ensure Functions are Called Correctly with JavaScript Mocks Often when writing JavaScript tests and mocking dependencies, you’ll want to verify that t 阅读全文
posted @ 2018-11-06 04:25 Zhentiw 阅读(437) 评论(0) 推荐(0)
摘要: 1. Color Picker (Chrome) You might know how to use color picker in Chrome, recently there is a feature inside color picker which is "Contrast Ratio", 阅读全文
posted @ 2018-07-15 18:41 Zhentiw 阅读(250) 评论(0) 推荐(0)
摘要: We'll examine how to unnest function calls, capture assignment, and create a linear data flow with a type we call Box. This is our introduction to wor 阅读全文
posted @ 2016-12-11 21:47 Zhentiw 阅读(339) 评论(0) 推荐(0)
摘要: Well, this stuff will be a little bit strange if you deal with it first time. Container Object: Just a wrapper / contianer for values No Method No Nou 阅读全文
posted @ 2016-09-06 04:23 Zhentiw 阅读(348) 评论(0) 推荐(0)
摘要: First, what is 'High Order function', basic just a function, inside the function return another fuction. For example: Decorators is a subset of high o 阅读全文
posted @ 2016-06-14 03:10 Zhentiw 阅读(387) 评论(0) 推荐(0)
摘要: Somehow it looks like reflect in Java. For example: We define an mothod on the Object, it called defineMethod(). It accepts two arguements, one is met 阅读全文
posted @ 2016-05-02 03:06 Zhentiw 阅读(389) 评论(0) 推荐(0)
摘要: 上一节我们体验了“手动维护聊天记录”,每次都要: 把用户发言添加到 history 把模型输出添加到 history 每轮都手动调用 getMessages() 构造上下文 await history.addMessage(new HumanMessage(input)); await histor 阅读全文
posted @ 2025-11-14 14:57 Zhentiw 阅读(2) 评论(0) 推荐(0)
摘要: 大模型本身是无状态的,每次调用都只看当前输入。如果要在多轮对话中维持上下文,就需要 Memory 模块来存储和管理对话历史。 LangChain.js 针对 Memory 提供了多个工具类,先来学习最常用的 ChatMessageHistory 快速上手案例: import { ChatMessag 阅读全文
posted @ 2025-11-14 14:55 Zhentiw 阅读(4) 评论(0) 推荐(0)
摘要: RAG 标准流程: 索引:外挂知识库 检索 生成 Advanced RAG 针对上述 3 个阶段做了优化。例如检索阶段,新增了 检索前处理 以及 检索后处理。 检索前处理: 查询转换 查询扩充 ...... 查询扩充(Query Expansion) 在不改变用户意图的前提下,添加相关词语或同义表达 阅读全文
posted @ 2025-11-09 20:03 Zhentiw 阅读(11) 评论(0) 推荐(0)
摘要: 回忆 RAG 关键步骤: 文本切割 嵌入处理 存储向量数据库 向量数据库可以分为这几种类型: 内存型 本地自托管 云托管 LangChain 内置了 MemoryVectorStore,这就是一个内存型向量库,用于将文档向量存储到内存中,适合本地调试、快速演示,零依赖、即插即用。 MemoryVec 阅读全文
posted @ 2025-11-08 19:49 Zhentiw 阅读(9) 评论(0) 推荐(0)
摘要: 回忆 RAG 关键步骤: 文本切割 嵌入处理 存储向量数据库 嵌入处理,又称之为向量化操作。核心就是将文本转为向量的形式,从而为下一步做数学运算做准备。 "今天的天气真好,万里无云" [ 0.3297254741191864, 0.7386181354522705, -3.3423418998718 阅读全文
posted @ 2025-11-07 14:56 Zhentiw 阅读(9) 评论(0) 推荐(0)
摘要: 为什么需要切割? 回忆一下 RAG 的流程: 用户提问 从知识库检索相关内容 将检索到的内容和用户问题一起交给模型推理 如果文档不切割,检索阶段就只能以整篇为单位,长文会超出模型的 Token 限制,无法一次性送进模型。 快速上手 如何切割? 最通用的是使用 RecursiveCharacterTe 阅读全文
posted @ 2025-11-06 15:07 Zhentiw 阅读(10) 评论(0) 推荐(0)
摘要: CheerioWebBaseLoader 作用是抓取指定网页并解析 HTML 内容,提取需要的纯文本数据。 这个 Loader 底层依赖 cheerio,语法类似 jQuery,可以方便地选择 HTML 元素并提取内容,适用于解析静态 HTML 网页。 pnpm add @langchain/com 阅读全文
posted @ 2025-11-06 14:51 Zhentiw 阅读(10) 评论(0) 推荐(0)
摘要: 很多时候,我们需要加载额外的数据,比如 RAG 架构中,需要外挂知识库。 外部数据的形式千差万别:可能是一份 PDF 文件、一张表格、一段代码,甚至是来自网络的实时信息。针对这些需求,LangChain 提供了一整套开箱即用的 Loader 工具,帮助我们高效地加载各种结构化或非结构化的数据,并统一 阅读全文
posted @ 2025-11-05 15:07 Zhentiw 阅读(8) 评论(0) 推荐(0)
摘要: 所谓条件路由(Conditional Routing),就是在一条 AI 推理/数据处理流水线里,先依据输入内容、上下文或运行时信号做一次判别,再把请求分发到不同的子流程(链)上执行。本质上是受控的 if/else:先“判别”,再“选择”,最后“执行”,避免“一个提示词走天下”。 在 LangCha 阅读全文
posted @ 2025-11-04 15:08 Zhentiw 阅读(9) 评论(0) 推荐(0)
摘要: RunnableSequence .pipe() 是逐个拼接,RunnableSequence.from([...]) 则是显式声明流程结构,将多个步骤写成数组更清晰。 课堂练习:快速上手示例 import { ChatOllama } from "@langchain/ollama"; impor 阅读全文
posted @ 2025-11-03 14:45 Zhentiw 阅读(4) 评论(0) 推荐(0)