自定义提示词

自定义提示词 why 1.针对LLM进行优化 2.更改语言 3.针对复杂领域进行专业化 4.调整语气和风格 5.支持超个性化用例 了解CrewAI的提示词系统 智能体模板 (Agent templates) – 控制每个智能体对其指定角色的处理方式。 提示词片段 (Prompt slices) – 控制任务、工具使用和输出结构等专门行为。 错误处理 (Error handling) – 指导智能体如何应对失败、异常或超时。 工具专用提示词 (Tool-specific prompts) – 定义如何调用或使用工具的详细说明。 了解默认系统指令 当通过role,goal,backstory定义agent时,自动注入的一些指令 ...

FrameworksCrewAI
2 分钟765 字chenghaoning51

Retrieval

Two limitations of LLM: finite context Static Knowledge RAG(检索增强生成) Building a knowledge base A repository of documents of structured data 使用LangChain’s document loaders and vector stores 来建立你自己的知识库 如果你已经有知识库,你不需要重建,你只需要 ...

FrameworksLangChain
1 分钟480 字chenghaoning51

Short-term Memory

Conversation history is the most common form of short-term memory Fact1: message includes instructions and inpus Usage To add short-term memory to an agent ,you need to specify a checkpointer when creating an agent note: short-term memory is part of your agent’s state. State is persisted in a database using a checkpointer so thread can resume it an any time. Short-term memory updates when the agent is invoked or a step (like a tool call) is completed, and the state is read at the start of each step. ...

FrameworksLangChain
3 分钟1481 字chenghaoning51

Runtime

LangChain’s create_agent的底层运行在LangGraph’s runtime LangGraph暴露一个Runtime object,提供以下的信息: 1.context:静态信息:user id,数据库连接和其他的依赖 2.Store:用于长期记忆的BaseStore实例 3.Stream writer:通过"custom"流式传输模式来硫化信息的object 4.Execution info: identity and retry information for the current execution(thread ID, run ID ,attmpt number) 5.Server info:在 LangGraph Server 上运行时的特定于服务器的元数据(assistant ID,graph ID, authenticated user ) You can access the runtime information within tools and middleware ...

FrameworksLangChain
2 分钟962 字chenghaoning51

Streaming

Overview 实现的功能: Stream agent progress Stream LLM tokens Streaming thinking/reasoning tokens Stream custom updates Stream multiple modes:从updates,messages,custom中进行选择 Supported stream modes 将下列的一个或者多个流式传输模式作为列表传输给stream或者astream方法 ...

FrameworksLangChain
5 分钟2472 字chenghaoning51

Structured Output

返回的形式: JSON objects, Pydantic models,or dataclasses that your application can use directly LangChain’s create_agent 会自动处理结构化输出 用户设置desired 结构化输出的schema 返回在 in the key strucured_responese key of the agent’s state Field函数的作用: 结构化输出时,是创建元数据的重要途径,且其内部的description可以作为Prompt的一部分指导LLM的工作 ...

FrameworksLangChain
4 分钟1930 字chenghaoning51

Tools

Tools Extend what agents can do! Create tools Basic tool definition The easiest way to create a tool is to use the @tool decorator In this way the docstring will become the description of the tool 1 2 3 4 5 6 7 8 9 10 11 from langchain.tools import tool @tool def search_database(query: str, limit: int = 10) -> str: """Search the customer database for records matching the query. Args: query: Search terms to look for limit: Maximum number of results to return """ return f"Found {limit} results for '{query}'" docstring:’’' ada ’’' 的部分 docstring应该内容丰富且简明扼要 参数的type hints是必须的,因为他们定义了工具的输入参数 ...

FrameworksLangChain
8 分钟3539 字chenghaoning51