{"id":53956,"date":"2025-09-25T16:29:54","date_gmt":"2025-09-25T06:29:54","guid":{"rendered":"https:\/\/www.cloudproinc.com.au\/?p=53956"},"modified":"2025-09-25T16:29:56","modified_gmt":"2025-09-25T06:29:56","slug":"running-prompts-with-langchain","status":"publish","type":"post","link":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/","title":{"rendered":"Running Prompts with LangChain"},"content":{"rendered":"\n<p>In this blog post Running Prompts with LangChain A Practical Guide for Teams and Leaders we will walk through how to design, run, and ship reliable prompts using LangChain\u2019s modern building blocks.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-why-prompts-and-why-langchain\">Why prompts and why LangChain<\/h2>\n\n\n\n<p>Large language models respond to instructions written as prompts. The challenge is making those prompts consistent, testable, and composable with other parts of your app\u2014like retrieval, tools, and memory. That\u2019s where LangChain shines: it turns prompting into reusable, typed, and observable components you can run locally or in production.<\/p>\n\n\n\n<p>At a high level, <a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/category\/langchain\/\">LangChain <\/a>provides a clean way to express \u201cLLM programs.\u201d You define small pieces\u2014prompts, models, output parsers\u2014and wire them together into chains. This lets teams version prompts, add context from your data, enforce structured outputs, and monitor behavior without rewriting glue code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-technology-behind-langchain-prompting\">The technology behind LangChain prompting<\/h2>\n\n\n\n<p>Under the hood, LLMs work by predicting the next token (a chunk of text) given an input prompt. Parameters like temperature control randomness. Context windows cap how much text you can send, so you must be deliberate about instructions and which data you include.<\/p>\n\n\n\n<p>LangChain\u2019s core abstractions map neatly onto this:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Prompt templates<\/strong> define reusable instruction text with variables.<\/li>\n\n\n\n<li><strong>Models<\/strong> are providers such as OpenAI or local models; you can swap them with minimal code change.<\/li>\n\n\n\n<li><strong>Output parsers<\/strong> enforce structure (e.g., JSON) so downstream code is reliable.<\/li>\n\n\n\n<li><strong>Runnables\/Chains<\/strong> compose prompts, models, and utilities into a single callable unit.<\/li>\n\n\n\n<li><strong>Retrievers<\/strong> and <strong>vector stores<\/strong> add your private knowledge via embeddings and similarity search.<\/li>\n\n\n\n<li><strong>Memory<\/strong> lets you keep conversation state across turns securely.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-getting-started\">Getting started<\/h2>\n\n\n\n<p>Install the essentials and set your API key (OpenAI shown, but LangChain supports many providers):<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-cc60009762be6d3c167358ef156f8875\"><code>pip install -U langchain langchain-openai langchain-community faiss-cpu tiktoken\n# export OPENAI_API_KEY=...  # or set in your environment\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-your-first-prompt-chain\">Your first prompt chain<\/h2>\n\n\n\n<p>Use the modern LangChain Expression Language (LCEL) to compose prompt \u2192 model \u2192 parser.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-167a8b390ee253a60077d54853a2c7e9\"><code>from langchain_core.prompts import ChatPromptTemplate\nfrom langchain_core.output_parsers import StrOutputParser\nfrom langchain_openai import ChatOpenAI\n\nprompt = ChatPromptTemplate.from_messages(&#91;\n    (\"system\", \"You are a concise technical assistant.\"),\n    (\"human\", \"{question}\")\n])\n\nmodel = ChatOpenAI(model=\"gpt-4o-mini\", temperature=0.2)\nchain = prompt | model | StrOutputParser()\n\nprint(chain.invoke({\"question\": \"Explain LangChain in one paragraph.\"}))\n<\/code><\/pre>\n\n\n\n<p>This creates a reusable chain. You can call <code>invoke<\/code> for single runs or <code>batch<\/code> for parallel inputs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-prompt-templates-that-scale\">Prompt templates that scale<\/h2>\n\n\n\n<p>Good prompts are explicit, modular, and parameterized. Here\u2019s a template with guardrails and examples:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-556decc018a63a95eee70809048f7a34\"><code>examples = &#91;\n    {\"q\": \"What is RAG?\", \"a\": \"Retrieval augmented generation...\"},\n    {\"q\": \"Define vector embeddings\", \"a\": \"Numerical representations...\"},\n]\n\nprompt = ChatPromptTemplate.from_messages(&#91;\n    (\"system\", \"You are an expert who answers clearly and briefly.\"),\n    (\"human\", \"Task: {task}\\nConstraints: {constraints}\"),\n    (\"human\", \"Examples:\\n{examples}\"),\n    (\"human\", \"Question: {question}\")\n])\n\nformatted_examples = \"\\n\".join(&#91;f\"Q: {e&#91;'q']}\\nA: {e&#91;'a']}\" for e in examples])\n\nprint(prompt.format(\n    task=\"Answer technical questions\",\n    constraints=\"No source code unless asked; keep to 3 sentences\",\n    examples=formatted_examples,\n    question=\"How does temperature affect LLM outputs?\"\n))\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-structured-outputs-you-can-trust\">Structured outputs you can trust<\/h2>\n\n\n\n<p>Parsing plain text is brittle. Use a JSON parser to enforce a schema.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-53f25130c1725eb7eb27e0dbdf50bab1\"><code>from typing import Optional\nfrom pydantic import BaseModel, Field\nfrom langchain_core.output_parsers import JsonOutputParser\n\nclass Answer(BaseModel):\n    answer: str = Field(description=\"Concise answer\")\n    confidence: float = Field(description=\"0.0 to 1.0\")\n    citations: Optional&#91;list&#91;str]] = None\n\nparser = JsonOutputParser(pydantic_object=Answer)\n\nprompt = ChatPromptTemplate.from_messages(&#91;\n    (\"system\", \"Return only valid JSON matching this schema:\\n{format_instructions}\"),\n    (\"human\", \"{question}\")\n]).partial(format_instructions=parser.get_format_instructions())\n\nchain = prompt | model | parser\nresult = chain.invoke({\"question\": \"What is LangChain?\"})\nprint(result)  # dict with keys: answer, confidence, citations\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-adding-your-data-with-retrieval\">Adding your data with retrieval<\/h2>\n\n\n\n<p>Retrieval-augmented generation (RAG) brings your documents into the prompt at query time. You embed documents into vectors, store them, then fetch the most relevant chunks.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-6c917ff4f25d9412bc552e9ce062163f\"><code>from langchain_text_splitters import RecursiveCharacterTextSplitter\nfrom langchain_openai import OpenAIEmbeddings\nfrom langchain_community.vectorstores import FAISS\nfrom langchain_core.runnables import RunnablePassthrough\n\n# Prepare documents\nraw_docs = &#91;\n    (\"doc1\", \"LangChain provides Runnables, PromptTemplates, and parsers.\"),\n    (\"doc2\", \"Use retrieval to ground answers in your data.\"),\n]\ntexts = &#91;d&#91;1] for d in raw_docs]\n\nsplitter = RecursiveCharacterTextSplitter(chunk_size=300, chunk_overlap=50)\nchunks = &#91;c for t in texts for c in splitter.split_text(t)]\n\n# Build vector store\nemb = OpenAIEmbeddings()\nvs = FAISS.from_texts(chunks, embedding=emb)\nretriever = vs.as_retriever(k=3)\n\ndef format_docs(docs):\n    return \"\\n\\n\".join(&#91;d.page_content for d in docs])\n\nrag_prompt = ChatPromptTemplate.from_messages(&#91;\n    (\"system\", \"Answer using only the provided context. If unsure, say 'I don't know'.\"),\n    (\"human\", \"Context:\\n{context}\\n\\nQuestion: {question}\")\n])\n\nrag_chain = {\n    \"context\": retriever | format_docs,\n    \"question\": RunnablePassthrough()\n} | rag_prompt | model | StrOutputParser()\n\nprint(rag_chain.invoke(\"How does LangChain help with prompting?\"))\n<\/code><\/pre>\n\n\n\n<p>This pattern keeps prompts lean and focused, and it limits hallucinations by grounding answers in retrieved context.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-keeping-conversation-state-with-memory\">Keeping conversation state with memory<\/h2>\n\n\n\n<p>For chat apps, you often need previous turns. Use message history with a session ID so each user\u2019s context is isolated.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-547b86987f9816d0a54a53a151cad584\"><code>from langchain_core.chat_history import InMemoryChatMessageHistory\nfrom langchain_core.runnables.history import RunnableWithMessageHistory\n\nbase_prompt = ChatPromptTemplate.from_messages(&#91;\n    (\"system\", \"You are a helpful assistant.\"),\n    (\"placeholder\", \"{history}\"),\n    (\"human\", \"{input}\")\n])\nbase_chain = base_prompt | model | StrOutputParser()\n\nstore = {}\n\ndef get_history(session_id: str):\n    if session_id not in store:\n        store&#91;session_id] = InMemoryChatMessageHistory()\n    return store&#91;session_id]\n\nchat_chain = RunnableWithMessageHistory(\n    base_chain,\n    get_history,\n    input_messages_key=\"input\",\n    history_messages_key=\"history\"\n)\n\nsession_id = \"user-123\"\nprint(chat_chain.invoke({\"input\": \"Remember my project is Apollo\"}, config={\"configurable\": {\"session_id\": session_id}}))\nprint(chat_chain.invoke({\"input\": \"What did I say my project was?\"}, config={\"configurable\": {\"session_id\": session_id}}))\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-evaluation-and-reliability\">Evaluation and reliability<\/h2>\n\n\n\n<p>Prompts need tests. A lightweight approach:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a set of input-output examples (golden tests).<\/li>\n\n\n\n<li>Run your chain with <code>temperature=0<\/code> and compare outputs.<\/li>\n\n\n\n<li>Track changes whenever you edit prompts or model versions.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-4fb19454e69952185c690f2da49b570e\"><code>tests = &#91;\n  {\"in\": {\"question\": \"Define embeddings\"}, \"contains\": \"numerical\"},\n  {\"in\": {\"question\": \"What is RAG?\"}, \"contains\": \"retrieval\"}\n]\n\nok = 0\nfor t in tests:\n    out = chain.invoke(t&#91;\"in\"]).lower()\n    if t&#91;\"contains\"] in out:\n        ok += 1\nprint(f\"Passed {ok}\/{len(tests)} tests\")\n<\/code><\/pre>\n\n\n\n<p>For more rigorous checks, score responses with another model against criteria (helpfulness, correctness) and keep a changelog of prompt versions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-best-practices-for-production\">Best practices for production<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Be explicit: system messages set role and constraints; avoid ambiguity.<\/li>\n\n\n\n<li>Use structured outputs for anything machine-read; validate JSON.<\/li>\n\n\n\n<li>Control variability: set temperature low for deterministic tasks.<\/li>\n\n\n\n<li>Stay within token budgets: summarize or shorten context when needed.<\/li>\n\n\n\n<li>Guard against prompt injection in RAG: filter sources, prefix with clear rules, and quote context distinctly.<\/li>\n\n\n\n<li>Separate content from logic: store prompts as templates, version them, and document changes.<\/li>\n\n\n\n<li>Observe and log: capture inputs, outputs, and latencies for iterative tuning.<\/li>\n\n\n\n<li>Fail gracefully: set timeouts, retries, and fallbacks to smaller\/cheaper models.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-troubleshooting-checklist\">Troubleshooting checklist<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Hallucinations: add retrieval context; ask the model to say \u201cI don\u2019t know.\u201d<\/li>\n\n\n\n<li>Inconsistent JSON: use a JSON parser and provide the schema in the prompt.<\/li>\n\n\n\n<li>Too verbose answers: instruct max length and give examples.<\/li>\n\n\n\n<li>Slow responses: reduce context size, switch to faster models, or cache.<\/li>\n\n\n\n<li>Drift after edits: re-run golden tests; version prompts and models.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-putting-it-all-together\">Putting it all together<\/h2>\n\n\n\n<p>With LangChain, you can express prompt logic as small, testable parts that compose cleanly: templates for clarity, models for inference, output parsers for structure, retrieval for grounding, and memory for continuity. Start simple, add structure as requirements grow, and treat prompts like production code\u2014versioned, observed, and tested.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-next-steps\">Next steps<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Wrap your chains behind an API; keep prompts and config out of code where possible.<\/li>\n\n\n\n<li>Introduce RAG for proprietary data; add filters and source attributions.<\/li>\n\n\n\n<li>Automate evaluations and monitor latency, cost, and quality.<\/li>\n<\/ul>\n\n\n\n<p>That\u2019s the foundation for running prompts with LangChain in real-world systems\u2014simple to start, powerful as you scale.<\/p>\n\n\n\n<ul class=\"wp-block-yoast-seo-related-links yoast-seo-related-links\">\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/langchain-architecture-explained\/\">LangChain Architecture Explained<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/document-definition-in-langchain\/\">Document Definition in LangChain<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/08\/31\/extracting-structured-data-with-openai\/\">Extracting Structured Data with OpenAI<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/15\/architecture-of-rag-building-reliable-retrieval-augmented-ai\/\">Architecture of RAG Building Reliable Retrieval Augmented AI<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/08\/28\/cypher-queries-and-rag-technology-explained\/\">Cypher Queries and RAG Technology Explained<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to design, run, and evaluate prompts with LangChain using modern patterns, from simple templates to retrieval and production-ready chains.<\/p>\n","protected":false},"author":1,"featured_media":53963,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_focuskw":"Running Prompts with LangChain","_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"Learn to design and run prompts with LangChain. This guide makes prompt creation consistent and reliable for your team.","_yoast_wpseo_opengraph-title":"","_yoast_wpseo_opengraph-description":"","_yoast_wpseo_twitter-title":"","_yoast_wpseo_twitter-description":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[24,13,94],"tags":[],"class_list":["post-53956","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-blog","category-langchain"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Running Prompts with LangChain - CPI Consulting<\/title>\n<meta name=\"description\" content=\"Learn to design and run prompts with LangChain. This guide makes prompt creation consistent and reliable for your team.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Running Prompts with LangChain\" \/>\n<meta property=\"og:description\" content=\"Learn to design and run prompts with LangChain. This guide makes prompt creation consistent and reliable for your team.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/\" \/>\n<meta property=\"og:site_name\" content=\"CPI Consulting\" \/>\n<meta property=\"article:published_time\" content=\"2025-09-25T06:29:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-25T06:29:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.cloudproinc.com.au\/wp-content\/uploads\/2025\/09\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1536\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CPI Staff\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CPI Staff\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/\"},\"author\":{\"name\":\"CPI Staff\",\"@id\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/#\\\/schema\\\/person\\\/192eeeb0ce91062126ce3822ae88fe6e\"},\"headline\":\"Running Prompts with LangChain\",\"datePublished\":\"2025-09-25T06:29:54+00:00\",\"dateModified\":\"2025-09-25T06:29:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/\"},\"wordCount\":761,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/#primaryimage\"},\"thumbnailUrl\":\"\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png\",\"articleSection\":[\"AI\",\"Blog\",\"LangChain\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/\",\"url\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/\",\"name\":\"Running Prompts with LangChain - CPI Consulting\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/#primaryimage\"},\"thumbnailUrl\":\"\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png\",\"datePublished\":\"2025-09-25T06:29:54+00:00\",\"dateModified\":\"2025-09-25T06:29:56+00:00\",\"description\":\"Learn to design and run prompts with LangChain. This guide makes prompt creation consistent and reliable for your team.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/#primaryimage\",\"url\":\"\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png\",\"contentUrl\":\"\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png\",\"width\":1536,\"height\":1024},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/25\\\/running-prompts-with-langchain\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/cloudproinc.com.au\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Running Prompts with LangChain\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/#website\",\"url\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/\",\"name\":\"Cloud Pro Inc - CPI Consulting Pty Ltd\",\"description\":\"Cloud, AI &amp; Cybersecurity Consulting | Melbourne\",\"publisher\":{\"@id\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/#organization\",\"name\":\"Cloud Pro Inc - Cloud Pro Inc - CPI Consulting Pty Ltd\",\"url\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/favfinalfile.png\",\"contentUrl\":\"\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/favfinalfile.png\",\"width\":500,\"height\":500,\"caption\":\"Cloud Pro Inc - Cloud Pro Inc - CPI Consulting Pty Ltd\"},\"image\":{\"@id\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cloudproinc.azurewebsites.net\\\/#\\\/schema\\\/person\\\/192eeeb0ce91062126ce3822ae88fe6e\",\"name\":\"CPI Staff\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g\",\"caption\":\"CPI Staff\"},\"sameAs\":[\"http:\\\/\\\/www.cloudproinc.com.au\"],\"url\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/index.php\\\/author\\\/cpiadmin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Running Prompts with LangChain - CPI Consulting","description":"Learn to design and run prompts with LangChain. This guide makes prompt creation consistent and reliable for your team.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/","og_locale":"en_US","og_type":"article","og_title":"Running Prompts with LangChain","og_description":"Learn to design and run prompts with LangChain. This guide makes prompt creation consistent and reliable for your team.","og_url":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/","og_site_name":"CPI Consulting","article_published_time":"2025-09-25T06:29:54+00:00","article_modified_time":"2025-09-25T06:29:56+00:00","og_image":[{"width":1536,"height":1024,"url":"https:\/\/www.cloudproinc.com.au\/wp-content\/uploads\/2025\/09\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png","type":"image\/png"}],"author":"CPI Staff","twitter_card":"summary_large_image","twitter_misc":{"Written by":"CPI Staff","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/#article","isPartOf":{"@id":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/"},"author":{"name":"CPI Staff","@id":"https:\/\/cloudproinc.azurewebsites.net\/#\/schema\/person\/192eeeb0ce91062126ce3822ae88fe6e"},"headline":"Running Prompts with LangChain","datePublished":"2025-09-25T06:29:54+00:00","dateModified":"2025-09-25T06:29:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/"},"wordCount":761,"commentCount":0,"publisher":{"@id":"https:\/\/cloudproinc.azurewebsites.net\/#organization"},"image":{"@id":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2025\/09\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png","articleSection":["AI","Blog","LangChain"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/","url":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/","name":"Running Prompts with LangChain - CPI Consulting","isPartOf":{"@id":"https:\/\/cloudproinc.azurewebsites.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/#primaryimage"},"image":{"@id":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2025\/09\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png","datePublished":"2025-09-25T06:29:54+00:00","dateModified":"2025-09-25T06:29:56+00:00","description":"Learn to design and run prompts with LangChain. This guide makes prompt creation consistent and reliable for your team.","breadcrumb":{"@id":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/#primaryimage","url":"\/wp-content\/uploads\/2025\/09\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png","contentUrl":"\/wp-content\/uploads\/2025\/09\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png","width":1536,"height":1024},{"@type":"BreadcrumbList","@id":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/running-prompts-with-langchain\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudproinc.com.au\/"},{"@type":"ListItem","position":2,"name":"Running Prompts with LangChain"}]},{"@type":"WebSite","@id":"https:\/\/cloudproinc.azurewebsites.net\/#website","url":"https:\/\/cloudproinc.azurewebsites.net\/","name":"Cloud Pro Inc - CPI Consulting Pty Ltd","description":"Cloud, AI &amp; Cybersecurity Consulting | Melbourne","publisher":{"@id":"https:\/\/cloudproinc.azurewebsites.net\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudproinc.azurewebsites.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudproinc.azurewebsites.net\/#organization","name":"Cloud Pro Inc - Cloud Pro Inc - CPI Consulting Pty Ltd","url":"https:\/\/cloudproinc.azurewebsites.net\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudproinc.azurewebsites.net\/#\/schema\/logo\/image\/","url":"\/wp-content\/uploads\/2022\/01\/favfinalfile.png","contentUrl":"\/wp-content\/uploads\/2022\/01\/favfinalfile.png","width":500,"height":500,"caption":"Cloud Pro Inc - Cloud Pro Inc - CPI Consulting Pty Ltd"},"image":{"@id":"https:\/\/cloudproinc.azurewebsites.net\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/cloudproinc.azurewebsites.net\/#\/schema\/person\/192eeeb0ce91062126ce3822ae88fe6e","name":"CPI Staff","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g","caption":"CPI Staff"},"sameAs":["http:\/\/www.cloudproinc.com.au"],"url":"https:\/\/www.cloudproinc.com.au\/index.php\/author\/cpiadmin\/"}]}},"jetpack_featured_media_url":"\/wp-content\/uploads\/2025\/09\/running-prompts-with-langchain-a-practical-guide-for-teams-and-leaders.png","jetpack-related-posts":[{"id":53960,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/langchain-architecture-explained\/","url_meta":{"origin":53956,"position":0},"title":"LangChain Architecture Explained","author":"CPI Staff","date":"September 25, 2025","format":false,"excerpt":"A practical tour of LangChain\u2019s building blocks\u2014models, prompts, chains, memory, tools, and RAG\u2014plus LCEL, tracing, and deployment tips for production AI apps.","rel":"","context":"In &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/ai\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/09\/langchain-architecture-explained-for-agents-rag-and-production-apps.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/09\/langchain-architecture-explained-for-agents-rag-and-production-apps.png 1x, \/wp-content\/uploads\/2025\/09\/langchain-architecture-explained-for-agents-rag-and-production-apps.png 1.5x, \/wp-content\/uploads\/2025\/09\/langchain-architecture-explained-for-agents-rag-and-production-apps.png 2x, \/wp-content\/uploads\/2025\/09\/langchain-architecture-explained-for-agents-rag-and-production-apps.png 3x, \/wp-content\/uploads\/2025\/09\/langchain-architecture-explained-for-agents-rag-and-production-apps.png 4x"},"classes":[]},{"id":56928,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/02\/01\/protect-against-langgrinch-cve-2025-68664-in-langchain\/","url_meta":{"origin":53956,"position":1},"title":"Protect Against LangGrinch CVE-2025-68664 in LangChain","author":"CPI Staff","date":"February 1, 2026","format":false,"excerpt":"Learn what LangGrinch (CVE-2025-68664) means for LangChain-based apps and how to reduce risk with practical guardrails, testing, and operational controls.","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/blog\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2026\/02\/post-1.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2026\/02\/post-1.png 1x, \/wp-content\/uploads\/2026\/02\/post-1.png 1.5x, \/wp-content\/uploads\/2026\/02\/post-1.png 2x, \/wp-content\/uploads\/2026\/02\/post-1.png 3x, \/wp-content\/uploads\/2026\/02\/post-1.png 4x"},"classes":[]},{"id":53959,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/supercharge-langchain-apps-with-an-llm-cache\/","url_meta":{"origin":53956,"position":2},"title":"Supercharge LangChain apps with an LLM Cache","author":"CPI Staff","date":"September 25, 2025","format":false,"excerpt":"Cut latency and costs by caching LLM outputs in LangChain. Learn what to cache, when not to, and how to ship in-memory, SQLite, and Redis caches.","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/blog\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/09\/supercharge-langchain-apps-with-an-llm-cache-for-speed-and-cost.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/09\/supercharge-langchain-apps-with-an-llm-cache-for-speed-and-cost.png 1x, \/wp-content\/uploads\/2025\/09\/supercharge-langchain-apps-with-an-llm-cache-for-speed-and-cost.png 1.5x, \/wp-content\/uploads\/2025\/09\/supercharge-langchain-apps-with-an-llm-cache-for-speed-and-cost.png 2x, \/wp-content\/uploads\/2025\/09\/supercharge-langchain-apps-with-an-llm-cache-for-speed-and-cost.png 3x, \/wp-content\/uploads\/2025\/09\/supercharge-langchain-apps-with-an-llm-cache-for-speed-and-cost.png 4x"},"classes":[]},{"id":53958,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/25\/document-definition-in-langchain\/","url_meta":{"origin":53956,"position":3},"title":"Document Definition in LangChain","author":"CPI Staff","date":"September 25, 2025","format":false,"excerpt":"Understand LangChain\u2019s Document model and how to structure, chunk, and enrich metadata to build accurate, scalable RAG pipelines.","rel":"","context":"In &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/ai\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/09\/mastering-document-definition-in-langchain-for-reliable-rag.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/09\/mastering-document-definition-in-langchain-for-reliable-rag.png 1x, \/wp-content\/uploads\/2025\/09\/mastering-document-definition-in-langchain-for-reliable-rag.png 1.5x, \/wp-content\/uploads\/2025\/09\/mastering-document-definition-in-langchain-for-reliable-rag.png 2x, \/wp-content\/uploads\/2025\/09\/mastering-document-definition-in-langchain-for-reliable-rag.png 3x, \/wp-content\/uploads\/2025\/09\/mastering-document-definition-in-langchain-for-reliable-rag.png 4x"},"classes":[]},{"id":56798,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/11\/26\/block-prompt-attacks-with-azure-ai-services\/","url_meta":{"origin":53956,"position":4},"title":"Block Prompt Attacks with Azure AI Services","author":"CPI Staff","date":"November 26, 2025","format":false,"excerpt":"Learn how to block prompt injection and jailbreak attacks using Azure AI, with practical patterns for safe, production-ready AI applications on Microsoft Azure.","rel":"","context":"In &quot;Azure AI Services&quot;","block_context":{"text":"Azure AI Services","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/azure-ai-services\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/11\/block-prompt-attacks-with-azure-ai-in-real-world-apps.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/11\/block-prompt-attacks-with-azure-ai-in-real-world-apps.png 1x, \/wp-content\/uploads\/2025\/11\/block-prompt-attacks-with-azure-ai-in-real-world-apps.png 1.5x, \/wp-content\/uploads\/2025\/11\/block-prompt-attacks-with-azure-ai-in-real-world-apps.png 2x, \/wp-content\/uploads\/2025\/11\/block-prompt-attacks-with-azure-ai-in-real-world-apps.png 3x, \/wp-content\/uploads\/2025\/11\/block-prompt-attacks-with-azure-ai-in-real-world-apps.png 4x"},"classes":[]},{"id":53838,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/15\/use-text2cypher-with-rag\/","url_meta":{"origin":53956,"position":5},"title":"Use Text2Cypher with RAG","author":"CPI Staff","date":"September 15, 2025","format":false,"excerpt":"Learn how to combine Text2Cypher and RAG to turn natural language into precise Cypher, execute safely, and deliver trustworthy graph answers.","rel":"","context":"In &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/ai\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/09\/use-text2cypher-with-rag-for-dependable-graph-based-answers-today.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/09\/use-text2cypher-with-rag-for-dependable-graph-based-answers-today.png 1x, \/wp-content\/uploads\/2025\/09\/use-text2cypher-with-rag-for-dependable-graph-based-answers-today.png 1.5x, \/wp-content\/uploads\/2025\/09\/use-text2cypher-with-rag-for-dependable-graph-based-answers-today.png 2x, \/wp-content\/uploads\/2025\/09\/use-text2cypher-with-rag-for-dependable-graph-based-answers-today.png 3x, \/wp-content\/uploads\/2025\/09\/use-text2cypher-with-rag-for-dependable-graph-based-answers-today.png 4x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/53956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=53956"}],"version-history":[{"count":2,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/53956\/revisions"}],"predecessor-version":[{"id":53973,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/53956\/revisions\/53973"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/media\/53963"}],"wp:attachment":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=53956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/categories?post=53956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/tags?post=53956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}