Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow templating {{input}} in prompt files #46

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

Merged
merged 3 commits into from
May 8, 2025

Conversation

sgoedecke
Copy link
Collaborator

@sgoedecke sgoedecke commented May 8, 2025

If the prompt yml file passed contains an {{input}}, we should template that in from stdin.

I considered using a separate --input parameter, but templated fields might be pretty large, so stdin seems like a better fit.

@Copilot Copilot AI review requested due to automatic review settings May 8, 2025 05:15
@sgoedecke sgoedecke requested a review from a team as a code owner May 8, 2025 05:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables using a {{input}} placeholder in .prompt.yml files to substitute stdin content into user messages when running gh models run --file. It adds a pipedContent variable in run.go to capture and inject stdin data, updates the command logic to replace {{input}} in user roles, and adds corresponding tests in run_test.go.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/run/run.go Introduce pipedContent, read from stdin when piped, and replace {{input}} in user messages from prompt files. Adjust interactive prompting and loop break conditions to support file-based runs.
cmd/run/run_test.go Remove outdated static prompt assertion and add a new test verifying that {{input}} is substituted with piped stdin content in prompt files.
Comments suppressed due to low confidence (1)

cmd/run/run.go:294

  • We should add tests covering multiple {{input}} occurrences within a single message and verify that placeholders in non-user roles are not replaced to ensure the substitution logic behaves correctly in all scenarios.
if pipedContent != "" && strings.ToLower(m.Role) == "user" {

@sgoedecke sgoedecke merged commit 2f31074 into main May 8, 2025
5 checks passed
@sgoedecke sgoedecke deleted the sgoedecke/allow-templating-input branch May 8, 2025 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants