save the enriched prompt as last conversation
October 30, 2024 ยท View on GitHub
Contributing to Smartcat ๐โโฌ
State of the project and main directions
Smartcat has reached an acceptable feature set. As a unix CLI tool it should remain focused and minimal but feature requests and suggestions are encouraged.
Codebase quality improvement are very welcome as I hadn't really used rust since 2019 and it shows.
Codebase map
src/
โ # args parsing logic
โโโ main.rs
โ # a (manageable) handful of utility functions used in serveral other places
โโโ utils.rs
โ # logic to customize the template prompt with the args
โโโ prompt_customization.rs
โ # logic to insert the input into the prompt
โโโ config
โ โ # function to check config
โย ย โโโ mod.rs
โ โ # config structs for API config definition (url, key...)
โย ย โโโ api.rs
โ โ # config structs for prompt defition (messages, model, temperature...)
โย ย โโโ prompt.rs
โ # text api related code (request, adapters)
โโโ text
โ # make third party requests and read the result
โโโ mod.rs
โ # make the request to the api and read the result
โโโ api_call.rs
โ # logic to adapt smartcat prompts to third party ones
โโโ request_schemas.rs
โ # structs to parse and extract the message from third party answers
โโโ response_schemas.rs
Logic flow
The prompt object is passed through the entire program, enriched with the input (from stdin) and then the third party response. The third party response is then written stdout and the whole conversation (including the input and the response) is then saved as the last prompt for re-use.
Regular
main
# parse the args and get the template prompt / continue with last conversation as prompt
-> prompt_customization::customize_prompt
โ# update the templated prompt with the information from the args
<-
-> text::process_input_with_request
โ# insert the input in the prompt
โ# load the api config
-> text::api_call::post_prompt_and_get_answer
โ# translate the smartcat prompt to api-specific prompt
โ# make the request
โ# get the message from api-specific response
<-
โ# add response message to the prompt
โ# write the response message to stdout
<-
# save the enriched prompt as last conversation
# exit
Testing
Some tests rely on environement variables and don't behave well with multi-threading. They are marked with #[serial] from the serial_test crate.
DOING
- Voice intergation
TODO
- make it available on homebrew
- handle streams
- automagical context fetches (might be out of scope)
- add RAG capabilities (might be out of scope)