All files / kernel-test/src/vats lms-sample-vat.ts

0% Statements 0/5
0% Branches 0/2
0% Functions 0/2
0% Lines 0/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                                                       
import type { ERef } from '@endo/eventual-send';
import { makeDefaultExo } from '@metamask/kernel-utils/exo';
import { makeSampleClient } from '@ocap/kernel-language-model-service';
import type { SampleService } from '@ocap/kernel-language-model-service';
 
import { unwrapTestLogger } from '../test-powers.ts';
import type { TestPowers } from '../test-powers.ts';
 
/**
 * A vat that uses a kernel language model service to perform a raw sample
 * completion and logs the response. Used to verify the full kernel → LMS
 * service round-trip for the sample path.
 *
 * @param vatPowers - The powers of the vat.
 * @param parameters - The parameters of the vat.
 * @param parameters.prompt - The prompt to sample from.
 * @returns A default Exo instance.
 */
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export function buildRootObject(
  vatPowers: TestPowers,
  { prompt = 'Hello' }: { prompt?: string } = {},
) {
  const tlog = unwrapTestLogger(vatPowers, 'lms-sample');
  return makeDefaultExo('root', {
    async bootstrap(
      _roots: unknown,
      { languageModelService }: { languageModelService: ERef<SampleService> },
    ) {
      const client = makeSampleClient(languageModelService, 'test');
      const result = await client.sample({ prompt });
      tlog(`response: ${result.text}`);
    },
  });
}