fix: minor cleanups of executablePath

remotes/origin/feature/api-redesign
Travis Fischer 2022-12-16 17:12:28 -06:00
rodzic 94d54836a7
commit d685b7800c
2 zmienionych plików z 8 dodań i 8 usunięć

Wyświetl plik

@ -3,11 +3,7 @@ import type { Browser, HTTPRequest, HTTPResponse, Page } from 'puppeteer'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import * as types from './types' import * as types from './types'
import { import { getBrowser, getOpenAIAuth } from './openai-auth'
defaultChromeExecutablePath,
getBrowser,
getOpenAIAuth
} from './openai-auth'
import { import {
browserPostEventStream, browserPostEventStream,
isRelevantRequest, isRelevantRequest,
@ -63,7 +59,7 @@ export class ChatGPTAPIBrowser {
isGoogleLogin = false, isGoogleLogin = false,
minimize = true, minimize = true,
captchaToken, captchaToken,
browserPath = defaultChromeExecutablePath() browserPath
} = opts } = opts
this._email = email this._email = email
@ -95,6 +91,8 @@ export class ChatGPTAPIBrowser {
this._page.on('request', this._onRequest.bind(this)) this._page.on('request', this._onRequest.bind(this))
this._page.on('response', this._onResponse.bind(this)) this._page.on('response', this._onResponse.bind(this))
maximizePage(this._page)
// bypass cloudflare and login // bypass cloudflare and login
await getOpenAIAuth({ await getOpenAIAuth({
email: this._email, email: this._email,

Wyświetl plik

@ -46,7 +46,8 @@ export async function getOpenAIAuth({
page, page,
timeoutMs = 2 * 60 * 1000, timeoutMs = 2 * 60 * 1000,
isGoogleLogin = false, isGoogleLogin = false,
captchaToken = process.env.CAPTCHA_TOKEN captchaToken = process.env.CAPTCHA_TOKEN,
executablePath
}: { }: {
email?: string email?: string
password?: string password?: string
@ -55,13 +56,14 @@ export async function getOpenAIAuth({
timeoutMs?: number timeoutMs?: number
isGoogleLogin?: boolean isGoogleLogin?: boolean
captchaToken?: string captchaToken?: string
executablePath?: string
}): Promise<OpenAIAuth> { }): Promise<OpenAIAuth> {
const origBrowser = browser const origBrowser = browser
const origPage = page const origPage = page
try { try {
if (!browser) { if (!browser) {
browser = await getBrowser({ captchaToken }) browser = await getBrowser({ captchaToken, executablePath })
} }
const userAgent = await browser.userAgent() const userAgent = await browser.userAgent()