Langchain Output Formatting logo

Langchain Output Formatting

Organization
Seeed-Projects
langchain-output-formatting

Format LLM output using Langchain on Jetson for structured smart home control signals. Deploys a local chatbot with Gradio UI that uses LlamaCpp and Langchain's StructuredOutputParser to produce JSON-formatted responses. Requires JetPack 5.0+ and a GGUF model.

Overview

PublisherSeeed-Projects
RepositorySeeed-Jetson-DevelopTool
Skill namelangchain-output-formatting
Stars
58
Forks
9
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Seeed-Projects on GitHub. Read the source before you install it.

Installation

Install the Langchain Output Formatting AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Seeed-Projects/Seeed-Jetson-DevelopTool/tree/main/seeed_jetson_develop/skills/openclaw/langchain-output-formatting
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Seeed-Projects/Seeed-Jetson-DevelopTool.git /tmp/Seeed-Jetson-DevelopTool
mkdir -p .claude/skills
cp -r /tmp/Seeed-Jetson-DevelopTool/seeed_jetson_develop/skills/openclaw/langchain-output-formatting .claude/skills/langchain-output-formatting
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Langchain Output Formatting in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Langchain Output Formatting on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Langchain Output Formatting is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Format LLM Output with Langchain on Jetson

Use Langchain's StructuredOutputParser to constrain LLM output into structured JSON for smart home control. The chatbot runs locally on Jetson using LlamaCpp with a Gradio web interface.


Execution model

Run one phase at a time. After each phase:

  • Relay all output to the user.
  • If output contains [STOP] → stop, consult the failure decision tree.
  • If output ends with [OK] → tell the user "Phase N complete" and proceed.

Prerequisites

RequirementDetail
HardwareJetson device (e.g. reComputer J4012)
JetPack5.0+
ModelLlama 2 7B Chat GGUF (Q4_0 quantization)
Pythonpip3 available

Phase 1 — Install dependencies (~3 min)

bash
pip3 install --no-cache-dir --verbose "langchain[llm]" openai
pip3 install --no-cache-dir --verbose gradio==3.38.0

[OK] when both packages install without error. [STOP] if pip3 fails — check Python version and pip availability.


Phase 2 — Download GGUF model (~5–15 min)

Download the Llama 2 7B Chat GGUF model (Q4_0 quantization) from Hugging Face:

bash
mkdir -p ~/models
# Download llama-2-7b-chat.Q4_0.gguf from Hugging Face
# Example using wget or huggingface-cli:
pip3 install huggingface-hub
huggingface-cli download TheBloke/Llama-2-7B-Chat-GGUF llama-2-7b-chat.Q4_0.gguf --local-dir ~/models

Verify:

bash
ls -lh ~/models/llama-2-7b-chat.Q4_0.gguf

[OK] when the GGUF file exists (~3.8 GB). [STOP] if download fails — check network and disk space.


Phase 3 — Create the chatbot script

Create format_opt.py with the following content. The script uses Langchain's StructuredOutputParser with ResponseSchema to define output fields (user_input, suggestion, control signal, temperature), then wraps a LlamaCpp model in a Gradio chat interface:

bash
cat > format_opt.py << 'PYEOF'
import copy
import gradio as gr
from langchain.llms import LlamaCpp
from langchain.output_parsers import StructuredOutputParser, ResponseSchema
from langchain.prompts import PromptTemplate

