Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/actors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ export function inferArrayItemType(property: SchemaProperties): string | null {
}
}

/**
* Add enum values as string to property descriptions.
* @param properties
*/
export function addEnumsToDescriptionsWithExamples(properties: { [key: string]: SchemaProperties }): { [key: string]: SchemaProperties } {
for (const property of Object.values(properties)) {
if (property.enum && property.enum.length > 0) {
property.description = `${property.description}\nPossible values: ${property.enum.join(',')}`;
}
const value = property.prefill ?? property.default;
if (value && !(Array.isArray(value) && value.length === 0)) {
property.examples = Array.isArray(value) ? value : [value];
}
}
return properties;
}

/**
* Filters schema properties to include only the necessary fields.
* @param properties
Expand Down Expand Up @@ -160,7 +177,8 @@ export async function getActorsAsTools(actors: string[]): Promise<Tool[]> {
if (result) {
if (result.input && 'properties' in result.input && result.input) {
const properties = filterSchemaProperties(result.input.properties as { [key: string]: SchemaProperties });
result.input.properties = shortenProperties(properties);
const propertiesShortened = shortenProperties(properties);
result.input.properties = addEnumsToDescriptionsWithExamples(propertiesShortened);
}
try {
const memoryMbytes = result.defaultRunOptions?.memoryMbytes || defaults.maxMemoryMbytes;
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface SchemaProperties {
prefill: string;
items?: { type: string; }
editor?: string;
examples?: unknown[];
}

// ActorStoreList for actor-search tool
Expand Down
Loading