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

Provide input via stdin and as an argument #128

Closed
2 tasks done
tbckr opened this issue Sep 27, 2023 · 5 comments · Fixed by #239
Closed
2 tasks done

Provide input via stdin and as an argument #128

tbckr opened this issue Sep 27, 2023 · 5 comments · Fixed by #239
Assignees
Labels
enhancement New feature or request

Comments

@tbckr
Copy link
Owner

tbckr commented Sep 27, 2023

Is your feature request related to a problem? Please describe.

Sometimes I want to pipe in some data (e.g. a file) and provide a prompt, what to do with the provided input via stdin.

Describe the solution you'd like

I want to be able to provide input via stdin and as an argument.

The input via an argument should be appended in such cases.

Example: cat some-file | sgpt "my prompt what i want to do with this file"

Describe alternatives you've considered

You can concatinate input in bash by using parentheses (see example below), but this solution is rather complicated.

( cat some-file; echo "my prompt what i want to do with this file"; ) | sgpt

Search

  • I did search for other open and closed issues before opening this

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

No response

@tbckr tbckr added the enhancement New feature or request label Sep 27, 2023
@tbckr tbckr self-assigned this Sep 27, 2023
@tbckr tbckr changed the title Provide prompts via stdin and as an argument Provide input via stdin and as an argument Sep 27, 2023
@tbckr tbckr linked a pull request Sep 30, 2023 that will close this issue
@tbckr
Copy link
Owner Author

tbckr commented Oct 12, 2023

won't be implemented for now

@tbckr tbckr closed this as completed Oct 12, 2023
@CGamesPlay
Copy link

What was the motivation for not merging this feature? I was experimenting with sgpt recently and this was one of the first things I wanted to do. Specifically:

$ git diff --cached | sgpt "Summarize all of these changes in a single line."

I would have liked sgpt to send two messages to the chat, one with the piped file, and the second with the command-line prompt.

@tbckr
Copy link
Owner Author

tbckr commented Mar 21, 2024

Good question. At that time, this would have meant that I had to introduce another breaking change which meant a new major release - which I was not willing to do. The software was supposed to be more stable.
In fact, right now, the first param is interpreted as a modifier and not as a prompt. This is a breaking change in the cli command.
Suggestion: Would it be feasible for you, if you could an additional prompt as the second argument, when data is piped? Then you would have to add an modifier to be able to add an additional prompt. At the same time, I do not really like this, because it is different from the default behaviour, when no data is piped. Moreover, one would still have to decide where to add the prompt in the message - in front of or behind the piped data.
The last option would be to introduce this breaking change and create a major release.
How bad do you want this feature? Does the current workaround not work for you?

@CGamesPlay
Copy link

CGamesPlay commented Mar 22, 2024

Yes, it's fine to have a second argument for me (so like pbpaste | sgpt SUBCOMMAND "Summarize this in a single line"). If I'm designing the interface from scratch, what I'd probably do is use a flag as a placeholder to indicate where piped input goes (so like pbpaste | sgpt "Summarize this in a single line" --stdin). Again, ideally these then get delivered as two separate messages to the model rather than catenated into a single message, but that's more minor.

The current workaround doesn't work for me; it's not ergonomic. My "current workaround" is to use llm instead when I want to do this (pbpaste | llm "Summarize this as a single line"), but I want to use sgpt because it's much easier to install a single binary than an entire python package.

@tbckr
Copy link
Owner Author

tbckr commented Mar 22, 2024

Thank you very much for your input!

I will reopen this issue and integrate it. I cannot give you a timeline right now, but I will try to do it in a timely manner.

@tbckr tbckr reopened this Mar 22, 2024
@tbckr tbckr linked a pull request Mar 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants