Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: chatgpt-web #1503

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

BlackStar1453
Copy link
Contributor

ChatGPT Web now utilizes WebSocket for data transmission.

@yetone
Copy link
Collaborator

yetone commented May 3, 2024

‌‌Thank you for your contribution, it seems there are some code conflicts that need to be resolved.

@BlackStar1453
Copy link
Contributor Author

Thanks for the reminder. I've already resolved the conflicts, but I'm having trouble understanding the Lint errors that came up and don't know how to fix them.

iI had to modify the eslint config and set /* eslint-disable prettier/prettier */ in the settings and translator components because otherwise, I would encounter prettier/prettier errors that I didn't understand. I hope you can review this portion of the code and make appropriate modifications.
@@ -193,7 +192,7 @@ export class QuoteProcessor {

const chineseLangCodes = ['zh-Hans', 'zh-Hant', 'lzh', 'yue', 'jdbhw', 'xdbhw']

export async function translate(query: TranslateQuery) {
export async function translate(query: TranslateQuery, engine: IEngine | undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‌‌‌Why is this engine singled out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because maintaining a long-term connection is necessary when using WebSockets, we don't have to re-register the WebSocket every time a request is made. To ensure the WebSocket's long-term existence, we need a long-term existing engine, rather than generating a new engine every time the translate function is used, as was done previously.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‌‌‌‌Can this engine be used as a field in TranslateQuery?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fine. I'll give it a try tomorrow when I have time . Also, OpenAI has updated their request specifications, so we need to make some minor adjustments too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed that setting the engine used as a field in TranslateQuery isn't feasible. This is because the engine needs to exist as a useState to avoid being rebuilt every time the translate method is called. Unless you plan to revert to the previous WebAPI Class approach, it's preferable to continue passing the engine as the second parameter, as we're currently doing.

@Loongphy
Copy link

Any progress?

ChatGPT-Web is now available for use, but it seems that occasional usage issues may arise due to risk control, resulting in 403 errors. Multiple attempts may be necessary.
@BlackStar1453
Copy link
Contributor Author

Maybe we could retry the request upon encountering a 403 error, and continue doing so until we receive at least 3 consecutive errors before displaying them on the interface? This could enhance the user experience.

@BlackStar1453
Copy link
Contributor Author

I've found that even when I use the ChatGPT website, I run into the same problem. So, it might not be a ChatGPT-Web issue but rather, OpenAI might be flagging our IP or device as risky, causing access denials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants