LLMs and Embedders

This page presents the abstract interfaces used to plug LLMs and embedders into Oracle Agent Memory.

LLM Interface

class oracleagentmemory.apis.llms.ILlm

Bases: ABC

Abstract interface for LLM invocation.

method generate (abstract)

Generate a response from an LLM synchronously.

method generate_async (abstract, async)

Asynchronously generate a response from an LLM.

LLM Responses

class oracleagentmemory.apis.llms.LlmResponse

Bases: object

A small normalized response returned by ILlm.

text

The primary generated text content.

Embedder Interface

class oracleagentmemory.apis.IEmbedder

Bases: ABC

Abstract interface for text embedders.

method embed (abstract)

Embed a batch of texts into a 2D float32 NumPy array.

method embed_async (abstract, async)

Embed a batch of texts into a 2D float32 NumPy array.

LiteLLM Adapters

class oracleagentmemory.core.llms.Llm

Bases: ILlm

Adapter leveraging litellm to produce chat completions.

Create a LiteLLM-backed LLM adapter.

method generate

Generate a response.

method generate_async (async)

Asynchronously generate a response using LiteLLM.

class oracleagentmemory.core.embedders.Embedder

Bases: IEmbedder

LiteLLM-backed embedder

Notes

The LiteLLM client is imported only when the embedder is first used, keeping optional dependency costs low for applications that do not rely on LiteLLM. Connection details such as api_base and api_key are merged into the call to litellm.embedding when provided.

method embed

Embed a batch of texts using LiteLLM.

Examples

Simple single-text embedding with a configured LiteLLM embedder:

vector = embedder.embed(["ping"])
vector.shape[0]
1

method embed_async (async)

Embed a batch of texts using LiteLLM.