-
Notifications
You must be signed in to change notification settings - Fork 8
Minor refactor, simplified how "interactive" mode works #48
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
base: main
Are you sure you want to change the base?
Conversation
…, so I renamed it interactiveMode and flipped it around.
There was a problem hiding this 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 streamlines the interactive chat flow by replacing the singleShot
flag with a clearer interactiveMode
boolean, refactors the prompt loop into a ChatWithUser
helper, and updates tests to match the new behavior.
- Renamed and inverted
singleShot
logic tointeractiveMode
- Extracted inline chat prompt loop into
ChatWithUser
- Updated tests to expect two messages instead of three
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
cmd/run/run_test.go | Adjusted test assertions to expect 2 messages after initial-prompt refactoring |
cmd/run/run.go | Introduced interactiveMode , simplified prompt/file templating logic, and added ChatWithUser |
Comments suppressed due to low confidence (2)
cmd/run/run.go:295
- [nitpick] The variable
pf
is ambiguous; consider renaming it topromptFile
orpromptConfig
for clarity.
if pf == nil {
cmd/run/run.go:576
- The new
ChatWithUser
helper contains its own I/O and command parsing logic but lacks direct unit tests; consider adding tests to validate prompt handling and command responses.
func (h *runCommandHandler) ChatWithUser(conversation Conversation, mp ModelParameters) (Conversation, error) {
@@ -139,7 +139,7 @@ messages: | |||
_, err = runCmd.ExecuteC() | |||
require.NoError(t, err) | |||
|
|||
require.Equal(t, 3, len(capturedReq.Messages)) | |||
require.Equal(t, 2, len(capturedReq.Messages)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the most sus change in the whole PR, but I think it's because I fixed a bug. I checked out the version in the main
branch, with 3 messages, and added some code to print the Messages out. This is what I got back:
=== RUN TestRun/--file_pre-loads_YAML_from_file
Message 1:
Content: You are a text summarizer.
Role: system
Message 2:
Content: Hello there!
Role: user
Message 3:
Content:
Role: user
i.e. the third and final message was simply empty. So, I sheepishly just decremented this number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! I'd be interested in @sgoedecke or another Models reviewer looking this over, as my Go skills are fair to middling. Thank you for working on the extension!
|
||
func (h *runCommandHandler) ChatWithUser(conversation Conversation, mp ModelParameters) (Conversation, error) { | ||
fmt.Printf(">>> ") | ||
reader := bufio.NewReader(os.Stdin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll avoid merging til @sgoedecke has had a chance to have a looksee 😄. |
Co-authored-by: Sarah Vessels <cheshire137@github.com>
What?
This PR:
interactiveMode
.Why?
I'm using this extension to teach myself some LLM-oriented workflows. I'm writing little shell scripts to have an AI companion in my CLI, and trying to figure out how to get the LLM to do most of the heavy lifting. I am thinking of proposing & then implementing some additional features to this extension (i.e. I think I might want to be able to pipe context in and have an interactive mode).
Ahead of those proposals, and to flex a little with LLMs, I decided to do some light refactoring. I like to keep my PRs small and bite-sized, so apologies if I create a few of these just tidying things up.