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