Token导航 LogoToken导航TokenDH.com
开发需要联网github未标认证来源可访问许可证需确认审计未展示

langchain-structured-output-%26-hitlLangChain structured output 26 hitl 命令行

Agent Skill

langchain-structured-output-%26-hitl 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

18,631

周安装

645

GitHub Stars

638

下载量

5,295
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:langchain-structured-output-%26-hitl(LangChain structured output 26 hitl 命令行)
来源仓库:https://github.com/langchain-ai/langchain-skills
仓库路径:skills/langchain-structured-output-%26-hitl
安装命令:
npx skills add https://github.com/langchain-ai/langchain-skills --skill 'LangChain Structured Output & HITL'
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/langchain-ai/langchain-skills --skill 'LangChain Structured Output & HITL'

简介

用于处理 LangChain 结构化输出与人类介入(HITL)流程,适合在需要人机协同的场景中使用。

  • 可辅助定义输出格式、校验规则及人工审核节点,提升响应质量与合规性。
  • 通过 GitHub 仓库安装,需确认是否会修改配置文件或触发外部服务调用。
  • 建议结合实际用例测试其交互逻辑,避免因格式错误导致流程中断。
  • langchain-structured-output-%26-hitl 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

  1. Structured Output: Transform unstructured model responses into validated, typed data
  2. Human-in-the-Loop: Add human oversight to agent tool calls, pausing for approval

Key Concepts:

  • response_format: Define expected output schema
  • with_structured_output(): Model method for direct structured output
  • human_in_the_loop_middleware: Pauses execution for human decisions
Use CaseUse Structured Output?
Extract contact info, datesYes
Form fillingYes
API integrationYes
Open-ended Q&ANo

Structured Output

class ContactInfo(BaseModel): name: str email: str = Field(pattern=r"^[^@]+@[^@]+.[^@]+$") phone: str

agent = create_agent(model="gpt-4", response_format=ContactInfo)

result = agent.invoke({"messages": {"role": "user", "content": "Extract: John Doe, [john@example.com, (555) 123-4567"}]}) print(result["structured_response"])

ContactInfo(name='John Doe', email='john@example.com', phone='(555) 123-4567')

</python>
<typescript>
Extract contact information from text using a Zod schema with email validation.

import { ChatOpenAI } from "@langchain/openai"; import { z } from "zod";

const ContactInfo = z.object({ name: z.string(), email: z.string().email(), phone: z.string(), });

const model = new ChatOpenAI({ model: "gpt-4" }); const structuredModel = model.withStructuredOutput(ContactInfo);

const response = await structuredModel.invoke( "Extract: John Doe, john@example.com, (555) 123-4567" ); console.log(response); // { name: 'John Doe', email: 'john@example.com', phone: '(555) 123-4567' }


class Movie(BaseModel): """Movie information.""" title: str = Field(description="Movie title") year: int = Field(description="Release year") director: str rating: float = Field(ge=0, le=10)

model = ChatOpenAI(model="gpt-4") structured_model = model.with_structured_output(Movie)

response = structured_model.invoke("Tell me about Inception") print(response)

# Movie(title="Inception", year=2010, director="Christopher Nolan", rating=8.8)

</python> <typescript> Get movie details as a validated Zod object using withStructuredOutput().

import { ChatOpenAI } from "@langchain/openai";
import { z } from "zod";

const Movie = z.object({
  title: z.string().describe("Movie title"),
  year: z.number().describe("Release year"),
  director: z.string(),
  rating: z.number().min(0).max(10),
});

const model = new ChatOpenAI({ model: "gpt-4" });
const structuredModel = model.withStructuredOutput(Movie);

const response = await structuredModel.invoke("Tell me about Inception");
// { title: "Inception", year: 2010, director: "Christopher Nolan", rating: 8.8 }

class Classification(BaseModel): category: Literal["urgent", "normal", "low"] sentiment: Literal["positive", "neutral", "negative"] confidence: float = Field(ge=0, le=1)

</python>
<typescript>
Define a classification schema with constrained enum values using z.enum().

import { z } from "zod";

const Classification = z.object({ category: z.enum(["urgent", "normal", "low"]), sentiment: z.enum(["positive", "neutral", "negative"]), confidence: z.number().min(0).max(1), });


class Address(BaseModel): street: str city: str state: str zip: str

class Person(BaseModel): name: str age: int = Field(gt=0) email: str address: Address tags: List[str] = Field(default_factory=list)

</python> </ex-complex-nested-schema>


Human-in-the-Loop

<ex-basic-hitl-setup> <python> Set up an agent with HITL middleware that pauses before sending emails for approval.

from langchain.agents import create_agent, human_in_the_loop_middleware
from langgraph.checkpoint.memory import MemorySaver
from langchain.tools import tool

@tool
def send_email(to: str, subject: str, body: str) -> str:
    """Send an email."""
    return f"Email sent to {to}"

