{"id":20732266,"url":"https://github.com/ChatLunaLab/cortexluna","last_synced_at":"2025-09-27T15:31:55.748Z","repository":{"id":249422937,"uuid":"831177094","full_name":"ChatLunaLab/adapters","owner":"ChatLunaLab","description":"ChatLuna 模型适配器项目","archived":false,"fork":false,"pushed_at":"2025-01-15T13:50:00.000Z","size":4921,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-15T14:28:45.788Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChatLunaLab.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-07-19T21:09:39.000Z","updated_at":"2025-01-15T13:50:01.000Z","dependencies_parsed_at":"2025-01-07T09:30:57.581Z","dependency_job_id":"dbbb5c29-e42f-4388-a9bc-448822cea5b0","html_url":"https://github.com/ChatLunaLab/adapters","commit_stats":null,"previous_names":["chatlunalab/adapters"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChatLunaLab%2Fadapters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChatLunaLab%2Fadapters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChatLunaLab%2Fadapters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChatLunaLab%2Fadapters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChatLunaLab","download_url":"https://codeload.github.com/ChatLunaLab/adapters/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234448341,"owners_count":18834213,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-11-17T05:18:45.733Z","updated_at":"2025-09-27T15:31:55.744Z","avatar_url":"https://github.com/ChatLunaLab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CortexLuna\n\nCortexLuna 是简易，轻量化的 LLM 框架。建设在 Cordis 之上，与 Langchain 和 Vercel AI SDK 有一些相近的 API。\n\nCortexLuna 基于 Langchain 和 Vercel AI SDK 派生开发。\n\n## 特性\n\n* 基于 TypeScript 编写，提供大量的类型定义\n* 轻量化，易于使用，尽可能少的依赖\n* 渐进式 API 设计，随时可集成进你的项目\n\n## 路线图\n\n* [x] 结构化 `prompt` 格式化支持\n* [x] `generateText` 和 tool calling 支持\n* [x] `generateObject` 支持，结构化输出\n* [x] `streamText` 支持，流式输出\n* [x] `embed` 支持，获取文本（也可以是其他东西）的向量\n* [x] `Provider` 提供器，轮询配置等请求\n* [ ] Workflow 工作流支持\n* [ ] Vector Store 向量存储和检索\n* [ ] Hybrid search, bm25 混合向量查询\n\n## 用法\n\n和 Vercel AI SDK 类似，CortexLuna 提供了 `generateText` 和 `generateObject` 等 API。\n\n```typescript\n// 需要设置环境变量啊喂\nconst { text, usage, finishReason } = await generatateText({\n    model: openaiCompatible('gemini-2.0-flash-lite-preview'),\n    prompt: 'Talk a joke about programming'\n})\n\nconsole.log(text, usage, finishReason)\n```\n\n我们也支持 PromptTemplate 格式化：\n\n```typescript\nconst prompt = promptTemplate(\n      'Now is {time}.  I will ask you a question: {question}. Please answer it.'\n)\n\nconst chain = bindPromptTemplate(prompt, generatateText)\nconst { text, usage, finishReason } = await chain({\n    model: openaiCompatible('gemini-2.0-flash-lite-preview'),\n    input: {\n        time: new Date().toLocaleString(),\n        question: 'what time is it'\n    }\n})\n\nconsole.log(text, usage, finishReason)\n```\n\n流式文本也是支持的：\n\n```typescript\nconst {textStream, text } =  streamText({\n    model: openaiCompatible('gemini-2.0-flash-lite-preview'),\n    prompt: 'Talk a joke about programming'\n\n})\nfor await (const chunk of textStream) {\n    console.log(chunk)\n}\n\nconsole.log(await text)\n```\n\n结构化输出也支持：\n\n```typescript\nconst { object, usage } = await generateObject({\n    model: openaiCompatible('gemini-2.0-flash-lite-preview'),\n    prompt: 'Tell me a joke about programming',\n    schema: z.object({\n        joke: z.string().describe('The joke'),\n        punchline: z.string().describe('The punchline')\n    })\n})\n\nconsole.log(object, usage)\n```\n\n## 我是否应该使用 CortexLuna？\n\n看到上面的例子，你会觉得：\n\n\u003e 这 Vercel AI SDK 有什么区别？\n\n单纯 API 设计角度来看，确实是很接近。因为 CortexLuna 是基于 Vercel AI SDK 派生开发的，所以它的 API 设计也很接近。\n\n但 CortexLuna 不是为了取代 Langchain 或 Vercel AI SDK，而是为了给其他项目（主要指的是 ChatLuna）提供一个更简单，轻量级的 LLM 框架。\n\nLangchain 实在是过于笨重了，我不想再继续依赖它。但 Vercel AI SDK 的设计又比较简洁，我仍需要扩展一些东西才能用到 ChatLuna。最后我决定将两者的部分特定结合起来，就形成了 CortexLuna。\n\n\u003e [!TIP]\n\u003e 请注意，此项目是实验性的，不应该用于生产环境。\n\n## 致谢\n\n感谢以下开源项目：\n\n* [langchain/langchainjs](https://github.com/langchain-ai/langchainjs)\n* [vecel/ai](https://github.com/vercel)\n* [cordis](https://github.com/cordiverse/cordis)\n\n最后感谢所有 ChatLuna 的贡献者和用户，没有你们的支持，ChatLuna 就不会继续向前发展。\n\n## 许可证\n\n使用 [MIT](./LICENSE) 许可证发布。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChatLunaLab%2Fcortexluna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FChatLunaLab%2Fcortexluna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChatLunaLab%2Fcortexluna/lists"}