Skip to content

Commit

Permalink
Fix claude model not allowed error
Browse files Browse the repository at this point in the history
  • Loading branch information
wong2 committed Dec 25, 2023
1 parent e30199b commit 14d617d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/app/bots/claude-web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ interface ConversationContext {
export class ClaudeWebBot extends AbstractBot {
private organizationId?: string
private conversationContext?: ConversationContext
private model: string

async doSendMessage(params: SendMessageParams) {
constructor() {
super()
this.model = 'claude-2.1'
}

async doSendMessage(params: SendMessageParams): Promise<void> {
if (!(await requestHostPermission('https://*.claude.ai/'))) {
throw new ChatError('Missing claude.ai permission', ErrorCode.MISSING_HOST_PERMISSION)
}
Expand All @@ -39,12 +45,20 @@ export class ClaudeWebBot extends AbstractBot {
text: params.prompt,
completion: {
prompt: params.prompt,
model: 'claude-2.1',
model: this.model,
},
attachments: [],
}),
})

// different models are available for different accounts
if (!resp.ok && resp.status === 403 && this.model === 'claude-2.1') {
if ((await resp.text()).includes('model_not_allowed')) {
this.model = 'claude-2.0'
return this.doSendMessage(params)
}
}

let result = ''

await parseSSEResponse(resp, (message) => {
Expand Down

0 comments on commit 14d617d

Please sign in to comment.