-
Notifications
You must be signed in to change notification settings - Fork 39
/
cot.ts
35 lines (31 loc) 路 983 Bytes
/
cot.ts
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
import { Generate, type GenerateOptions } from '../dsp/generate.js';
import type { GenIn, GenOut } from '../dsp/program.js';
import { Signature } from '../dsp/sig.js';
import type { AIService } from '../text/types.js';
export class ChainOfThought<
IN extends GenIn = GenIn,
OUT extends GenOut = GenOut
> extends Generate<IN, OUT & { reason: string }> {
constructor(
ai: AIService,
signature: Readonly<Signature | string>,
options?: Readonly<GenerateOptions>
) {
super(ai, signature, options);
this.updateSignature(this.updateSig);
}
private updateSig = (sig: Readonly<Signature>) => {
// const outputs = sig
// .getOutputFields()
// .map((f) => `\`${f.name}\``)
// .join(', ');
const description = `Let's work this out in a step by step way in order to ensure we have the right answer.`;
sig.setOutputFields([
{
name: 'reason',
description
},
...sig.getOutputFields()
]);
};
}