Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Prototype] Self-hosted CodeLlama LLM for code autocompletion#576

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
senwang86 wants to merge6 commits intocodepod-io:main
base:main
Choose a base branch
Loading
fromsenwang86:copilot

Conversation

senwang86
Copy link
Collaborator

@senwang86senwang86 commentedNov 4, 2023
edited
Loading

Summary

This pr provides a solution to use CodeLlama for self-hosted code autocompletion.

  • A standalone LLM is required to run separately and expose a RESTful API to access. The most straight-forward way is to usellama.cpp, in which you can host the LLM either on a Mac laptop or a GPU-installed machine.
    • Please follow the instructions ofllama.cpp to run the LLM locally or in a cloud, also feel free to let me know if a detailed tutorial is needed.
  • A Sidebar setting is added to enable/disable the copilot
  • tRPC seems not very well support multiple providers in React,ref, thus I put the Route inapi/src/server, initially we talked about to create an standalone server service to the copilot-related services.
  • There are a couple of follow-up patches to add, e.g., vite bug fix, monitoring the copilot service connection status, similar to the sync statue in the top of Sidebar, adding infilling mode in addition to autocomplete mode.This PR also aims to collect some early feedback regarding the overall design and architecture.

Test

  1. First, enable the RESTful API on the llama.cpp, assuming the IP address isx.x.x.x, port is9090
  2. On the local machine, open the terminal,
    • cd codepod/api/
    • pnpm dev --copilotIP x.x.x.x --copilotPort 9090
  • Note that, the screenshot below intends to the demonstrate the functionality, the quality of the auto-completion might be low due to the 4-bit quantized llama-7b model.

copilot

@senwang86senwang86 marked this pull request as ready for reviewNovember 4, 2023 04:21
@lihebi
Copy link
Collaborator

lihebi commentedNov 5, 2023
edited
Loading

  • tRPC seems not very well support multiple providers in React,ref,

I also came across multiple providers the other day, and it is well supported:trpc#3049. I have implemented multiple providers inhttps://github.com/codepod-io/codepod-cloud/pull/11. Related code:

https://github.com/codepod-io/codepod-cloud/blob/113f4f7ca3656d6db2296bb32a64dc8ae3ae3342/ui/src/lib/trpc.ts#L9-L16

@lihebi
Copy link
Collaborator

lihebi commentedNov 5, 2023
edited
Loading

With that said, it could actually be better and simpler to leave it inapi/ routers, so that the frontend always has one API to talk to. We can let theapi/ forward the request to the actual LLM service internally through tRPC or gRPC.

Copy link
Collaborator

@lihebilihebi left a comment

Choose a reason for hiding this comment

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

Thanks, Sen! It works well. I left some minor comments in the code.

One issue is the automatic completion byInlineCompletionsProvider is not very responsiveness. Sometimes it is fired, and sometimes it is not. How about using a shortcut to trigger it manually, and disable the automatic triggering?

@@ -59,6 +68,8 @@ export async function startServer({ port, repoDir }) {
});

http_server.listen({ port }, () => {
console.log(`🚀 Server ready at http://localhost:${port}`);
console.log(
`🚀 Server ready at http://localhost:${port}, LLM Copilot is hosted at ${copilotIpAddress}:${copilotPort}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd revert this print information, because people may choose to run CodePod without copilot server, and this info is misleading. Just be silent should be fine.

} else {
remoteUrl = `${window.location.hostname}:${window.location.port}`;
}
export const trpcProxyClient = createTRPCProxyClient<AppRouter>({
Copy link
Collaborator

Choose a reason for hiding this comment

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

We already have a trpc client in App.tsx. You can access the client inllamaInlineCompletionProvider like this:

// MyMonaco.tsxfunctionMyMonaco(){   ...const{ client}=trpc.useUtils();constllamaCompletionProvider=newllamaInlineCompletionProvider(id,editor,client);}

Copy link
Collaborator

Choose a reason for hiding this comment

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

A second thought: since the copilot is already a REST API, and we are not going to further customize it or add authentication to this Desktop app, let's directly call the REST API in the frontend.

The trpc is preferred in the cloud app.

@lihebi
Copy link
Collaborator

Also, there's an uncaught exception in the console for canceled API call. I'd like to catch it and display a canceling message to keep the console clean.

Screenshot 2023-11-07 at 11 50 33 AM

@lihebi
Copy link
Collaborator

monitoring the copilot service connection status

This isn't that critical. We can assume that the service is up.

adding infilling mode in addition to autocomplete mode

This is quite important. It is quite often that we edit code in the middle.

@senwang86
Copy link
CollaboratorAuthor

After the discussion, we decide to leave this PR as a reference to integrate the self-hosted copilot and address the comments in the codepod-cloud repo.

@senwang86senwang86 changed the title[Feature] Self-hosted CodeLlama LLM for code autocompletion[Prototype] Self-hosted CodeLlama LLM for code autocompletionNov 17, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@lihebilihebilihebi left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@senwang86@lihebi

[8]ページ先頭

©2009-2025 Movatter.jp