Skip to content
Draft
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions js/ai/src/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ function definePromptAsync<
},
metadata: resolvedOptions.metadata?.metadata
? {
prompt: resolvedOptions.metadata?.metadata,
}
prompt: resolvedOptions.metadata?.metadata,
}
: undefined,
});

Expand Down Expand Up @@ -432,6 +432,7 @@ function promptMetadata(options: PromptConfig<any, any, any>) {
...options.metadata?.prompt,
config: options.config,
input: {
default: options.input?.default,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While adding the default property is the goal of this PR, the PromptConfig interface has not been updated to reflect this change. The input property on PromptConfig does not have a default field.

This can lead to type safety issues and might be missed by the compiler due to the use of any in PromptConfig<any, any, any>.

Please consider updating the PromptConfig interface in js/ai/src/prompt.ts to include the default property on input. A possible update could be:

  input?: {
    schema?: I;
    jsonSchema?: JSONSchema7;
    default?: z.infer<I>;
  };

This would make the change type-safe and consistent across the codebase, affecting both this line and the change in the loadPrompt function.

schema: options.input ? toJsonSchema(options.input) : undefined,
},
name: options.name.includes('.')
Expand Down Expand Up @@ -855,6 +856,7 @@ function loadPrompt(
format: promptMetadata.output?.format,
},
input: {
default: promptMetadata.input?.default,
jsonSchema: promptMetadata.input?.schema,
},
metadata,
Expand Down
Loading