Skip to content

Commit ab00b65

Browse files
committed
update; test enum stuff
1 parent b39d2aa commit ab00b65

File tree

2 files changed

+40
-42
lines changed

2 files changed

+40
-42
lines changed

packages/core/src/generation.ts

+13-15
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ async function generateEnum<T extends string>({
287287
runtime: IAgentRuntime;
288288
context: string;
289289
modelClass: ModelClass;
290-
enumValues: readonly T[];
290+
enumValues: Array<T>;
291291
functionName: string;
292292
}): Promise<JSONValue> {
293293
logFunctionCall(functionName, runtime);
@@ -303,7 +303,7 @@ async function generateEnum<T extends string>({
303303
context,
304304
modelClass,
305305
output: 'enum',
306-
enum: enumValues as unknown as string[],
306+
enum: enumValues,
307307
});
308308

309309
elizaLogger.debug("Received enum response:", result);
@@ -322,18 +322,17 @@ export async function generateShouldRespond({
322322
context: string;
323323
modelClass: ModelClass;
324324
}): Promise<"RESPOND" | "IGNORE" | "STOP" | null> {
325-
const RESPONSE_VALUES = ['RESPOND', 'IGNORE', 'STOP'] as const;
326-
type ResponseType = typeof RESPONSE_VALUES[number];
325+
const RESPONSE_VALUES = ['RESPOND', 'IGNORE', 'STOP'];
327326

328-
const result = await generateEnum<ResponseType>({
327+
const result = await generateEnum({
329328
runtime,
330329
context,
331330
modelClass,
332331
enumValues: RESPONSE_VALUES,
333332
functionName: 'generateShouldRespond',
334333
});
335334

336-
return result as ResponseType;
335+
return result as "RESPOND" | "IGNORE" | "STOP";
337336
}
338337

339338
export async function generateTrueOrFalse({
@@ -347,10 +346,10 @@ export async function generateTrueOrFalse({
347346
}): Promise<boolean> {
348347
logFunctionCall('generateTrueOrFalse', runtime);
349348

350-
const BOOL_VALUES = ['true', 'false'] as const;
351-
type BoolString = typeof BOOL_VALUES[number];
349+
const BOOL_VALUES = ['true', 'false'];
352350

353-
const result = await generateEnum<BoolString>({
351+
352+
const result = await generateEnum({
354353
runtime,
355354
context,
356355
modelClass,
@@ -591,35 +590,34 @@ export async function generateTweetActions({
591590
modelClass: ModelClass;
592591
}): Promise<ActionResponse | null> {
593592
try {
594-
const BOOL_VALUES = ['true', 'false'] as const;
595-
type BoolString = typeof BOOL_VALUES[number];
593+
const BOOL_VALUES = ['true', 'false'];
596594

597595
// Generate each action using generateEnum
598-
const like = await generateEnum<BoolString>({
596+
const like = await generateEnum({
599597
runtime,
600598
context: `${context}\nShould I like this tweet?`,
601599
modelClass,
602600
enumValues: BOOL_VALUES,
603601
functionName: 'generateTweetActions_like'
604602
});
605603

606-
const retweet = await generateEnum<BoolString>({
604+
const retweet = await generateEnum({
607605
runtime,
608606
context: `${context}\nShould I retweet this tweet?`,
609607
modelClass,
610608
enumValues: BOOL_VALUES,
611609
functionName: 'generateTweetActions_retweet'
612610
});
613611

614-
const quote = await generateEnum<BoolString>({
612+
const quote = await generateEnum({
615613
runtime,
616614
context: `${context}\nShould I quote this tweet?`,
617615
modelClass,
618616
enumValues: BOOL_VALUES,
619617
functionName: 'generateTweetActions_quote'
620618
});
621619

622-
const reply = await generateEnum<BoolString>({
620+
const reply = await generateEnum({
623621
runtime,
624622
context: `${context}\nShould I reply to this tweet?`,
625623
modelClass,

pnpm-lock.yaml

+27-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)