This content originally appeared on Bits and Pieces - Medium and was authored by Eden Ella
Create modular AI systems using Bit components to enhance code reuse and gain greater transparency into the system’s structure and changes.

AI-powered applications, which are based on data streaming in and out of LLMs and other AI models, are notorious for being flaky and unpredictable. They require a careful orchestration of various moving parts and a strict validation of the models’ inferences.
A great way to make the system more predictable and trustworthy — is by treating its parts such as agents, templates, output schemas, and more — as discrete Bit componetns that are individually tracked and versioned.
For example, the following “AI Technical Writer,” implemented with LangChain, is a composition of two Bit componetns and a third one that integrates them into a whole system.

➡️ See the ‘Technical Blog Writer’ components on Bit Platform
/**
* @ComponentId: learnbit.langchain/technical-blog-writer
* @filename: technical-blog-writer.ts
*/
// ...
/* use this component to define the output schema for the model */
import { blogContentSchema } from '@learnbit/langchain.structured-outputs.blog-content';
/* use this component to define the template for the model */
import {
contentWriterPrompt,
type ContentWriterPromptInput,
} from '@learnbit/langchain.templates.content-writer-prompt';
// ...
export default async function runTechnicalBlogWriter() {
const llm = new ChatOpenAI();
const structuredLLM = llm.withStructuredOutput(blogContentSchema);
try {
const topic = await getUserInput(
'What topic would you like to create content about? '
);
const experienceLevel = await getUserInput(
'What is the audience level of the content? (beginner, intermediate, advanced): '
);
const chain = contentWriterPrompt.pipe(structuredLLM);
/* the template provides a type for its inputs */
const result = await chain.invoke({
topic,
experienceLevel,
} as ContentWriterPromptInput);
// ...
}
This results in a CLI application that behaves as follows:
**AI Bot**: What topic would you like to create content about?
**User**: Individually versioning components in a LangChain applications
**AI Bot**: What is the audience level of the content? (beginner, intermediate, advanced): advanced
advanced)
**User**: Advanced
The output given by the model follows the schema provided by the structured-outputs/blog-content schema component:
{
"seoDescription": "Learn to version components in LangChain for A/B testing and code reuse.",
"seoTitle": "Individually Versioning Components in LangChain Applications",
"keywords": [
"LangChain",
"A/B testing",
"component versioning",
"code reuse",
"system insight"
],
"content": "# Individually Versioning Components in LangChain ..."
}
In this demo, the schema utilized by the LLM is defined using Zod. That makes it useful not only as a reusable block for other AI systems but also as a run-time schema validator and a TS type ( z.infer<Schema>) for clients of this system. For instance, think of a UI that displays the various properties of the returned object in designated fields.
/**
* @ComponentId: learnbit.langchain/sructured-outputs/blog-content
* @filename: blog-content.ts
*/
import { z } from 'zod';
export const blogContentSchema = z.object({
seoDescription: z
.string()
.describe(
'The SEO-optimized description of the blog post (150-160 characters).'
),
seoTitle: z.string().describe('The SEO-optimized title of the blog post.'),
keywords: z
.array(z.string().describe('A keyword or category for the blog.'))
.describe('An array of keywords or categories for the blog.'),
content: z
.string()
.describe('The main content of the blog in markdown format.'),
});
To learn more, visit the project’s scope on Bit Platform:

Why Build AI Systems as Bit Components?
1. A/B Testing and Multi-Variant Testing
When each part of your AI system is a versioned Bit component, running A/B tests or multi-variant tests becomes significantly easier. For example:
- You can compare different agent strategies by swapping versions of the agent component.
- Experiment with various prompt templates to assess which yields better results.
- Test multiple output schemas to determine which formats enhance user experience or accuracy.
With Bit, testing different component versions in isolation allows for precise measurement of their impact on system performance and output quality, enabling continuous optimization of AI systems.
Read this blog to learn more about testing with Bit:
Implementing Feature Toggling in 2024
2. Reusing Code Across AI-Powered Applications
Imagine having a highly effective prompt template or output schema — why reinvent the wheel for every new project? Using Bit, these components can be shared across multiple AI-powered applications. For example:
- A sentiment analysis agent built for one application can be reused in another with minimal adjustment.
- Common schemas can be shared across various projects.
This not only accelerates development but also ensures consistency across different projects.
3. Visualizing AI System Structure with Dependency Graphs
One of Bit’s standout features is its dependency graph visualization. In a composable AI system:
- You can inspect how components like agents, templates, and schemas interconnect.
- Easily trace how changes in one component might affect dependent systems.
This provides a clear overview of system complexity and aids in debugging, optimizing, and scaling efforts. In addition to that, since components are versioned using semantic versioning (MAJOR.MINOR.PATH ), it is easy to understand the scope and impact of their updates.
Final Thoughts
Building AI systems as composable Bit components brings clarity, scalability, and efficiency to AI development.
As AI systems grow more complex, composable architectures will be key to staying agile and innovative. To learn more, visit Bit Platform and Bit’s Documentation:
Building Composable AI Systems for Better Testability and Maintainability was originally published in Bits and Pieces on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Bits and Pieces - Medium and was authored by Eden Ella

Eden Ella | Sciencx (2025-02-24T22:25:40+00:00) Building Composable AI Systems for Better Testability and Maintainability. Retrieved from https://www.scien.cx/2025/02/24/building-composable-ai-systems-for-better-testability-and-maintainability/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.