class ChatBot:
    def __init__(self, llama_model_path, history_length=3):
        self.chat_history = []
        self.history_threshold = history_length
        self.llm = LlamaCpp(
            model_path=llama_model_path,
            temperature=0.75,
            max_tokens=2000,
            top_p=1
        )
        response_schemas = [
            ResponseSchema(name="user_input", description="This is the user's input"),
            ResponseSchema(name="suggestion", type="string", description="your suggestion"),
            ResponseSchema(name="control", description="This is your response"),
            ResponseSchema(name="temperature", type="int",
                           description="Degrees centigrade temperature of the air conditioner.")
        ]
        self.output_parser = StructuredOutputParser.from_response_schemas(response_schemas)
        self.format_instructions = self.output_parser.get_format_instructions()
        self.template = """
            Now you are a smart speaker, and you need to determine whether to turn on the air conditioner based on the user's input.
            In the suggestion section, please reply normal conversation.
            In the control section, if you need to turn on the air conditioner, please reply with <1>; if you need to turn off the air conditioner, please reply with <0>.
            {format_instructions}
            Please do not generate any comments.
            % USER INPUT:
            {user_input}
            YOUR RESPONSE:
        """
        self.prompt = PromptTemplate(
            input_variables=["user_input"],
            partial_variables={"format_instructions": self.format_instructions},
            template=self.template
        )

    def format_chat_prompt(self, message):
        prompt = ""
        for turn in self.chat_history:
            user_message, bot_message = turn
            prompt = f"{prompt}\nUser: {user_message}\nAssistant: {bot_message}"
        prompt = f"{prompt}\nUser: {message}\nAssistant:"
        return prompt

    def respond(self, message):
        prompt = self.prompt.format(user_input=message)
        formatted_prompt = self.format_chat_prompt(prompt)
        bot_message = self.llm(formatted_prompt)
        if len(self.chat_history) >= self.history_threshold:
            del self.chat_history[0]
        self.chat_history.append((message, bot_message))
        return "", self.chat_history

    def run_webui(self):
        with gr.Blocks() as demo:
            gr.Markdown("# Format Output of LLM Demo")
            chatbot = gr.Chatbot(height=500)
            msg = gr.Textbox(label="Prompt")
            btn = gr.Button("Submit")
            clear = gr.ClearButton(components=[msg, chatbot], value="Clear console")
            btn.click(self.respond, inputs=[msg], outputs=[msg, chatbot])
            msg.submit(self.respond, inputs=[msg], outputs=[msg, chatbot])
        gr.close_all()
        demo.launch()

if __name__ == '__main__':
    chatbot_ins = ChatBot("/home/nvidia/models/llama-2-7b-chat.Q4_0.gguf")
    chatbot_ins.run_webui()
PYEOF

Update the model path in the script to match your actual GGUF location.

[OK] when file is created.


Phase 4 — Run the chatbot (~1 min to start)

bash
python3 format_opt.py

Open a browser and navigate to http://<jetson-ip>:7861/.

Test by typing prompts like "It's really hot today" — the LLM should respond with structured JSON containing control signals.

[OK] when the Gradio UI loads and the LLM returns formatted JSON output. [STOP] if the model fails to load or Gradio crashes.


Failure decision tree

SymptomAction
pip3 install langchain failsUpgrade pip: pip3 install --upgrade pip. Check Python ≥ 3.8.
ModuleNotFoundError: llama_cppInstall: pip3 install llama-cpp-python. May need CMAKE_ARGS="-DLLAMA_CUBLAS=on" for GPU.
Model loading OOMUse a smaller quantization (Q2_K) or free memory. Check with free -h.
Gradio won't start on port 7861Port in use. Kill existing process or set demo.launch(server_port=7862).
LLM output not valid JSONAdjust temperature lower (0.3–0.5). Ensure format_instructions are in the prompt.
Browser can't reach JetsonCheck firewall: sudo ufw allow 7861. Verify IP with hostname -I.

Reference files

  • references/source.body.md — Full Seeed Wiki tutorial with code examples, screenshots, and next steps for Riva integration (reference only)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Langchain Output Formatting AI skill do?

Format LLM output using Langchain on Jetson for structured smart home control signals. Deploys a local chatbot with Gradio UI that uses LlamaCpp and Langchain's StructuredOutputParser to produce JSON-formatted responses. Requires JetPack 5.0+ and a GGUF model.

Why use Langchain Output Formatting on TypingMind?

Because you install it once and use it with any model. Langchain Output Formatting is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Langchain Output Formatting in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Seeed-Projects/Seeed-Jetson-DevelopTool/tree/main/seeed_jetson_develop/skills/openclaw/langchain-output-formatting. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Langchain Output Formatting?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Langchain Output Formatting?

As many as you like. As long as a model supports skills, you can use Langchain Output Formatting with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Langchain Output Formatting AI skill free?

Yes. It is published on GitHub by Seeed-Projects under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