xhjkl / well

A command-line utility to chat with your codebase
49 stars 3 forks source link

[FR] Add support for Claude (anthropic) #5

Open CapCap opened 2 weeks ago

CapCap commented 2 weeks ago

Request: support claude (anthropic) in addition to chatGPT

I've been using well a bunch, really enjoying it- but given claudes context is > 6x (200k) what chatGPTs is (22k), would be interesting to test it out too.

Would you welcome a PR for this?

xhjkl commented 1 week ago

Hi, Max! Glad you dropped by! Great to know you found the thing useful.

I was thinking about adding Claude too, but my own experience shows that OpenAI's models are better at reasoning and code understanding, even if some benchmarks online indicate the opposite. Given that, and because I wanted to focus on the simplicity of implementation before version one comes out, I'm not rushing it.

The main problem with Anthropic is that you cannot easily plug in their api instead of OpenAI's, as you do with ollama, because there are subtle differences in schema.

Also, the newest gpt-4o has a context window of 128k, so the gap is closing: https://platform.openai.com/docs/models/gpt-4o

Having said all that, the PR you're describing will be more than welcome.

The implementation details are entirely up to you, but if I were to start adding Anthropic today, I'd do it like follows:

I imagine the overall approach as follows... ``` trait ChatFlavor { fn complete(&self) -> Result; } struct OpenAI; struct Anthropic; impl ChatFlavor for OpenAI { fn complete(&self) -> Result { ... } } impl ChatFlavor for Anthropic { fn complete(&self) -> Result { ... } } struct Chat { flavor: Flavor, } impl Chat { fn new() -> Chat { Chat { flavor: OpenAI } } fn new_anthropic_flavored() -> Chat { Chat { flavor: Anthropic } } fn complete(&self) -> Result { self.flavor.complete() } } ```

Of course, this is a lot of work, so if you lose interest to adding Anthropic, please feel free to submit another feature request, I'd love to discuss that.

xhjkl commented 1 week ago

On the second thought, perhaps we could just move to Stainless/Fern once they get there.