Skip to content
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

Wrap completions API #5

Open
alexisabril opened this issue Aug 27, 2024 · 2 comments
Open

Wrap completions API #5

alexisabril opened this issue Aug 27, 2024 · 2 comments
Assignees

Comments

@alexisabril
Copy link

alexisabril commented Aug 27, 2024

Similar to the Octokit REST APIs, a method could exist to invoke the completions API for 3P integrators.

For potential consistency, here an OpenAI-inspired version:

const stream = await octokit.copilot.completions.create({...});

for await (const chunk of stream) {
    process.stdout.write(chunk?...);
}

curl for completions:

curl --request POST \
  --url https://api.githubcopilot.com/chat/completions \
  --header 'Authorization: Bearer SUPERSECRET' \
  --header 'Content-Type: application/json' \
  --header 'Copilot-Integration-Id: dev' \
  --data '{
	"messages": [{ "role": "user", "content": "What'\''s the weather like today?" }],
	"max_tokens": 50,
	"temperature": 0.5
}'
@gr2m
Copy link
Collaborator

gr2m commented Aug 27, 2024

@gr2m
Copy link
Collaborator

gr2m commented Aug 27, 2024

I figured we could add a prompt API as specced in the link above (WIP) to the context of the copilot extension SDK's event handlers, see https://github.com/copilot-extensions/preview-sdk.js/blob/main/dreamcode.md#api

Relevant part as of now (dreamcode.md will likely change soon):

// https://github.com/github/copilot-partners/blob/6d1cde3a1abb147da53f1a39864661dc824d40b5/docs/confirmations.md
copilotExtension.on(
  "confirmation",
  async ({ confirmation, octokit, prompt, respond, log }) => {
    if (confirmation.id === "joke") {
      if (confirmation.state === "dismissed") {
        await respond.text("Okay, maybe next time!");
        return;
      }

      await respond.text(
        prompt.stream("Please tell me a joke about Mona Lisa, Github's mascot.")
      );
      return;
    }

    log.warn("Received an unknown confirmation:", confirmation.id);
    await respond.text("Hmm, something went wrong. Please try again later.");
  }
);

Not sure what the best way will be yet, but I want the prompt and response APIs to work together nicely.

@gr2m gr2m self-assigned this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants