arshad-yaseen / monacopilot

⚡️AI auto-completion plugin for Monaco Editor, inspired by GitHub Copilot.
MIT License
20 stars 1 forks source link

custom front-end part #30

Open wuhanjun opened 2 days ago

wuhanjun commented 2 days ago

Hello, How can I customize headers, catch errors, etc. when I only need to access the front-end part?

arshad-yaseen commented 2 days ago

Hey, the registerCompletion function and copilot.complete handle errors internally by logging them with appropriate messages and ignoring them. Both functions will not throw errors. However, if you prefer to handle the errors yourself, I can create a new option called throwOnError for both functions. This option would prevent logging and ignoring the errors, and instead, throw them. What do you think?

arshad-yaseen commented 2 days ago

Which headers do you need to customize from frontend? Is it in the request going from the frontend to the API where you set up copilot.complete, or in the request going to the AI model?

wuhanjun commented 2 days ago

Because I only used the front-end part of the monacopilot, the back-end part was implemented by our company's server-side colleagues themselves, without using Node.

When used in my project, we will add some custom attributes required by the business itself in the request header. In addition, we also need to notice the user with an error message when the interface encounters an error, or redirect to a single sign on site when not logged in.

arshad-yaseen commented 1 day ago

I understand.

Already on it, Keep you posted!

arshad-yaseen commented 19 hours ago

Hey, here's an update: please update monacopilot to the latest version (v0.10.19 🚀).

Refer to the following:

I believe these will fulfill your needs. Lmk if not 🙂

If you have any questions or need further assistance, feel free to reach out. I'm happy to help! Thanks!

wuhanjun commented 6 hours ago

So efficient, thank you very much. I'll give it a try.

wuhanjun commented 6 hours ago

Speaking of which, would it be better to open up a request API? It will return a promise. If someone else wants to customize the processing of request parameters, or handle the results of responses, etc., you will need to add other methods or properties. Haha, I want to hear your opinion.