Prompt Chain

Convert Knowledge Bases into Executable LLM Routines

OpenAI cookbook using o1 to zero-shot convert knowledge base articles into step-by-step, function-calling LLM routines.

Works with openai

80
Spark score
out of 100
Updated 16 days ago
Version 1.0.0
Models

Add to Favorites

Why it matters

Transform complex knowledge base articles into structured, step-by-step routines that LLMs can execute. This enables automated customer service by breaking down information into actionable tasks and function calls.

Outcomes

What it gets done

01

Deconstruct knowledge base articles into discrete, LLM-executable actions.

02

Define function calls for external data retrieval or system interactions.

03

Generate clear, concise instructions and sample responses for LLM execution.

04

Automate the conversion of human-readable policies into machine-readable SOPs.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/oai-usingreasoningforroutinegeneration | bash

Steps

Steps in the chain

01
Select Knowledge Base Articles
02
Convert Policy to Routine
03
Define Functions and External Actions
04
Store and Review Results
05
Integrate into Agentic Systems
06
Develop Comprehensive Evaluations

Overview

Using reasoning for routine generation

An OpenAI cookbook using o1 to zero-shot convert customer-service knowledge base articles into step-by-step, function-calling LLM routines with IFTTT branching logic. Use when building an automated pipeline to turn policy documentation into LLM-executable routines rather than hand-writing each one.

What it does

Using reasoning for routine generation converts customer-service knowledge base articles into "routines" - step-by-step instruction sets an LLM can follow, where each step maps to a clear action: responding to the user, triggering a function call, or retrieving additional knowledge. Most internal knowledge base articles are written for human interpretation, full of diagrams, multi-step processes, and decision trees that are hard for an LLM to reason through directly; breaking them into small, discrete routine steps reduces ambiguity and the risk of hallucination or drifting off the intended path.

When to use - and when NOT to

Use it when building an automated pipeline to convert policy documentation into LLM-executable routines rather than hand-writing each one. Doing this with earlier GPT-class models required designing very specific, robust instructions, capturing edge cases manually, supplying high-quality few-shot examples, and sometimes fine-tuning - a substantial engineering lift. The cookbook shows o1 deconstructing these articles into routines zero-shot, without extensive examples or task-specific prior training, because the routine structure itself supplies the guidance the model needs. It is not needed for simple, single-step policies where a routine's step-by-step scaffolding adds no value over a direct instruction.

Inputs and outputs

Input is a set of real OpenAI Help Center articles (deleting a payment method, requesting a Business Associate Agreement, setting up prepaid billing, submitting a VAT exemption request), stored in a CSV and passed to o1-preview in parallel. Conversion instructions direct the model to: turn the external-facing document into an internal SOP-style routine, break the policy into specific actions and sub-actions, define the conditions for moving between steps, and identify where external knowledge or actions are required, defining functions to fetch them. Output routines are stored in a dataframe and include sample user-facing responses, discrete numbered actions, and concrete function definitions the LLM can call - review_and_apply_tax_exemption, get_billing_plan, update_payment_method - so the LLM can act on the user's behalf, not just describe what to do. Routines also use IFTTT (If This, Then That) branching logic (e.g. "If the customer requests assistance, proceed to step 3f"), which the cookbook found translates complex source workflows into something both easily machine-followable and far more comprehensible than the diagrams they came from.

Integrations

Generated routines are meant to plug into an agentic system: a classifier picks the right routine for an incoming customer request and hands it to the LLM to execute directly with the customer - including performing the underlying action, not only explaining how to do it.

Who it's for

Teams building automated customer-service agents who need to convert existing policy/knowledge-base documentation into reliable, function-calling LLM routines at scale, and who plan to build comprehensive evaluations before production to validate and, where needed, adjust routines for compliance and effectiveness.

Source README

Using reasoning for routine generation

When developing customer service solutions, one of the initial steps involves transforming knowledge base articles into a set of routines that an LLM can comprehend and follow. A routine, in this context, refers to a set of step-by-step instructions designed specifically for the LLM to execute efficiently. Each routine is carefully structured so that a step corresponds to a clear action. Actions can include responding to a user, triggering a function call, or retrieving additional relevant knowledge.

