{"id":51451437,"url":"https://github.com/haveniceda/ai","last_synced_at":"2026-07-05T21:01:34.888Z","repository":{"id":337774858,"uuid":"1149828979","full_name":"HaveNiceDa/AI","owner":"HaveNiceDa","description":"基于Langchain学习AI","archived":false,"fork":false,"pushed_at":"2026-03-25T15:35:40.000Z","size":333,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-05T20:26:53.284Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HaveNiceDa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-04T15:14:01.000Z","updated_at":"2026-03-25T15:41:08.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/HaveNiceDa/AI","commit_stats":null,"previous_names":["haveniceda/ai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HaveNiceDa/AI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaveNiceDa%2FAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaveNiceDa%2FAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaveNiceDa%2FAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaveNiceDa%2FAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HaveNiceDa","download_url":"https://codeload.github.com/HaveNiceDa/AI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaveNiceDa%2FAI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35168795,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-05T02:00:06.290Z","response_time":100,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-05T21:01:32.948Z","updated_at":"2026-07-05T21:01:34.870Z","avatar_url":"https://github.com/HaveNiceDa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LangChain TypeScript 项目\n\n这是一个使用 TypeScript 和 LangChain 构建的项目，包含了多个示例和工具。\n\n## 项目结构\n\n```\n├── chain.ts           # 链式调用示例\n├── embedding.ts       # 嵌入向量示例\n├── textsplitter.ts    # 文本分割工具\n├── csvloader.ts       # CSV 文件加载器\n├── pdf-example.ts     # PDF 文本提取示例\n├── pdf-lib-example.ts # PDF 创建和修改示例\n├── test.ts            # 测试文件\n├── tsconfig.json      # TypeScript 配置\n└── package.json       # 项目依赖配置\n```\n\n## 安装依赖\n\n```bash\npnpm install\n```\n\n## 可用脚本\n\n- `pnpm run dev` - 运行开发模式\n- `pnpm run build` - 编译 TypeScript 代码\n- `pnpm run test` - 运行测试\n- `pnpm run textsplitter` - 运行文本分割示例\n- `pnpm run chain` - 运行链式调用示例\n- `pnpm run embedding` - 运行嵌入向量示例\n- `pnpm run csvloader` - 运行 CSV 加载器示例\n- `pnpm run pdf` - 运行 PDF 文本提取示例\n- `pnpm run pdf-lib` - 运行 PDF 创建和修改示例\n\n## TypeScript 配置\n\n项目使用严格的 TypeScript 配置，包括：\n\n- 启用严格模式 (`strict: true`)\n- 检查未使用的变量和参数\n- 检查隐式返回\n- 模块解析使用 bundler 模式\n- 支持 ES2022 特性\n\n## 环境变量\n\n确保在项目根目录创建 `.env` 文件并配置必要的 API 密钥：\n\n```env\nAPI_KEY=your_api_key_here\n```\n\n## 运行示例\n\n### 文本分割\n```bash\npnpm run textsplitter\n```\n\n### 链式调用\n```bash\npnpm run chain\n```\n\n### 嵌入向量\n```bash\npnpm run embedding\n```\n\n### PDF 处理\n\n#### 提取 PDF 文本（类似 Python pypdf）\n```bash\npnpm run pdf\n```\n\n需要将 PDF 文件放在项目根目录下的 `example.pdf`，或修改代码中的路径。\n\n#### 创建和修改 PDF\n```bash\npnpm run pdf-lib\n```\n\n这会创建三个 PDF 文件：\n- `created.pdf` - 新创建的 PDF\n- `modified.pdf` - 修改后的 PDF\n- `merged.pdf` - 合并后的 PDF\n\n## PDF 处理库说明\n\n项目包含三个主要的 PDF 处理库：\n\n### 1. pdf-parse\n- **用途**: 提取 PDF 文本内容\n- **特点**: 简单易用，类似 Python 的 pypdf\n- **适用场景**: 只需要读取 PDF 文本\n\n### 2. pdfjs-dist\n- **用途**: Mozilla 的 PDF.js 库\n- **特点**: 功能强大，支持渲染和提取\n- **适用场景**: 需要在浏览器中渲染 PDF 或提取详细内容\n\n### 3. pdf-lib\n- **用途**: 创建、修改和生成 PDF\n- **特点**: 现代化 API，支持完整的 PDF 操作\n- **适用场景**: 需要创建、修改、合并 PDF 文件\n\n## 技术栈\n\n- **TypeScript** - 类型安全的 JavaScript 超集\n- **LangChain** - 语言模型应用开发框架\n- **tsx** - TypeScript 执行器\n- **pnpm** - 快速、节省磁盘空间的包管理器\n- **pdf-parse** - PDF 文本提取\n- **pdf-lib** - PDF 创建和修改\n- **pdfjs-dist** - PDF 渲染和处理\n\n## 开发\n\n在开发过程中，你可以直接使用 `tsx` 运行 TypeScript 文件：\n\n```bash\nnpx tsx your-file.ts\n```\n\n或者使用配置好的脚本：\n\n```bash\npnpm run dev your-file.ts\n```\n\n## 类型检查\n\n运行 TypeScript 类型检查：\n\n```bash\nnpx tsc --noEmit\n```\n\n## 构建\n\n编译 TypeScript 代码：\n\n```bash\npnpm run build\n```\n\n编译后的文件将输出到 `dist` 目录。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaveniceda%2Fai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaveniceda%2Fai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaveniceda%2Fai/lists"}