@@ -54,21 +54,19 @@ async function list(client: Anthropic): Promise<ActionMetadata[]> {
5454
5555 return clientModels
5656 . map ( ( modelInfo ) => {
57- // Remove the final part if it's a date (8 digits)
58- const idParts = modelInfo . id . split ( '-' ) ;
59- const normalizedId = idParts [ idParts . length - 1 ] . match ( / ^ \d { 8 } $ / )
60- ? idParts . slice ( 0 , - 1 ) . join ( '-' )
61- : modelInfo . id ;
57+ // Remove the date suffix from the model id
58+ const normalizedId = modelInfo . id . replace ( / - \d { 8 } $ / , '' ) ;
59+ // Get the model reference from the supported models
6260 const ref = SUPPORTED_CLAUDE_MODELS [ normalizedId ] ;
63- return ref
64- ? modelActionMetadata ( {
65- name : ref . name ,
66- info : ref . info ,
67- configSchema : ref . configSchema ,
68- } )
69- : null ;
61+ // Return the model action metadata if the model is supported
62+ return ref ? modelActionMetadata ( {
63+ name : ref . name ,
64+ info : ref . info ,
65+ configSchema : ref . configSchema ,
66+ } ) : undefined ;
7067 } )
71- . filter ( Boolean ) as ActionMetadata [ ] ;
68+ // Filter out undefined values
69+ . filter ( ( metadata ) => metadata !== undefined ) ;
7270}
7371
7472/**
@@ -115,7 +113,7 @@ export const anthropic = (options?: PluginOptions) => {
115113 const client = new Anthropic ( { apiKey, defaultHeaders } ) ;
116114
117115 const cachedActions : ModelAction [ ] = [ ] ;
118- let listActionsCache ;
116+ let listActionsCache : ActionMetadata [ ] | null = null ;
119117
120118 return genkitPluginV2 ( {
121119 name : 'anthropic' ,
@@ -142,6 +140,7 @@ export const anthropic = (options?: PluginOptions) => {
142140 list : async ( ) => {
143141 if ( listActionsCache ) return listActionsCache ;
144142 listActionsCache = await list ( client ) ;
143+ console . log ( 'listActionsCache' , listActionsCache . length ) ;
145144 return listActionsCache ;
146145 }
147146 } ) ;
0 commit comments