Skip to content

GenericFrontendAdapter

Defined in: adapters/generic.ts:102

Passthrough frontend adapter for IR format.

This adapter accepts IR requests directly and returns IR responses without any conversion. It’s useful for:

  • Direct IR access: Work with the universal format without provider wrappers
  • Testing: Test bridges and backends without conversion overhead
  • Custom integrations: Build tools that operate at the IR level
  • Format normalization: Use when your application already produces IR
// Basic usage
const frontend = new GenericFrontendAdapter();
// With custom configuration
const frontend = new GenericFrontendAdapter({
name: 'my-app-frontend',
trackProvenance: true,
maxContextTokens: 128000,
});

new GenericFrontendAdapter(config): GenericFrontendAdapter

Defined in: adapters/generic.ts:110

GenericFrontendConfig = {}

GenericFrontendAdapter

readonly metadata: AdapterMetadata

Defined in: adapters/generic.ts:107

Adapter metadata for identification and capabilities.

FrontendAdapter.metadata

fromIR(response): Promise<IRChatResponse>

Defined in: adapters/generic.ts:194

Pass through Universal IR response without conversion.

This method accepts an IR response and returns it directly without any transformation. Since this is a passthrough adapter, the response remains in IR format, allowing applications to work directly with the universal format.

IRChatResponse

Universal IR chat response

Promise<IRChatResponse>

Promise resolving to the same IR response

const adapter = new GenericFrontendAdapter();
const irResponse = await adapter.fromIR(irResponse);
// Returns the exact same response unchanged
console.log(irResponse.message.content);

FrontendAdapter.fromIR


fromIRStream(stream, _options?): AsyncGenerator<IRStreamChunk, void, undefined>

Defined in: adapters/generic.ts:220

Pass through Universal IR stream chunks without conversion.

This async generator method accepts an IR stream and yields each chunk directly without any transformation. Unlike other frontend adapters that convert to provider-specific formats (SSE, JSON, etc.), this maintains the raw IR chunk structure for direct consumption.

IRChatStream

Universal IR chat stream

StreamConversionOptions

Optional stream conversion options (currently unused)

AsyncGenerator<IRStreamChunk, void, undefined>

IR stream chunks unchanged

const adapter = new GenericFrontendAdapter();
for await (const chunk of adapter.fromIRStream(irStream)) {
if (chunk.type === 'content') {
console.log(chunk.delta); // Access IR structure directly
}
}

FrontendAdapter.fromIRStream


toIR(request): Promise<IRChatRequest>

Defined in: adapters/generic.ts:157

Pass through Universal IR request without conversion.

This method accepts an IR request and returns it directly, as this is a passthrough adapter. When provenance tracking is enabled (default), it adds the frontend adapter name to the provenance metadata for tracking purposes, but otherwise performs no transformations.

IRChatRequest

Universal IR chat request

Promise<IRChatRequest>

Promise resolving to the same IR request (with optional provenance)

const adapter = new GenericFrontendAdapter();
const irRequest = await adapter.toIR({
messages: [{ role: 'user', content: 'Hello!' }],
parameters: { model: 'gpt-4', temperature: 0.7 },
metadata: { requestId: 'req_123', timestamp: Date.now(), provenance: {} }
});
// Returns the same request with provenance.frontend = 'generic-frontend'

FrontendAdapter.toIR


validate(request): Promise<void>

Defined in: adapters/generic.ts:234

Validate IR request structure.

Only performs validation if validateRequests is enabled in config.

IRChatRequest

Promise<void>

FrontendAdapter.validate