About Smarter

The story, inspiration, and goals behind the Smarter project—making AI and LLM tools accessible for everyone, from classrooms to the cloud.

The Original Problem

I teach AI to non-programmers at University of British Columbia. Like most AI professionals at the time, I spent much of Q1-2023 discovering the capabilities of OpenAI's newly published REST Api. In early April of that year I deployed a fun single page web app — openai.lawrencemcdaniel.com — demonstrating three things:

  1. How to integrate the OpenAI Api into a web chat user interface using React + inexpensive serverless services from AWS. The source code for this project is available at github.com/FullStackWithLawrence/aws-openai.
  2. An implementation of OpenAI's two dozen or so example LLM applications — OpenAI Examples
  3. An implementation of OpenAI's tool call example, "get_weather()" Function Calling Guide to which they refer, but oddly, they never actually implement. If that's what you're looking for, then follow this link function_weather.py and god speed on your journey.

Even though I'm satisfied with the end result, I was nonetheless disappointed in the size and breadth of the project. It's entirely too complicated. At more than 12,000 lines of code, it is a solidly medium-sized project by commercial standards, spanning complex technologies including React, Python, Terraform, and advanced networking concepts; all of which have steep learning curves. The daunting size and the complexity of the source code make it inaccessible to the kinds of working professionals who register for my courses and would most benefit from learning how to integrate function calls into their LLM prompts. Hence, this first attempt at creating a reference project was basically a bust, in that it is not an effective in-classroom teaching tool.

This lived experience inspired the Smarter project. I wanted to abstract away all of the React, Python, Terraform, and network engineering, leaving only the LLM prompt and tool calls, editable in real-time in a classroom-friendly environment. And after careful thought I realized there was a laundry list of pretty big secondary goals as well, including:

  • The ability to swap out LLM providers on the fly, and make these available from within the manifests such that vendor Api keys are abstracted away in favor of these being controlled by the institution.
  • Adding a tool 'selector' technology that can dynamically choose which tools to include in a prompt based on a variety of factors, kind of like how CSS selectors work.
  • Providing more visibility into the inner workings of LLM function calling, especially in cases where complex 'selectors' are employed, and multiple tools are being presented in a single chat session, and remote data sources are being integrated to these tools. Ideally, I wanted to extend the traditional chat interface to include a kind of 'debug mode' that introduces additional roles into the chat thread, showing how the LLM is reasoning about which tools to call, what data is being returned from these tools, and how this data is being integrated into the final response. And importantly, providing visibility into costing on a per-request basis.
  • Tightly controlling API key access, because, y'know, students 🤷🏼‍♂️
  • Maintaining auditable history on all chats, because, y'know, students 🤷🏼‍♂️
  • The ability to publish chatbots to production URL endpoints that can run at scale.
  • Integrating remote data sources so that chatbots can securely access real, live enterprise data from traditional sources like MySQL databases and REST Apis; meanwhile maintaining strict role-based access controls and audit logging.

Separately, and on an aside, for several years I've aspired to teach a class on advanced cloud computing techniques; namely Kubernetes. To do that well, you need an easy-to-understand application with a real-world purpose for running inside massively scalable cloud infrastructure. Bonus points if this application turns out to be interesting to students. The approach should ideally involve starting simple, on a local computer with Docker Desktop, and then scaling up to a Kubernetes cluster. Even more bonus points if the techniques that you're teaching actually work out in the wild, for a real platform running at scale. These eventually became additional, ancillary objectives of the Smarter project.

The Eventual Solution

Kubernetes was an early and ongoing source of design inspiration for what a "smarter" resource management strategy might look like. Kubernetes relies on a command-line tool named kubectl to process YAML "manifest" files that describe complex cloud resources. For the uninitiated, a typical Kubernetes manifest might look like:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    App: smarter
    app.kubernetes.io/managed-by: Helm
  name: smarter
  namespace: smarter-platform-prod
spec:
   ... stuff about the configuration of this software deployment goes here
status:
   ... stuff about the current state of this deployment goes here

Kubernetes was open sourced by Google in June 2014. The project was originally a sparse collection of their own in-house best practices, perfected over time based on their own realized experience running containers in production for more than a decade. The joint tests of time and scale have proven that most cloud resources can be described using the Kubernetes manifest layout. So in April 2023, I set about prototyping something like Kubernetes, but for AI resources. To be sure, there are nuances. For example, Kubernetes has no front end nor user experience, while AI resources often do. Still, though imperfect, the comparison is close enough. A comparable Smarter manifest might look like:

apiVersion: smarter.sh/v1
kind: SqlPlugin
metadata:
  name: stackademy_sql
  pluginClass: sql
spec:
  selector:
    directive: always
  prompt:
    provider: openai
    systemRole: >
      You are a helpful student advisor at the fictional Stackademy University that only offers computer science
      degrees programs. Whenever possible you should defer to the tool calls provided for additional information
      about the courses offered by Stackademy University. Questions unrelated to the courses or Stackademy University
      should be answered with "I am sorry, but I can only provide information about the courses offered by Stackademy University."
    model: gpt-4o-mini
    temperature: 0.5
    maxTokens: 2048
  connection: smarter_test_db
  sqlData:
    sqlQuery: SELECT c.course_code, c.course_name, c.description, c.cost, prerequisite.course_code AS prerequisite_course_code, prerequisite.course_name AS prerequisite_course_name
      FROM courses c
      LEFT JOIN courses prerequisite ON c.prerequisite_id = prerequisite.course_id
      WHERE ((c.description LIKE CONCAT('%', {description}, '%')) OR ({description} IS NULL))
        AND (c.cost <= {max_cost} OR {max_cost} IS NULL)
      ORDER BY c.prerequisite_id;

   ... more stuff about this plugin

From a design philosophy perspective, and to a large extent, the eventual implementation of Smarter Api is identical to that of Kubernetes. kubectl is written in Golang using the Viper and Cobra CLI frameworks, and so is the Smarter CLI. On the other hand, Python is the the lingua franca for data scientists and prompt engineers, so with that in mind, Smarter's backend is written in Python rather than in Golang. And not to beat the matter to death, but Smarter requires a web front end for the Prompt Engineers Workbench as well as for adminstration, and Django is an excellent choice for both, so that's what I used. Despite the divergence in language choices, both platforms work with YAML manifests and both are extensible. So no matter where you look, you'll see a lot of similarities.

Two and a half years later, Smarter is now a production-ready platform running at scale on AWS, used by students at UBC and other institutions. It is freely available to the general public, and contributors are warmly welcomed. Smarter is capable of deploying LLM chatbots connected to remote SQL databases, all defined using simple YAML manifests. The platform supports multiple LLM providers, dynamic tool selection, audit logging, and secure API key management. Best of all, Smarter abstracts away all of the complex infrastructure, allowing educators and students to focus solely on crafting effective prompts and tool calls.

Plenty more work remains, of course. Smarter is a young project, and there are many hoped-for features that are yet to be implemented. Nonetheless, I'm proud of the project so far, and I'm excited about its potential to transform how AI applications are developed and taught.

Lawrence McDaniel, principal author and maintainer
Data Scientist, Full Stack Developer, Instructor at UBC