Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set prompt metadata for render action as expected by dev ui #2180

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion js/ai/src/prompt.ts
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you mind adding unit tests for the metadata (can probably just add some assertions to existing tests)? I just feel like you've fixed this in the past and I broke it again...

Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ function promptMetadata(options: PromptConfig<any, any, any>) {
return {
...options.metadata,
prompt: {
...options.metadata?.prompt,
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know the history here, but copying existing metadata.prompt as the base, and then overriding with the few options below that were already present.

config: options.config,
input: {
schema: options.input ? toJsonSchema(options.input) : undefined,
Expand Down Expand Up @@ -784,7 +785,7 @@ function loadPrompt(
type: 'prompt',
prompt: {
...promptMetadata,
template: source,
template: parsedPrompt.template,
Copy link
Member Author

Choose a reason for hiding this comment

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

Set the template to just the body, w/o the yaml header.

},
},
maxTurns: promptMetadata.raw?.['maxTurns'],
Expand Down
Loading