Skip to content

Commit

Permalink
fix(anthropic): message role conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
efugier committed Apr 17, 2024
1 parent 27abfc6 commit 1d56a0b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "smartcat"
version = "0.7.2"
version = "0.7.3"
authors = ["Emilien Fugier <[email protected]>"]
description = '''
Putting a brain behind `cat`.
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@
Puts a brain behind `cat`! CLI interface to bring language models in the Unix ecosystem and allow power users to make the most out of llms.

What makes it special:
- a set of partial prompts making the model play nice as a cli tool;
- good io handling to insert user input in said prompts and use the result in cli-based workflows.
- minimalist, built following to the unix philosophy with terminal and editor intergation in mind;
- you can have full control on what LLM version, temperature and API you use;
- good io handling to insert user input in prompts and use the result in cli-based workflows;
- compatible with several LLM APIs (openai, Anthropic, Mistral);
- built-in partial prompt to make the model play nice as a cli tool;
- write and save your own prompt templates for faster reccuring tasks (simplify, optimize, tests);
- conversation support;
- glob expressions to include context files.

Currently supports **ChatGPT** and **Mistral AI** but built to work with multiple ones seemlessly.
Currently supports **OpenAi**, **Mistral AI** and **Claude**.


![](assets/workflow.gif)
Expand All @@ -38,6 +44,9 @@ Currently supports **ChatGPT** and **Mistral AI** but built to work with multipl

## Installation


### With Cargo

With an **up to date** [rust and cargo](https://www.rust-lang.org/tools/install) setup (you might consider running `rustup update`):

```
Expand All @@ -46,7 +55,9 @@ cargo install smartcat

run this command again to update `smartcat`.

Or download directly the binary compiled for your platform from the [release page](https://github.com/efugier/smartcat/releases).
### By downloading the binary

Chose the one compiled for your platform on the [release page](https://github.com/efugier/smartcat/releases).

(the binary is named `sc`)

Expand Down Expand Up @@ -315,4 +326,5 @@ Smartcat has reached an acceptable feature set. The focus is now on upgrading th
#### TODO

- [ ] make it available on homebrew
- [ ] automatically context fetches

2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod config;
#[command(
name = "smartcat (sc)",
author = "Emilien Fugier",
version = "0.7.2",
version = "0.7.3",
about = "Putting a brain behind `cat`. CLI interface to bring language models in the Unix ecosystem 🐈‍⬛",
long_about = None
)]
Expand Down
5 changes: 4 additions & 1 deletion src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ impl From<Prompt> for AnthropicPrompt {
prompt
.messages
.into_iter()
.fold(Vec::new(), |mut acc: Vec<Message>, message| {
.fold(Vec::new(), |mut acc: Vec<Message>, mut message| {
if message.role == "system" {
message.role = "user".to_string();
}
match acc.last_mut() {
Some(last_message) if last_message.role == message.role => {
last_message.content.push_str("\n\n");
Expand Down

0 comments on commit 1d56a0b

Please sign in to comment.