Skip to content

Commit

Permalink
chatgpt_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ishandutta2007 committed May 10, 2024
1 parent 8167dbd commit d77c138
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 20 deletions.
63 changes: 59 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"expiry-map": "^2.0.0",
"github-markdown-css": "^5.1.0",
"inter-ui": "^3.19.3",
"llm-playground-chain": "^0.0.6",
"lodash-es": "^4.17.21",
"ofetch": "^1.0.1",
"preact": "^10.11.3",
Expand Down
3 changes: 2 additions & 1 deletion src/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Browser from 'webextension-polyfill'
import { getProviderConfigs, ProviderType } from '../config'
import { ChatGPTProvider, getChatGPTAccessToken, sendMessageFeedback } from './providers/chatgpt'
// import { ChatGPTProvider, getChatGPTAccessToken, sendMessageFeedback } from './providers/chatgpt'
import { ChatGPTProvider, getChatGPTAccessToken, sendMessageFeedback } from 'llm-playground-chain'
import { OpenAIProvider } from './providers/openai'
import { Provider } from './types'

Expand Down
12 changes: 6 additions & 6 deletions src/background/providers/chatgpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { GenerateAnswerParams, Provider } from '../types'
dayjs().format()

async function request(token: string, method: string, path: string, data?: unknown) {
return fetch(`https://chat.openai.com/backend-api${path}`, {
return fetch(`https://chatgpt.com/backend-api${path}`, {
method,
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -56,7 +56,7 @@ async function request_new(
data?: unknown,
callback?: unknown,
) {
return fetch(`https://chat.openai.com/backend-api${path}`, {
return fetch(`https://chatgpt.com/backend-api${path}`, {
method,
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -152,7 +152,7 @@ export async function getChatGPTAccessToken(): Promise<string> {
if (cache.get(KEY_ACCESS_TOKEN)) {
return cache.get(KEY_ACCESS_TOKEN)
}
const resp = await fetch('https://chat.openai.com/api/auth/session')
const resp = await fetch('https://chatgpt.com/api/auth/session')
if (resp.status === 403) {
throw new Error('CLOUDFLARE')
}
Expand Down Expand Up @@ -201,7 +201,7 @@ export class ChatGPTProvider implements Provider {
}

async getChatRequirementsToken(params: SendMessageParams) {
const resp = await fetch('https://chat.openai.com/backend-api/sentinel/chat-requirements', {
const resp = await fetch('https://chatgpt.com/backend-api/sentinel/chat-requirements', {
method: 'POST',
signal: params.signal,
headers: {
Expand All @@ -224,7 +224,7 @@ export class ChatGPTProvider implements Provider {
}

async registerWSS(params: GenerateAnswerParams) {
const resp = await fetch('https://chat.openai.com/backend-api/register-websocket', {
const resp = await fetch('https://chatgpt.com/backend-api/register-websocket', {
method: 'POST',
signal: params.signal,
headers: {
Expand Down Expand Up @@ -397,7 +397,7 @@ export class ChatGPTProvider implements Provider {
const chatRequirementsToken = await this.getChatRequirementsToken(params)
console.debug('Using model:', modelName)

await fetchSSE('https://chat.openai.com/backend-api/conversation', {
await fetchSSE('https://chatgpt.com/backend-api/conversation', {
method: 'POST',
signal: params.signal,
headers: {
Expand Down
6 changes: 3 additions & 3 deletions src/background/providers/chatgpt_new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// import { GenerateAnswerParams, Provider } from '../types'

// async function request(token: string, method: string, path: string, data?: unknown) {
// return fetch(`https://chat.openai.com/backend-api${path}`, {
// return fetch(`https://chatgpt.com/backend-api${path}`, {
// method,
// headers: {
// 'Content-Type': 'application/json',
Expand Down Expand Up @@ -34,7 +34,7 @@
// if (cache.get(KEY_ACCESS_TOKEN)) {
// return cache.get(KEY_ACCESS_TOKEN)
// }
// const resp = await fetch('https://chat.openai.com/api/auth/session')
// const resp = await fetch('https://chatgpt.com/api/auth/session')
// if (resp.status === 403) {
// throw new Error('CLOUDFLARE')
// }
Expand Down Expand Up @@ -80,7 +80,7 @@
// const modelName = await this.getModelName()
// console.log('Using model:', modelName, params.conversationId, params.parentMessageId)

// await fetchSSE('https://chat.openai.com/backend-api/conversation', {
// await fetchSSE('https://chatgpt.com/backend-api/conversation', {
// method: 'POST',
// signal: params.signal,
// headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/content-script/ChatGPTQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function ChatGPTQuery(props: Props) {
return (
<p>
Please login and pass Cloudflare check at{' '}
<a href="https://chat.openai.com" target="_blank" rel="noreferrer">
<a href="https://chatgpt.com" target="_blank" rel="noreferrer">
chat.openai.com
</a>
{retry > 0 &&
Expand Down
5 changes: 4 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"48": "logo.png",
"128": "logo.png"
},
"host_permissions": ["https://*.openai.com/"],
"host_permissions": [
"https://*.openai.com/",
"https://*.chatgpt.com/"
],
"permissions": [ "storage" ],
"background": {
"service_worker": "background.js"
Expand Down
8 changes: 6 additions & 2 deletions src/manifest.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
"48": "logo.png",
"128": "logo.png"
},
"permissions": ["storage", "https://*.openai.com/"],
"permissions": [
"storage",
"https://*.openai.com/",
"https://*.chatgpt.com/"
],
"background": {
"scripts": ["background.js"]
},
Expand Down Expand Up @@ -81,7 +85,7 @@
// },
// {
// "matches": [
// "https://chat.openai.com/*",
// "https://chatgpt.com/*",
// "https://google.com/*"
// ],
// "resources": [
Expand Down
4 changes: 2 additions & 2 deletions src/popup/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ function App() {
)
}
if (accessTokenQuery.data) {
return <iframe src="https://chat.openai.com" className="grow border-none" />
return <iframe src="https://chatgpt.com" className="grow border-none" />
}
return (
<div className="grow flex flex-col justify-center">
<p className="text-base px-2 text-center">
Please login and pass Cloudflare check at{' '}
<a href="https://chat.openai.com" target="_blank" rel="noreferrer">
<a href="https://chatgpt.com" target="_blank" rel="noreferrer">
chat.openai.com
</a>
</p>
Expand Down

0 comments on commit d77c138

Please sign in to comment.