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

Create an example setup that works with the basic prompts #83

Open
rajbos opened this issue Sep 13, 2024 · 7 comments
Open

Create an example setup that works with the basic prompts #83

rajbos opened this issue Sep 13, 2024 · 7 comments

Comments

@rajbos
Copy link
Contributor

rajbos commented Sep 13, 2024

It was quite a hassle to get things started with the SDK, I think it would make it a lot easier if an example folder is included that can be executed, basically with the example of 'Talk like a pirate'.

I'd be happy to help out with that, either in this repo or in a new one?
We can also include an example of running this inside of a Codespace, which works rather nicely. A walk trough would really help there as well.

Let me know your thoughts and I can help out with setting things up.

@gr2m
Copy link
Collaborator

gr2m commented Sep 13, 2024

That would be most wonderful, I really like repositories with an examples/ folder, I think that the Next.js team really paved the way to show how great it can be:

https://github.com/vercel/next.js/tree/canary/examples

  • It's great for users to have reference examples
  • It's great for maintainers to have examples close to the codebase, we could even implement end-to-end tests to make sure that examples do not break moving forward
  • my favorite: it's a fantastic additional way of contributing to the project.

@rajbos thank you for making that suggestion. If you like, you can start by creating the first examples/* folder and if you get stuck in any way, please reach out for help

@rajbos
Copy link
Contributor Author

rajbos commented Sep 13, 2024

I will!

@gr2m
Copy link
Collaborator

gr2m commented Sep 13, 2024

I recently shared a minimal hello world example privately within @github. I figured I'll share it here as well, maybe we can use it as a starting point for examples/hello-world/index.js

import { createServer } from "http";

import {
  createTextEvent,
  createDoneEvent,
} from "@copilot-extensions/preview-sdk";

const server = createServer((req, res) => {
  if (req.method === "GET") {
    return res.end("ok");
  }

  res.write(createTextEvent("Hello, world!"));
  res.end(createDoneEvent());
});

const PORT = process.env.PORT || 3000;
server.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

@gr2m
Copy link
Collaborator

gr2m commented Sep 13, 2024

Also here is my own app that I've been using to try out all the SDK capabilities:
https://github.com/gr2m/app

It's a bit messy but maybe it helps

@rajbos
Copy link
Contributor Author

rajbos commented Sep 13, 2024

That link returns a 404 for me.

@rajbos
Copy link
Contributor Author

rajbos commented Sep 13, 2024

Draft PR started, please comment if you have remarks on the direction it is going.

@gr2m
Copy link
Collaborator

gr2m commented Sep 13, 2024

That link returns a 404 for me.

sorry it was private, fixed it now

gr2m added a commit that referenced this issue Sep 17, 2024
See the conversation in #83 

- Adding `examples` folder with easy to start projects (see `README` in
that folder)
- Example 1: hello world
- Example 2: handle the user prompt by sending it to the Copilot API and
returning the result

---------

Co-authored-by: Gregor Martynus <[email protected]>
gr2m pushed a commit that referenced this issue Oct 2, 2024
<!--
This pull request template provides suggested sections for framing your
work.
You're welcome to change or remove headers if it doesn't fit your use
case. :)
-->

### What are you trying to accomplish?
Another example to add from the discussion in #83 

### What approach did you choose and why?
Adding a full example how to create the user confirmation and handling
the response, for easier exploration.

### What should reviewers focus on?
If things fit the right way, happy to adjust when needed 😄
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