File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,23 @@ export function inferArrayItemType(property: SchemaProperties): string | null {
122122 }
123123}
124124
125+ /**
126+ * Add enum values as string to property descriptions.
127+ * @param properties
128+ */
129+ export function addEnumsToDescriptionsWithExamples ( properties : { [ key : string ] : SchemaProperties } ) : { [ key : string ] : SchemaProperties } {
130+ for ( const property of Object . values ( properties ) ) {
131+ if ( property . enum && property . enum . length > 0 ) {
132+ property . description = `${ property . description } \nPossible values: ${ property . enum . join ( ',' ) } ` ;
133+ }
134+ const value = property . prefill ?? property . default ;
135+ if ( value && ! ( Array . isArray ( value ) && value . length === 0 ) ) {
136+ property . examples = Array . isArray ( value ) ? value : [ value ] ;
137+ }
138+ }
139+ return properties ;
140+ }
141+
125142/**
126143 * Filters schema properties to include only the necessary fields.
127144 * @param properties
@@ -160,7 +177,8 @@ export async function getActorsAsTools(actors: string[]): Promise<Tool[]> {
160177 if ( result ) {
161178 if ( result . input && 'properties' in result . input && result . input ) {
162179 const properties = filterSchemaProperties ( result . input . properties as { [ key : string ] : SchemaProperties } ) ;
163- result . input . properties = shortenProperties ( properties ) ;
180+ const propertiesShortened = shortenProperties ( properties ) ;
181+ result . input . properties = addEnumsToDescriptionsWithExamples ( propertiesShortened ) ;
164182 }
165183 try {
166184 const memoryMbytes = result . defaultRunOptions ?. memoryMbytes || defaults . maxMemoryMbytes ;
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ export interface SchemaProperties {
4545 prefill : string ;
4646 items ?: { type : string ; }
4747 editor ?: string ;
48+ examples ?: unknown [ ] ;
4849}
4950
5051// ActorStoreList for actor-search tool
You can’t perform that action at this time.
0 commit comments