st1vms/unofficial-claude-api

Support for switching between the claude 3 models? Perhaps auto switching when opus is out of quota!

mhd25112 opened this issue · 15 comments

I'd really appreciate that feature if it's not too much trouble

I found a way, I modified client.py to remove the lines
if model_name is not None and model_name not in {"claude-2.0", "claude-2.1"}: raise ValueError( "model_name must be either None or one of 'claude-2.0' or 'claude-2.1' strings" )

And initiated the model like that :
claude_client = ClaudeAPIClient(session, timeout=240, model_name="claude-3-sonnet-20240229")

I obtained the model name from the network tab in google chrome

Do you mind if I add that change? I will have to figure out how cuz I am not a coder and I generally dont use github lol

Of course I will add the lines I removed back in but with the claude 3 models instead of claude 2

I also found a way to include images if you want a look at that

@mhd25112 That's great news!
Seems switching model was as simple as overriding the model_name parameter.

Removing the model name check may be a good idea afterall, i'll add this change for the next PR.

Yeah it's simple, would you like the code for image support? Because right now it supports files but that seems to be handled different from images

@mhd25112 Thing is that it should already support any type of file... I included a mimetype check feature in the api just for that.

How is that different from your code?

@st1vms In my testing text files worked fine, but images did not. Do images work for you without modification?

The model_name patch is already live on branch dev-0.3.2

Will test the image attachments...

@mhd25112 I finally was able to let file upload work, now it should successfully process images and other file types, changes are already live in dev-0.3.2 come check them out!

PR #22 should be ready for merge.

Please let me know if dev-0.3.2 works for you.

Awesome, will let you know when I have time to shift my code from the customized API I made to this one and if it works well

Also just a suggestion for accessibility, add to the read me which model names are allowed to be used, right now there is kind of no way someone will figure that out on their own without going to the website and inspecting packets. it is "claude-3-opus-20240229", "claude-3-sonnet-20240229", or "claude-3-haiku-20240229" right now but that needs to be updated periodically I presume.

Also just a suggestion for accessibility, add to the read me which model names are allowed to be used, right now there is kind of no way someone will figure that out on their own without going to the website and inspecting packets. it is "claude-3-opus-20240229", "claude-3-sonnet-20240229", or "claude-3-haiku-20240229" right now but that needs to be updated periodically I presume.

I think it's probably best if I don't check that parameter, as you've noticed it is subject to frequent changes...By default it will allow to use the latest Claude3 model (should be Sonnet). Also I can't seem to find a good reference to gather those strings...

Waiting for confirmations in order to merge dev-0.3.2

@mhd25112 I updated the README with that link, it's already in dev-0.3.2