Closed pendekarcode closed 11 months ago
I do this from outside, i.e., by catching the error and then starting the script/a new request from scratch
As @Xceron said, the current way you can do this is by catching the error and using a new client for the account you want to switch to.
Currently the interface isnt super ergonomic for this use case, but I can add a switch_account()
method to the ClaudeWrapper
to make this slightly easier.
I do this from outside, i.e., by catching the error and then starting the script/a new request from scratch
Yes, like example my code before. newchat = claude_obj.start_new_conversation("New Conversation", f"Hi Claude!") if newchat is not None: // do something else: // change account
Or you give another ideas?
@pendekarcode I just added a new method to the ClaudeWrapper
class that may help out. Its not on pip
, but you can use it if you download the git repo as a pip
package. Example usage:
newchat = claude_obj.start_new_conversation("New Conversation", f"Hi Claude!")
if newchat is not None:
# do something
else:
# change account
# here, you have to sign into a new account
new_client = claude_client.ClaudeClient(NEW_SESSION_KEY)
claude_obj.switch_account(new_client)
# set the conversation context for `claude_obj` like normal and continue using it
You might be able to make it slightly cleaner based on your use case:
newchat = claude_obj.start_new_conversation("New Conversation", f"Hi Claude!")
if newchat is None:
# fallback to using another client
new_client = claude_client.ClaudeClient(NEW_SESSION_KEY)
claude_obj.switch_account(new_client)
newchat = claude_obj.start_new_conversation("New Conversation", f"Hi Claude!")
# Do something with `newchat`
@pendekarcode I just added a new method to the
ClaudeWrapper
class that may help out. Its not onpip
, but you can use it if you download the git repo as apip
package. Example usage:newchat = claude_obj.start_new_conversation("New Conversation", f"Hi Claude!") if newchat is not None: # do something else: # change account # here, you have to sign into a new account new_client = claude_client.ClaudeClient(NEW_SESSION_KEY) claude_obj.switch_account(new_client) # set the conversation context for `claude_obj` like normal and continue using it
You might be able to make it slightly cleaner based on your use case:
newchat = claude_obj.start_new_conversation("New Conversation", f"Hi Claude!") if newchat is None: # fallback to using another client new_client = claude_client.ClaudeClient(NEW_SESSION_KEY) claude_obj.switch_account(new_client) newchat = claude_obj.start_new_conversation("New Conversation", f"Hi Claude!") # Do something with `newchat`
thank you brother....
@pendekarcode if it works, lmk and ill close the issue.
@pendekarcode if it works, lmk and ill close the issue.
yes brother. thank you very much.
Brother, please add a feature to switch accounts. Because each account has a request limit. Thank You.
prompt = 'string hello world' newchat = claude_obj.start_new_conversation("New Conversation", f"Hi Claude! {prompt}")
if newchat is not None: // Doing something according to the concept else: // HTTP Error 429: Too Many Requests // None // Switch accounts