Skip to main content
Defined in: client/sampling/generic.ts:52 Contribution template. Wraps any async function into a SamplingHandler. The adapter resolves the model from modelPreferences, defaults maxTokens, and threads onToken through. Message format conversion, tool translation, and streaming are the caller’s responsibility. Example:
const adapter = new GenericSamplingAdapter(async ({ model, messages }) => {
  const text = await myLlm.complete(model, messages)
  return { role: 'assistant', content: { type: 'text', text }, model, stopReason: 'endTurn' }
})

Implements

Constructors

Constructor

new GenericSamplingAdapter(fn, options?): GenericSamplingAdapter;
Defined in: client/sampling/generic.ts:56

Parameters

fn
GenericCompletionFn
options?
SamplingAdapterOptions & { defaultModel?: string; }

Returns

GenericSamplingAdapter

Methods

asHandler()

asHandler(): SamplingHandler;
Defined in: client/sampling/generic.ts:64

Returns

SamplingHandler

Implementation of

SamplingAdapter.asHandler