-
Notifications
You must be signed in to change notification settings - Fork 15
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
Feat: AI Code AutoCompletion with Codeium Support #328
Conversation
@@ -51,6 +51,8 @@ model User { | |||
Repo Repo[] @relation("OWNER") | |||
sharedRepos Repo[] @relation("COLLABORATOR") | |||
UserRepoData UserRepoData[] | |||
|
|||
codeiumAPIKey String? @default("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd better not store user tokens in the database, for security and privacy policy purposes.
Let's use the browser cache (localStorage
) instead? And let's make all the Codeium API requests directly from the user's browser.
I'm having the same concern in #216, and I plan to use localStorage
for GitHub token as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. localStorage
seems available across all browsers. Should we use it to store users' API keys or their tokens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another strange question: if one stored his/her own token before, after he/she logs out and signs in with another account, should the stored token remains?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, good point. The settings should come and go with the user. If a user logout, the token should also be removed for security purpose. People might log in and out on a public computer in the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this sense, localStorage
is not a good option to store either settings or user tokens. We should indeed use the database.
Thanks for the hard work, @li-xin-yi !
|
I think people should bring their tokens; it's their business and pricing plans with Codeium (though it is free). Otherwise, we need to obtain some enterprise licenses with Codeium to provide it for our users. Anonymous users can still set a token. If we use |
Update: I also keep the option on the sidebar (BTW, I think many options can also be kept on sidebar, for example, show line numbers) I'm considering about storing stuffs in the browser's local storage, not only the token, but the option to turn on/off some feats, such as auto-completion, show annotations, or maybe the last viewpoint... what do you think about it? @lihebi @senwang86 |
I agree that we should move "show line numbers" and "Enable auto completion" to the side bar. |
I have a codepod/ui/src/lib/store/settingSlice.tsx Lines 20 to 50 in 0471799
|
Let's think twice about
I think we could put a few simple things like "debug mode" in |
If the tokens were saved in Auto-Fill, it could be synced by browsers? LIke password synching via Chrome or Firefox. |
19f8d93
to
51532f7
Compare
1ad8d32
to
1c51cf4
Compare
Update: when no default API specified in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Xinyi. The PR looks and works very well. A few minor comments.
const client = useApolloClient(); | ||
const autoCompletion = useStore(store, (state) => state.autoCompletion); | ||
|
||
console.log("autoCompletion", autoCompletion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean this?
ui/src/lib/codeiumClient.ts
Outdated
signal, | ||
headers: this.getHeaders(request.metadata?.apiKey), | ||
}); | ||
console.log("codeium request", request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is printed very often. Change it to console.debug
so that user's console stays clean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we could show an indicator in a "status bar" (or the toolbar near the "auto-complete" switch) to show that we are doing a Codeium request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of indicator. Do we have to implement it in this PR? I can add it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sg, let’s add it later.
if (api_key === "" || api_key === undefined) { | ||
throw new Error("Invalid token"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also provide a way so that people can clear their tokens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Added!
ui/src/components/MyMonaco.tsx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel these changes are leftovers (to be removed) from your code to test Codeium plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, definitely my fault, I forgot to clean them up.
Merging. Thanks, Xinyi! |
Forgot to ask: Do I also need to update the |
I would be helpful to leave a placeholder there for Codeium API. |
compose/prod/compose.yml has been deprecated as it was used for hosting CodePod in a production environment. However, the production setup has been transitioned from Docker to Kubernetes (k8s). You can find the updated configuration at https://github.com/codepod-io/codepod-k8s. Although the prod configuration is no longer recommended for production, it can still be useful for users (non-developers) who want to launch a "local CodePod" with minimal resource requirements. This configuration serves plain HTML and JavaScript instead of using react start, which requires more than 3GB of RAM. Additionally, there is no need to mount the src/ folder since there is no intention to develop the CodePod source code in this scenario. However, to avoid confusion, it is advisable to temporarily remove the prod configuration. We should release a "local CodePod" in some form once we have a clear plan in place. |
@@ -63,6 +70,7 @@ | |||
"zustand": "^4.1.3" | |||
}, | |||
"scripts": { | |||
"generate": "chmod 777 /root && rm -rf ./src/proto && npx buf generate --output ./src/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need chmod 777 /root
? The app inside the container is mounted at /app/src/
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, npx buf generate
will fail because it needs to create & read a /root/.config/buf/config.yaml
. I have no idea how to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I'll take a look later.
Usage
Right-click the pane and select this option:
Then it prompts a tab and requires your Codeium token obtained from this tab:
After that, try to type some prompts in code editor, it gives inline completion suggestions:
Tips
npx prisma migrate dev
in docker api's shell and then restartDon't merge, just for test, many issues may exist
Todo