Exafunction / codeium-react-code-editor

AI-enabled code editor for React. Unlimited AI autocomplete capabilities with full Typescript support.
MIT License
162 stars 10 forks source link

Expose a method allowing for editor value to be modified prior to being sent to Codeium for suggestions #18

Closed jaytoday closed 5 months ago

jaytoday commented 5 months ago

It would be helpful if there was a method exposed to provide extra context or content to be included in the value sent to the Codeium model for generating suggestions. An example could be a list of style guide preferences that would be undesirable to include in the editor itself but would be helpful in prompting Codeium to modify the content of its suggestions.

khou22 commented 5 months ago

Hey @jaytoday, thanks for the feature request. I'm working on building out this functionality. Rather than allowing arbitrary prompting (which is not exposed to the client-side), I will be giving the user the ability to pass in documents as context into the prompt.

We have heuristics internally to determine what context is relevant within those other documents (ie. if you're writing JS, it'll read other JS/HTML/CSS files).

I will keep you posted but should have something ready by the end of the week. I'm still not 100% certain it'll work with style guide preferences (since that's more guidelines rather than neighboring code files), but hopefully it helps with a vast majority of use cases.

khou22 commented 5 months ago

New context awareness feature released in v1.0.10! You can specify otherDocuments to allow Codeium to intelligently include snippets in the prompt generation. Allows for very powerful multi-file setups. Here's an open source example: https://github.com/khou22/khou22.github.io/blob/41ab65d9fb52ce8a1c7ed7bb9f202c4e168e42f3/src/app/programming/codeium/ContextAwareDemo.tsx#L37-L52

And here's a quick demo it in action: https://x.com/kevinhou22/status/1757868545990619178?s=20

https://github.com/Exafunction/codeium-react-code-editor/assets/6607077/ecaedbff-f662-4957-82be-a3266a4c2f25

Going to mark this issue as closed. If you'd like other features relating to personalization and context please open up a more specific issue and we can chat about it there. Enjoy!

jaytoday commented 4 months ago

Thank you!

jaytoday commented 4 months ago

Following up, it doesn't seem from my initial experimentation that this otherDocuments param can be used to provide context that can be effectively used as additional instructions. Presumably it is mainly good for working on a module of code and knowing the correct interface to use for another function or class.