微信扫码
添加专属顾问
我要投稿
LazyLLM基本概念
使用指南
# set environment variable: LAZYLLM_OPENAI_API_KEY=xx # or you can make a config file(~/.lazyllm/config.json) and add openai_api_key=xximport lazyllmt = lazyllm.OnlineChatModule(source="openai", stream=True)w = lazyllm.WebModule(t)w.start().wait()
如果使用一个本地部署的模型,请确保自己安装了至少一个推理框架(lightllm或vllm)
import lazyllm# Model will be download automatically if you have an internet connectiont = lazyllm.TrainableModule('internlm2-chat-7b')w = lazyllm.WebModule(t)w.start().wait()import osimport lazyllmfrom lazyllm import pipeline, parallel, bind, _0, Document, Retriever, Rerankerprompt = '你将扮演一个人工智能问答助手的角色,完成一项对话任务。在这个任务中,你需要根据给定的上下文以及问题,给出你的回答。'documents = Document(dataset_path='/file/to/yourpath', embed=TrainableModule('bge-large-zh-v1.5'))with pipeline() as ppl:with parallel().sum as ppl.prl:prl.retriever1 = Retriever(documents, parser='CoarseChunk', similarity_top_k=6)prl.retriever2 = Retriever(documents, parser='SentenceDivider', similarity='chinese_bm25', similarity_top_k=6)ppl.reranker = Reranker(types='ModuleReranker', model='bge-reranker-large') | bind(ppl.input, _0)ppl.post_processer = lambda nodes: f'《{nodes[0].metadata["file_name"].split(".")[0]}》{nodes[0].get_content()}' if len(nodes) > 0 else '未找到'ppl.formatter = (lambda ctx, query: dict(context_str=ctx, query_str=query)) | bind(query=ppl.input)ppl.llm = lazyllm.TrainableModule('internlm2-chat-7b').prompt(lazyllm.ChatPrompter(prompt, extro_keys=['context_str']))mweb = lazyllm.WebModule(ppl, port=23456).start().wait()
故事创作
import lazyllmfrom lazyllm import pipeline, warp, bindfrom lazyllm.components.formatter import JsonFormattertoc_prompt=""" 你现在是一个智能助手。你的任务是理解用户的输入,将大纲以列表嵌套字典的列表。每个字典包含一个 `title` 和 `describe`,其中 `title` 中需要用Markdown格式标清层级,`describe` `describe` 是对该段的描述和写作指导。请根据以下用户输入生成相应的列表嵌套字典:输出示例:[{"title": "# 一级标题","describe": "请详细描述此标题的内容,提供背景信息和核心观点。"},{"title": "## 二级标题","describe": "请详细描述标题的内容,提供具体的细节和例子来支持一级标题的观点。"},{"title": "### 三级标题","describe": "请详细描述标题的内容,深入分析并提供更多的细节和数据支持。"}]用户输入如下:"""completion_prompt="""你现在是一个智能助手。你的任务是接收一个包含 `title` 和 `describe` 的字典,并根据 `describe` 中的指导展开写作输入示例:{"title": "# 一级标题","describe": "这是写作的描述。"}输出:这是展开写作写的内容接收如下:"""writer_prompt = {"system": completion_prompt, "user": '{"title": {title}, "describe": {describe}}'}with pipeline() as ppl:ppl.outline_writer = lazyllm.OnlineChatModule(source="openai", stream=False).formatter(JsonFormatter()).prompt(toc_prompt)ppl.story_generater = warp(lazyllm.OnlineChatModule(source="openai", stream=False).prompt(writer_prompt))ppl.synthesizer = (lambda *storys, outlines: "\n".join([f"{o['title']}\n{s}" for s, o in zip(storys, outlines)])) | bind(outlines=ppl.outline_writer)print(ppl({'query':'请帮我写一篇关于人工智能在医疗领域应用的文章。'}))
规划:LazyLLM v0.2的目标是打造一个支持常见的AI-Agent应用场景,并在各个场景下支持灵活定制的AI应用开发框架。
LazyLLM v0.2 PRD:https://aicarrier.feishu.cn/wiki/BeFfwBFv8iXq7vkVGyrcv1kGnIhdocs:https://lazyllm.readthedocs.io/github https://github.com/LazyAGI/LazyLLM
欢迎关注我的公众号“PaperAgent”,每天一篇大模型(LLM)文章来锻炼我们的思维,简单的例子,不简单的方法,提升自己。
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2026-02-03
暴涨11.7k Star!复刻Manus上下文工程的开源Skills,Claude code等多个平台即插即用
2026-02-03
ollama v0.15.4 更新:OpenClaw全面上线,优化集成流程与工具解析能力大升级!
2026-02-03
阶跃星辰 Step 3.5 Flash 上线!更快更强更稳的 Agent 大脑,开源!
2026-02-02
一分钟部署OpenClaw+QQ,国内最爽的一键启动!
2026-02-02
这家字节系AI初创,推出首个开源Agent Skills Builder!对话Refly.AI李锦威:大多数Agent都停留在专业用户层面,没有做到真正的普惠
2026-02-02
OCR又出宠OpenDoc,速度超MinerU6倍
2026-02-02
月之暗面发布 Kimi K2.5:一个模型,百个智能体,重新定义 AI 协作效率
2026-02-02
Google重磅开源!用AI读懂你的“天书”,LangExtract让非结构化文本瞬间结构化!
2025-11-19
2026-01-27
2025-12-22
2025-12-10
2025-11-17
2026-01-12
2025-11-07
2025-12-23
2026-01-06
2026-01-28
2026-01-28
2026-01-26
2026-01-21
2026-01-21
2026-01-20
2026-01-16
2026-01-02
2025-12-24