Skip to content

Add interactive shell mode#363

Merged
aandrew-me merged 4 commits into
aandrew-me:mainfrom
aki-colt:feat-interactive-shell
May 6, 2025
Merged

Add interactive shell mode#363
aandrew-me merged 4 commits into
aandrew-me:mainfrom
aki-colt:feat-interactive-shell

Conversation

@aki-colt
Copy link
Copy Markdown
Contributor

Created a new mode called interactive shell, which inherits all the features of interactive mode and can execute shell commands.
Implementation:

  • Use system prompt to force LLM generate commands wrapped in XML <tgpt_command> tags.
  • Stream the natural language output except for the commands. Finally, ask whether to execute the command (of course, automatic execution is also supported).
  • If the execution is successful, interaction can continue; if it fails, it will exit (inheriting the characteristics of shell mode).

Comment thread main.go Outdated
"The shell environment you are is %s. The operate system you are is %s."+
"Examples:"+
"User: list the files in my home dir."+
"Assistant: Sure. I will list the files under your home dir. <tgpt_command>ls ~</tgpt_command>",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Let it just be <cmd>

@aandrew-me
Copy link
Copy Markdown
Owner

Looks good

Phind likely doesn't follow instructions properly
image

@aandrew-me
Copy link
Copy Markdown
Owner

Great job!
Just change to and I will merge

@aki-colt
Copy link
Copy Markdown
Contributor Author

aki-colt commented May 3, 2025

Thanks for review. Sometimes, it does fail to follow instructions. Perhaps adding some self-correction would be a good solution, where the program prompts the large model to regenerate if it detects incomplete tags. Additionally, I noticed that commands like ping or similar ones that don't self-terminate cannot be stopped in interactive-shell mode. I think this is a bug, and I’ll try to fix it.

@aki-colt
Copy link
Copy Markdown
Contributor Author

aki-colt commented May 3, 2025

I’ll first push a commit to fix the issue where commands cannot be stopped. Currently, using Ctrl+C during command execution stops both the command and tgpt. I tried stopping only the command while continuing the conversation, but it caused strange errors. I’ll keep trying, but I don’t think this is a high priority. Additionally, adding self-correction is quite complex under the current code structure. The LLM's error rate is not high, and users can continue inputting to correct the model. So, I think self-correction may not be necessary.

@aandrew-me
Copy link
Copy Markdown
Owner

I am not able to merge because of conflicts

@aki-colt aki-colt force-pushed the feat-interactive-shell branch from 7c122aa to f285ea3 Compare May 6, 2025 08:14
@aki-colt
Copy link
Copy Markdown
Contributor Author

aki-colt commented May 6, 2025

I didn't see conflicts between main branch and mine 🤔.

@aandrew-me aandrew-me merged commit 8dfb4a8 into aandrew-me:main May 6, 2025
@aandrew-me
Copy link
Copy Markdown
Owner

All good, thanks for your work!

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 10, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [aandrew-me/tgpt](https://github.com/aandrew-me/tgpt) | minor | `v2.9.6` -> `v2.10.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>aandrew-me/tgpt (aandrew-me/tgpt)</summary>

### [`v2.10.0`](https://github.com/aandrew-me/tgpt/releases/tag/v2.10.0): tgpt 2.10.0

[Compare Source](aandrew-me/tgpt@v2.9.6...v2.10.0)

#### Changelog:

-   Added interactive shell mode [#&#8203;363](aandrew-me/tgpt#363) (Thanks to [aki-colt](https://github.com/aki-colt))

<details><summary>SHA256 Hashes</summary><code>
SHA256 hashes of the built binaries:
08adc4fee97190c01f1a595aa2f904464241e7e7673990d4d43eb1eb945ee410  tgpt-linux-amd64
06cb03595b3693b97724ad64fa5270eaabe1c40b8a198c31905f60cedd732354  tgpt-linux-i386
69fd6d923b5addfb3d95734431eac983379d9aed7ee91021f3a60b9df1aadb6c  tgpt-linux-arm64
c8f5c8e9cb4f7b9409e704ce6cf8d7e8dd17be17640272c565545eb9c67d2f3b  tgpt-linux-arm
14fbe26d87960a1df4c87059d146db15287ece542c179b4138201b5b487eb19d  tgpt-amd64.exe
ca2085656b5b5cb1f34e1d2ac190d0f4da4295ad55a1ead71a186765616eda25  tgpt-i386.exe
841b1129441d4c4d8c24b693c380cbdafa198d6c4e09a833fddab64a6071a20d  tgpt-mac-amd64
ff70dd9d4d44e98c501860579f4d1cc6ac1dc50bd7d29bf7147b3c70603c6098  tgpt-mac-arm64
</code></details>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xMS4yIiwidXBkYXRlZEluVmVyIjoiNDAuMTEuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
@aandrew-me
Copy link
Copy Markdown
Owner

What do you think about implementing this using mcp?

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