File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,8 +11,14 @@ interface ConversationContext {
1111export class ClaudeWebBot extends AbstractBot {
1212 private organizationId ?: string
1313 private conversationContext ?: ConversationContext
14+ private model : string
1415
15- async doSendMessage ( params : SendMessageParams ) {
16+ constructor ( ) {
17+ super ( )
18+ this . model = 'claude-2.1'
19+ }
20+
21+ async doSendMessage ( params : SendMessageParams ) : Promise < void > {
1622 if ( ! ( await requestHostPermission ( 'https://*.claude.ai/' ) ) ) {
1723 throw new ChatError ( 'Missing claude.ai permission' , ErrorCode . MISSING_HOST_PERMISSION )
1824 }
@@ -39,12 +45,20 @@ export class ClaudeWebBot extends AbstractBot {
3945 text : params . prompt ,
4046 completion : {
4147 prompt : params . prompt ,
42- model : 'claude-2.1' ,
48+ model : this . model ,
4349 } ,
4450 attachments : [ ] ,
4551 } ) ,
4652 } )
4753
54+ // different models are available for different accounts
55+ if ( ! resp . ok && resp . status === 403 && this . model === 'claude-2.1' ) {
56+ if ( ( await resp . text ( ) ) . includes ( 'model_not_allowed' ) ) {
57+ this . model = 'claude-2.0'
58+ return this . doSendMessage ( params )
59+ }
60+ }
61+
4862 let result = ''
4963
5064 await parseSSEResponse ( resp , ( message ) => {
You can’t perform that action at this time.
0 commit comments