Skip to content

Commit

Permalink
feat: enhance session/conversation (#162)
Browse files Browse the repository at this point in the history
* feat: enhance session/conversation

* updates

* updates

* cut version v0.9.0-rc2

* add .session name completion
  • Loading branch information
sigoden authored Oct 28, 2023
1 parent 1575d44 commit bc44026
Show file tree
Hide file tree
Showing 12 changed files with 409 additions and 224 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aichat"
version = "0.9.0-rc1"
version = "0.9.0-rc2"
edition = "2021"
authors = ["sigoden <sigoden@gmail.com>"]
description = "A powerful chatgpt cli."
Expand Down
52 changes: 20 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Download it from [GitHub Releases](https://github.com/sigoden/aichat/releases),
- Predefine AI [roles](#roles)
- Use GPT prompt easily
- Powerful [Chat REPL](#chat-repl)
- Context-aware conversation
- Context-aware conversation/session
- Syntax highlighting markdown and 200 other languages
- Stream output with hand-typing effect
- Support multiple models
Expand All @@ -58,9 +58,8 @@ On completion, it will automatically create the configuration file. Of course, y
```yaml
model: openai:gpt-3.5-turbo # Choose a model
temperature: 1.0 # See https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature
save: true # If set true, aichat will save chat messages to message.md
save: true # If set true, aichat will save non-session chat messages to messages.md
highlight: true # Set false to turn highlight
conversation_first: false # If set true, start a conversation immediately upon repl
light_theme: false # If set true, use light theme
auto_copy: false # Automatically copy the last output to the clipboard
keybindings: emacs # REPL keybindings, possible values: emacs (default), vi
Expand Down Expand Up @@ -167,10 +166,10 @@ AIChat also provides `.edit` command for multi-lines editing.
.prompt Add a GPT prompt
.role Select a role
.clear role Clear the currently selected role
.conversation Start a conversation.
.clear conversation End current conversation.
.session Start a session
.clear session End current session
.copy Copy the last output to the clipboard
.read Read the contents of a file into the prompt
.read Read the contents of a file and submit
.edit Multi-line editing (CTRL+S to finish)
.history Print the history
.clear history Clear the history
Expand All @@ -187,11 +186,11 @@ Press Ctrl+C to abort readline, Ctrl+D to exit the REPL
config_file /home/alice/.config/aichat/config.yaml
roles_file /home/alice/.config/aichat/roles.yaml
messages_file /home/alice/.config/aichat/messages.md
sessions_dir /home/alice/.config/aichat/sessions
model openai:gpt-3.5-turbo
temperature 0.7
save true
highlight true
conversation_first false
light_theme false
dry_run false
vi_keybindings true
Expand Down Expand Up @@ -264,41 +263,30 @@ emoji〉.clear role
Hello there! How can I assist you today?
```
### `.conversation` - start a context-aware conversation
## Session - context-aware conversation
By default, aichat behaves in a one-off request/response manner.
You should run aichat with "-s/--session" or use the ".session" command to start a session.
You can run `.conversation` to enter context-aware mode, or set `config.conversation_first` true to start a conversation immediately upon repl.
```
〉.conversation

)list 1 to 5, one per line 4089
1
2
3
4
5

)reverse the list 4065
5
4
3
2
1
〉.session
temp)1 to 5, odd only 4089
1, 3, 5

```
When entering conversation mode, prompt `〉` will change to `)`. A number will appear on the right,
indicating how many tokens are left to use.
Once the number becomes zero, you need to start a new conversation.
temp)to 7 4070
1, 3, 5, 7

Exit conversation mode:
temp).clear session

```
).clear conversation 4043
```sh
aichat --list-sessions # List sessions
aichat -s # Start with a new session
aichat -s rust # If session rust exists, use it. If it does not exist, create a new session.
aichat -s rust --info # Show session details
```

## License
Expand Down
6 changes: 6 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ pub struct Cli {
/// Run in dry run mode
#[clap(long)]
pub dry_run: bool,
/// List sessions
#[clap(long)]
pub list_sessions: bool,
/// Initiate or continue named session
#[clap(short = 's', long)]
pub session: Option<Option<String>>,
/// Input text
text: Vec<String>,
}
Expand Down
91 changes: 0 additions & 91 deletions src/config/conversation.rs

This file was deleted.

Loading

0 comments on commit bc44026

Please sign in to comment.