agent = create_agent(
    model="gpt-4",
    tools=[send_email],
    checkpointer=MemorySaver(),  # Required for HITL
    middleware=[
        human_in_the_loop_middleware(
            interrupt_on={
                "send_email": {"allowed_decisions": ["approve", "edit", "reject"]},
            }
        )
    ],
)

const sendEmail = tool(async ({to, subject, body}) => Email sent to ${to}, {name: "send_email", description: "Send an email", schema: z.object({to: z.string(), subject: z.string(), body: z.string()}),});

const agent = createReactAgent({llm: model, tools: [sendEmail], checkpointer: new MemorySaver(), // Required for HITL interruptBefore: ["send_email"],});

</typescript>
</ex-basic-hitl-setup>

<ex-running-with-interrupts>
<python>
Run the agent, detect an interrupt, then resume execution after human approval.

from langgraph.types import Command

config = {"configurable": {"thread_id": "session-1"}}

Step 1: Agent runs until it needs to call tool

result1 = agent.invoke({ "messages": [{"role": "user", "content": "Send email to john@example.com"}] }, config=config)

Check for interrupt

if "__interrupt__" in result1: print(f"Waiting for approval: {result1['__interrupt__']}")

Step 2: Human approves

result2 = agent.invoke( Command(resume={"decisions": [{"type": "approve"}]}), config=config )


const config = {configurable: {thread_id: "session-1"}};

// Step 1: Agent runs until it needs to call tool const result1 = await agent.invoke({messages: [{role: "user", content: "Send email to [john@example.com](https://github.com/langchain-ai/langchain-skills/blob/HEAD/config/skills/langchain-output/mailto:john@example.com)"}]}, config);

// Check for interrupt if (result1.**interrupt**) {console.log(`Waiting for approval: ${result1.__interrupt__}`);}

// Step 2: Human approves const result2 = await agent.invoke(new Command({resume: {decisions: [{type: "approve"}]}}), config);

</typescript> </ex-running-with-interrupts>

<ex-editing-tool-arguments> <python> Edit the tool arguments before approving when the original values need correction.

# Human edits the arguments
result2 = agent.invoke(
    Command(resume={
        "decisions": [{
            "type": "edit",
            "args": {
                "to": "alice@company.com",  # Fixed email
                "subject": "Project Meeting - Updated",
                "body": "...",
            },
        }]
    }),
    config=config
)

Structured Output:

  • Schema structure: Any valid Pydantic/Zod model
  • Field validation: Types, ranges, regex, etc.

HITL:

  • Which tools require approval
  • Allowed decisions per tool (approve, edit, reject)

CORRECT

print(result["structured_response"])

</python>
<typescript>
With withStructuredOutput, response IS the structured data.

const response = await structuredModel.invoke("..."); console.log(response); // Directly the parsed object


# CORRECT

class Data(BaseModel): date: str = Field(description="Date in YYYY-MM-DD format") amount: float = Field(description="Amount in USD")

</python> <typescript> Add field descriptions to guide the model on expected formats.

// WRONG
const Data = z.object({ date: z.string(), amount: z.number() });

// CORRECT
const Data = z.object({
  date: z.string().describe("Date in YYYY-MM-DD format"),
  amount: z.number().describe("Amount in USD"),
});

CORRECT

class Data(BaseModel): items: List[str] = Field(default_factory=list)

</python>
</fix-not-using-correct-type-hints>

<fix-missing-checkpointer>
<python>
HITL middleware requires a checkpointer to persist state.

WRONG

agent = create_agent(model="gpt-4", tools=[send_email], middleware=[human_in_the_loop_middleware({...})])

CORRECT

agent = create_agent( model="gpt-4", tools=[send_email], checkpointer=MemorySaver(), # Required middleware=[human_in_the_loop_middleware({...})] )


// CORRECT const agent = createReactAgent({llm: model, tools: [sendEmail], checkpointer: new MemorySaver(), // Required interruptBefore: ["send_email"]});

</typescript> </fix-missing-checkpointer>

<fix-no-thread-id> <python> Always provide thread_id when using HITL to track conversation state.

# WRONG
agent.invoke(input)  # No config!

# CORRECT
agent.invoke(input, config={"configurable": {"thread_id": "user-123"}})

CORRECT

from langgraph.types import Command agent.invoke(Command(resume={"decisions": [{"type": "approve"}]}), config=config)

</python>
<typescript>
Use Command class to resume execution after an interrupt.

// WRONG await agent.invoke({ resume: { decisions: [...] } });

// CORRECT import { Command } from "@langchain/langgraph"; await agent.invoke(new Command({ resume: { decisions: [{ type: "approve" }] } }), config);

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.46%
按下载量换算1,825

Claude

29.35%
按下载量换算1,554

Cursor

19.38%
按下载量换算1,026

Gemini CLI

9.48%
按下载量换算502

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills