Skip to main content

What is the LLM component?

The LLM (Large Language Model) component in Agenite is the abstraction layer that provides a unified interface for communicating with different language models. It serves as the bridge between your agent logic and the underlying AI providers like OpenAI, Anthropic, AWS Bedrock, or Ollama. This abstraction is crucial as it allows you to:
  • Write provider-agnostic code that works across different LLM services
  • Handle both streaming and non-streaming interactions consistently
  • Work with rich content types beyond just text
  • Manage tool usage through a standardized interface
Key aspects of the LLM component
  • Abstraction layer: Provides a uniform interface across different LLM providers
  • Content handling: Manages rich content like text, images, tool calls, and thinking blocks
  • Message formatting: Standardizes the format of messages between agents and LLMs
  • Token tracking: Facilitates monitoring token usage for performance and cost tracking
  • Streaming support: Enables real-time streaming of model outputs

The LLM architecture

The LLM component sits between agents and providers, providing a clean abstraction that isolates agent logic from provider-specific implementation details.

Core interfaces

The heart of the LLM component is the LLMProvider interface, which defines three essential methods:

Message structure

The LLM component standardizes messages using the BaseMessage interface:

Content blocks

Content blocks provide a flexible way to represent different types of content:
This rich structure allows agents to handle multimodal content and tool interactions in a consistent way.

Working with the LLM component

Basic text generation

The simplest way to use the LLM component is for basic text generation:

Streaming responses

For real-time interactions, you can use the streaming interface:

Working with tools

When working with tools, the LLM component provides structured handling:

Integration with agents

The agent component uses the LLM component in the LLMStep, which handles:
  1. Sending messages to the LLM provider
  2. Processing streaming responses
  3. Deciding whether to proceed to tool calling or end the conversation
  4. Managing token usage tracking
The key aspect of this integration is that agents work with the abstract LLMProvider interface rather than specific provider implementations, allowing you to easily swap providers without changing your agent logic.

The BaseLLMProvider class

For provider developers, Agenite includes a BaseLLMProvider class that simplifies implementing the LLMProvider interface. It provides a default implementation of the iterate method based on the generate and stream methods:
By extending this class, providers only need to implement the generate and stream methods, making it easier to add support for new LLM services.

LLM utility functions

The LLM component exposes several utility functions that simplify working with messages and providers. These utilities help you format messages correctly, convert between different formats, and implement provider functionality with less boilerplate code.

Message conversion utilities

Provider implementation helpers

The LLM package includes the iterateFromMethods utility function that makes it easier to implement the iterate method required by the LLMProvider interface:
When extending BaseLLMProvider, the iterate method is automatically implemented for you using iterateFromMethods, which properly handles both streaming and non-streaming generation based on the options provided.

Content type utilities

When working with the LLM component’s rich content types, you’ll often need to create, transform, or filter content blocks. The LLM package provides type definitions that help with this:
These utilities help you work with the structured message format used by Agenite, ensuring type safety and consistent handling of different content types.

Benefits of the LLM abstraction

  1. Provider independence: Your agents can work with any supported LLM provider
  2. Consistent interfaces: Standardized methods for both streaming and non-streaming generation
  3. Rich content support: Handling of multimodal content and tool interactions
  4. Token tracking: Built-in mechanisms for monitoring token usage
  5. Future-proofing: As new providers emerge, your code remains compatible

Conclusion

The LLM component is the foundation that enables Agenite’s provider-agnostic approach. By providing a clean abstraction over different language model APIs, it allows you to build agents that can leverage the best models for your specific needs without getting locked into a single provider’s ecosystem. In the next section, we’ll explore how providers implement this LLM interface to connect to specific language model services.