Most internal knowledge base articles are complex and structured for human interpretation. They often include intricate diagrams, multi-step processes, and decision trees that pose challenges for LLM-based solutions to reason through in a meaningful way. By breaking down these documents into routines, each instruction can be simplified and formatted in a way that guides the LLM through a series of small, manageable tasks. This granular approach reduces ambiguity, allowing the LLM to process the information methodically and reducing the risk of hallucination or deviation from the expected path.

Converting these knowledge base articles into routines can be time-consuming and challenging, especially for companies attempting to build an automated pipeline. Each routine must account for various user scenarios, where actions need to be clearly defined. For instance, when a function call is necessary, the routine must specify the exact information to retrieve or the action to execute-whether it’s triggering an API, retrieving external data, or pulling in additional context. While automating this process with traditional GPT-class models can significantly reduce the manual effort involved, it often introduces new challenges. Some challenges include designing robust instructions that are specific enough for the LLM to follow consistently, capturing unique edge cases that may arise during customer interactions, providing high-quality few-shot examples to guide the model’s behavior, and in some cases, fine-tuning the model to achieve more reliable or specialized outcomes.

o1 has demonstrated the capability to efficiently deconstruct these articles and convert them into sets of routines zero-shot, meaning that the LLM can understand and follow the instructions without extensive examples or prior training on similar tasks. This minimizes the prompting effort required, as the routine structure itself provides the necessary guidance for the LLM to complete each step. By breaking down tasks into specific actions and integrating function calls where needed, o1’s approach ensures that even complex workflows can be handled seamlessly by the LLM, leading to more effective and scalable customer service solutions.

Selecting Knowledge Base Articles

In this example, we will use a set of publicly available Help Center articles from the OpenAI website and convert them into internal routines that an LLM can execute. Besides transforming the policies into routines, we will also have the model generate functions that allow the LLM to perform actions on behalf of the user. This is necessary to allow the LLM to execute the same actions that human agents have, and access additional information that may not be immediately available just from the policy documentation.

We will begin by using the following Help Center articles for conversion into routines:

We have our articles stored in an accessible csv. We will take the articles and pass them to o1-preview in parallel and generate the initial routines.

Our instructions for converting the policy to a routine include:

  • Converting the policy from an external facing document to an internal SOP routine
  • Breaking down the policy in specific actions and sub-actions
  • Outlining specific conditions for moving between steps
  • Determing where external knowledge/actions may be required, and defining functions that we could use to get that information

We'll store the results of our routines in a dataframe and print them out so we can get an initial look.

Results

Upon reviewing the generated routines, we can derive several insights:

  • Sample Responses: The model effectively generates sample responses that the LLM can utilize when executing the policy (e.g., “Instruct the user: ‘Confirm and purchase your initial amount of credits.’”).
  • Discrete Steps: The model excels at decomposing the problem into discrete actions that the LLM needs to execute. Each instruction is clearly defined and easy to interpret.
  • Function Definitions: The routines’ outputs include clearly defined functions to retrieve external information or trigger actions (e.g., review_and_apply_tax_exemption, get_billing_plan, update_payment_method).
    • This is crucial for any successful routine because LLMs often need to interact with external systems. Leveraging function calls is an effective way to interact with those systems and execute actions.
  • IFTTT Logic: The model effectively employs IFTTT (If This, Then That) logic, which is ideal for an LLM (e.g., “If the customer requests assistance, proceed to step 3f.”).
    • This type of translation becomes extremely valuable when the original knowledge base articles contain complex workflows and diagrams. Such complexity may not be easily understood by humans, and even less so by an LLM. IFTTT logic is easily comprehensible and works well for customer service solution

Where do we go from here?

These routines can now be integrated into agentic systems to address specific customer issues. When a customer requests assistance with tasks such as setting up prepaid billing, we can employ a classifier to determine the appropriate routine to retrieve and provide that to the LLM to interact directly with the customer. Beyond providing instructions to the user on how to set up billing, the system can also perform the action on their behalf.

Before deploying these routines into production, we should develop comprehensive evaluations to test and validate the quality of the model’s responses. This process may necessitate adjusting the routines to ensure compliance and effectiveness.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.