efugier / smartcat

Putting a brain behind `cat`🐈‍⬛ Integrating language models in the Unix commands ecosystem through text streams.
https://crates.io/crates/smartcat
Apache License 2.0
77 stars 9 forks source link

Add configurable timeout to API config #24

Closed lpchaim closed 1 month ago

lpchaim commented 3 months ago

I'm currently experimenting with ollama on a not too powerful laptop, so I stumbled upon #22 pretty quickly. Seeing as I liked the simplicity of smartcat and the fact it's Rust based, I figured I'd try my hand at adding an optional timeout parameter.

I implemented the "timeout" field in ApiConfig, and made it optional. I also made it so the reqwest client is instantiated through its builder so that the timeout can be specified. It could also be passed on the individual request, but since that form doesn't take an Option as a parameter, I figured this would be a bit cleaner.

Right now, the logic works as such:

lpchaim commented 2 months ago

Hey, no worries! Always happy to chip in :)

Anyway, I'd love to give the changes a go on my end, if only to practice my real world Rust a little more. If it ends up not to your taste afterwards, I wouldn't mind at all if you took over and added on top of my modifications. Does that work?

lpchaim commented 2 months ago

Alright, I've implemented the requested changes. These should cover what we've discussed, unless I misunderstood something.

lpchaim commented 1 month ago

Hey, no worries! Lmk if you'd prefer I squashed the commits together or anything like that and I'll get to that ASAP.

efugier commented 1 month ago

It's perfect like that!