Module 14 Wrap-up: The Sovereign Architect
Hands-on: Build a state-machine governed agent that handles a login and payment flow.
Module 14 Wrap-up: Logic Meets Language
You have learned that "Pure" AI is for creative tasks, but "Hybrid" AI is for business tasks. To finish this module, you are going to build a Guarded Payment Agent.
Hands-on Exercise: The Guarded Wallet
The Goal: Build a system where the agent can only "Pay" if the user has first "Logged In." You will use a simple Python dictionary for state and an LLM for intent classification.
1. The Logic (Python)
# The Deterministic State Machine
class PaymentSystem:
def __init__(self):
self.state = "GUEST"
def process_intent(self, intent):
if intent == "LOGIN":
self.state = "LOGGED_IN"
return "Successfully logged in."
if intent == "PAY":
if self.state == "LOGGED_IN":
return "Payment of $10 processed."
else:
return "Error: You must login first."
return "Unknown intent."
# The AI Brain (Intent Classifier)
def classify_user_text(user_input):
# This would call an LLM in real life
if "login" in user_input.lower(): return "LOGIN"
if "pay" in user_input.lower(): return "PAY"
return "UNKNOWN"
# THE HYBRID RUN
system = PaymentSystem()
print(system.process_intent(classify_user_text("I want to pay!")))
# Output: Error: You must login first.
print(system.process_intent(classify_user_text("Login me in.")))
print(system.process_intent(classify_user_text("I want to pay!")))
# Output: Payment of $10 processed.
Module 14 Summary
- Hybrid Architectures solve the reliability gap inherent in LLMs.
- FSMs (Finite State Machines) act as the "Bones" of the system.
- LLMs act as the "Eyes and Ears," interpreting messy human input.
- Constrained Sampling (Outlines) ensures that the AI's choices always fit the code's requirements.
Coming Up Next...
In Module 15, we look at the Enterprise Deployment of these systems. We will learn about Vector Databases, semantic caching, and how to scale your agents to serve millions of users.
Module 14 Checklist
- I can describe the difference between a Graph and a State Machine.
- I identify the "Probabilistic Wall" in any 10-step AI flow.
- I have chosen which states are mandatory for my Capstone Project.
- I understand how to use an LLM as a "Transition Trigger."
- I have researched the
Outlineslibrary for constrained JSON.