Skip to content

Commit

Permalink
#573's patch
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer committed Dec 4, 2023
1 parent d002aa8 commit 8d53ab8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/background/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ async function executeApi(session, port, config) {
await generateAnswersWithBardWebApi(port, session.question, session, cookies)
} else if (claudeWebModelKeys.includes(session.modelName)) {
const sessionKey = await getClaudeSessionKey()
await generateAnswersWithClaudeWebApi(port, session.question, session, sessionKey)
await generateAnswersWithClaudeWebApi(
port,
session.question,
session,
sessionKey,
session.modelName,
)
}
}

Expand Down
12 changes: 11 additions & 1 deletion src/services/apis/claude-web.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { pushRecord } from './shared.mjs'
import Claude from 'claude-ai'
import { Models } from '../../config/index.mjs'

/**
* @param {Runtime.Port} port
* @param {string} question
* @param {Session} session
* @param {string} sessionKey
* @param {string} modelName
*/
export async function generateAnswersWithClaudeWebApi(port, question, session, sessionKey) {
export async function generateAnswersWithClaudeWebApi(
port,
question,
session,
sessionKey,
modelName,
) {
const bot = new Claude({ sessionKey })
await bot.init()

Expand All @@ -28,6 +36,7 @@ export async function generateAnswersWithClaudeWebApi(port, question, session, s
.startConversation(question, {
progress: progressFunc,
done: doneFunc,
model: Models[modelName].value,
})
.then((conversation) => {
session.claude_conversation = conversation
Expand All @@ -38,5 +47,6 @@ export async function generateAnswersWithClaudeWebApi(port, question, session, s
conversation: session.claude_conversation,
progress: progressFunc,
done: doneFunc,
model: Models[modelName].value,
})
}

0 comments on commit 8d53ab8

Please sign in to comment.