All files / kernel-agents/src/strategies/json example-transcripts.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 0/0
100% Lines 4/4

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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75                                    1x             1x                         1x                                                                     1x  
/**
 * Example transcripts for the prompt
 */
import {
  CapabilitySpecMessage,
  UserMessage,
  AssistantMessage,
  CapabilityResultMessage,
} from './messages.ts';
import type { Transcript } from './messages.ts';
import { extractCapabilitySchemas } from '../../capabilities/capability.ts';
import { end as endCapability } from '../../capabilities/end.ts';
import { search as searchCapability } from '../../capabilities/examples.ts';
import {
  count as countCapability,
  multiply as multiplyCapability,
} from '../../capabilities/math.ts';
 
const { end, search, count, multiply } = extractCapabilitySchemas({
  end: endCapability,
  search: searchCapability,
  count: countCapability,
  multiply: multiplyCapability,
});
 
const simpleSemanticTask: Transcript = [
  new CapabilitySpecMessage({ end, search }),
  new UserMessage('What color is a banana?'),
  new AssistantMessage({
    think: [
      'Bananas can be either yellow or green, depending on the variety and ripeness.',
      'Typically, people think of yellow bananas when they think of bananas.',
      'I should give the typical response, but clarify that I am assuming the banana is ripe.',
    ],
    invoke: [{ name: 'end', args: { final: 'A banana is yellow when ripe.' } }],
  }),
];
 
const multiStepCalculation: Transcript = [
  new CapabilitySpecMessage({ end, count, multiply }),
  new UserMessage(
    'What is the size of a matrix with rows indexed by the letters of "piano" and columns by the letters of "guitar"?',
  ),
  new AssistantMessage({
    think: [
      'I need to find the size of a matrix with rows indexed by the letters of "piano" and columns by the letters of "guitar".',
      'The answer will be the product of the length of the word "piano" and the length of the word "guitar".',
      'To prove my answer, I will count the lengths of the words using the "count" capability, then multiply the results using the "multiply" capability.',
    ],
    invoke: [
      { name: 'count', args: { word: 'piano' } },
      { name: 'count', args: { word: 'guitar' } },
    ],
  }),
  new CapabilityResultMessage([
    { name: 'count', args: { word: 'piano' }, result: 5 },
    { name: 'count', args: { word: 'guitar' }, result: 6 },
  ]),
  new AssistantMessage({
    think: ['Now I can multiply the results to get the answer.'],
    invoke: [{ name: 'multiply', args: { factors: [5, 6] } }],
  }),
  new CapabilityResultMessage([
    { name: 'multiply', args: { factors: [5, 6] }, result: 30 },
  ]),
  new AssistantMessage({
    think: ['Now I can return the answer.'],
    invoke: [
      { name: 'end', args: { final: 'Such a matrix would have 30 elements.' } },
    ],
  }),
];
 
export const exampleTranscripts = [simpleSemanticTask, multiStepCalculation];