copilot.el icon indicating copy to clipboard operation
copilot.el copied to clipboard

Support for chat

Open drewwells opened this issue 1 year ago • 19 comments

Chat goes publicly available soon. Would be good to integrate it. It's a very useful tool but we're unable to use it in eMacs right now

https://github.blog/2023-11-08-universe-2023-copilot-transforms-github-into-the-ai-powered-developer-platform/

drewwells avatar Nov 09 '23 03:11 drewwells

@drewwells , as far as I am used to @zerolfx answers, if Github integrates it in the neovim plugin or releases a separate neovim plugin for that, it would be possible to go.

rakotomandimby avatar Nov 09 '23 15:11 rakotomandimby

I'm not a user of neovim, I couldn't validate, but I see traces of chat functionality in neovim repo command:workbench.panel.chat.view.copilot.focus

shroomist avatar Dec 01 '23 15:12 shroomist

This would indeed be a good feature to add IMO. Correct me if I'm wrong but this has not officially released (in general and as a feature of the neovim plugin)? I will keep this issue open so we can monitor the situation.

emil-vdw avatar Dec 12 '23 12:12 emil-vdw

I am eagerly waiting for this feature. A lot of thanks in advance.

wrn avatar Dec 12 '23 14:12 wrn

There is this project that implements Chat support for Neovim. It's unofficial, and I haven't tested this (I don't use nvim as my code editor), but according to the README it works

sylvesterroos avatar Dec 18 '23 09:12 sylvesterroos

I believe Neovim maybe be getting chat soon https://github.com/orgs/community/discussions/50939

FengqiuAdamDong avatar Dec 20 '23 17:12 FengqiuAdamDong

https://github.com/CopilotC-Nvim/CopilotChat.nvim

xz-dev avatar Apr 20 '24 14:04 xz-dev

https://github.com/CopilotC-Nvim/CopilotChat.nvim

any chance of getting it in emacs? @devs

Aneeqasif avatar May 29 '24 12:05 Aneeqasif

Hi,

I created a repository : https://github.com/chep/copilot-chat.el

I'm using neovim plugin code to implement copilot chat.

Currently, I'm able to ask something to copilot. The answer is printed in a buffer. Exemple for (copilot-chat-ask "write me a simple UDP server in C")

Copilot answer:
Sure, here's a simple UDP server written in C. This server will receive a message from a client, print it, and then send a response back.

```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>

#define BUF_SIZE 1024
#define PORT 8888

void error_handling(char *message);

int main(int argc, char *argv[])
{
    int serv_sock;
    char message[BUF_SIZE];
    struct sockaddr_in serv_addr;
    struct sockaddr_in clnt_addr;
    socklen_t clnt_addr_size;

    serv_sock = socket(PF_INET, SOCK_DGRAM, 0);
    if (serv_sock == -1)
        error_handling("UDP socket creation error");

    memset(&serv_addr, 0, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
    serv_addr.sin_port = htons(PORT);

    if (bind(serv_sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) == -1)
        error_handling("bind() error");

    while(1) {
        clnt_addr_size = sizeof(clnt_addr);
        int str_len = recvfrom(serv_sock, message, BUF_SIZE, 0, (struct sockaddr*)&clnt_addr, &clnt_addr_size);
        if (str_len == -1)
            error_handling("recvfrom() error");

        printf("Received from client: %s\n", message);

        sendto(serv_sock, message, str_len, 0, (struct sockaddr*)&clnt_addr, clnt_addr_size);
    }

    close(serv_sock);
    return 0;
}

void error_handling(char *message)
{
    fputs(message, stderr);
    fputc('\n', stderr);
    exit(1);
}
``

This server listens on port 8888 and uses the `recvfrom` function to receive data from a client. It then sends the same data back to the client using the `sendto` function. The `error_handling` function is used to display error messages and terminate the program in case of any errors.

(I just removed a backquote to have a pretty print in github)

Feel free to help me improving this or to use it for integration in copilot.el.

chep avatar Jul 09 '24 10:07 chep

lovely, does it have any workspace awareness?? like in vscode because that's the thing that separates copilot chat from other ai plugins

Aneeqasif avatar Jul 09 '24 10:07 Aneeqasif

lovely, does it have any workspace awareness?? like in vscode because that's the thing that separates copilot chat from other ai plugins

I think it can simply plus file content and path in chat

xz-dev avatar Jul 09 '24 10:07 xz-dev

looking forward for the package. i hope the features get polished in future. I willl test it out and get back to you with some reviews : )

Aneeqasif avatar Jul 09 '24 10:07 Aneeqasif

lovely, does it have any workspace awareness?? like in vscode because that's the thing that separates copilot chat from other ai plugins

It's only one day of work so for the moment I can authenticate, send a prompt and parse answer. That's all.

chep avatar Jul 09 '24 11:07 chep

lovely, does it have any workspace awareness?? like in vscode because that's the thing that separates copilot chat from other ai plugins

It's only one day of work so for the moment I can authenticate, send a prompt and parse answer. That's all.

yeah thats cool, best of luck for the project 🤗

Aneeqasif avatar Jul 09 '24 12:07 Aneeqasif

I'm gonna need help for http stuff. My requests are very slow and sometimes I have empty answers. Does anyone knows how to use the url api ?

chep avatar Jul 09 '24 14:07 chep

Hi, Chat is functional, with prompt buffer and shortcut functions (explain, doc, test…). Feel free to test it, open issues and pull requests.

chep avatar Jul 10 '24 09:07 chep

@chep Wondering why you are not using the copilot.vim binary to interface with Copilot chat. Everything is already there to support chat. There is no need for you to implement it via API calls, etc. You can just use not LSP functions like the rest of the plugin to talk to Copilot chat.

Just beautify the file and you will see that everything is ready for you.

		e.set("conversation/preconditions", v6e),
		e.set("conversation/persistence", m6e),
		e.set("conversation/create", f6e),
		e.set("conversation/turn", E6e),
		e.set("conversation/turnDelete", w6e),
		e.set("conversation/destroy", d6e),
		e.set("conversation/rating", b6e),
		e.set("conversation/copyCode", e6e),
		e.set("conversation/insertCode", r6e),
		e.set("conversation/templates", T6e),
		e.set("conversation/agents", Y8e),

TerminalFi avatar Jul 28 '24 04:07 TerminalFi

@TerminalFi Because I used neovim copilot chat plugin which does not use the binary…

chep avatar Aug 01 '24 08:08 chep