ubiquity-os-marketplace / text-conversation-rewards

1 stars 27 forks source link

feat/webpage #181

Closed gentlementlegen closed 1 week ago

gentlementlegen commented 3 weeks ago

Resolves #102 Depends on https://github.com/ubiquity-os-marketplace/text-conversation-rewards/pull/170


What's new

image

The changes aim to help developers running the plugin locally and have a preview of the results that displays very similarly to GitHub. They also benefit from caching, so subsequent runs won't refetch all the data allowing for fast runs. OpenAI also can be spoofed to avoid consuming API credits.

gentlementlegen commented 2 weeks ago

@whilefoo if you wanna have a look as well. Needs some more tweaks probably but it is reviewable.

ubiquity-os-beta[bot] commented 1 week ago

@gentlementlegen, this task has been idle for a while. Please provide an update.

gentlementlegen commented 1 week ago

@whilefoo @Keyrxng if you can take a look! I'll fix the CI runs very soon.

Keyrxng commented 1 week ago

Sorry @gentlementlegen if there's any confusion but I've been told by Rndquu not to perform review until things are cleared up regarding my status, I thought 0x4007 would have mentioned it to you sorry man.

rndquu commented 1 week ago

@gentlementlegen

Running bun run ui:dev and getting the POST http://localhost:3000/ net::ERR_CONNECTION_REFUSED error:

Screenshot 2024-11-18 at 18 29 50

What am I doing wrong and why do we need to run some service at http://localhost:3000 ?

gentlementlegen commented 1 week ago

You are running the command that is used to dev the UI only. We need a server because it runs the plug-in. You should use the root "bun start server" command after compiling the front-end.

rndquu commented 1 week ago

You are running the command that is used to dev the UI only. We need a server because it runs the plug-in. You should use the root "bun start server" command after compiling the front-end.

So I need to:

  1. Run bun ui:build from the src/web folder
  2. Run bun server from the root folder

Correct?

rndquu commented 1 week ago

@gentlementlegen

Getting 500 error on "Generate" click:

$ bun --watch src/web/api/index.ts
Started server http://localhost:3000
{
  type: 45,
  schema: {
    default: "info",
    [Symbol(TypeBox.Hint)]: "Enum",
    [Symbol(TypeBox.Kind)]: "Union",
    anyOf: [
      [Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
    ],
  },
  path: "/logLevel",
  value: undefined,
  message: "Expected required property",
  errors: [],
}
1 | /** The base Error type thrown for all TypeBox exceptions  */
2 | export class TypeBoxError extends Error {
3 |     constructor(message) {
4 |         super(message);
            ^
error: Unable to decode value as it does not match the expected schema
Screenshot 2024-11-18 at 18 40 45

What am I doing wrong?

gentlementlegen commented 1 week ago

@rndquu I removed it from the configuration as it should come from the environment, let me know if that solved your problem. Otherwise maybe something in your env is wrong?

rndquu commented 1 week ago

@rndquu I removed it from the configuration as it should come from the environment, let me know if that solved your problem. Otherwise maybe something in your env is wrong?

Getting another 500 error:

$ bun --watch src/web/api/index.ts
Started server http://localhost:3000
{
  type: 45,
  schema: {
    [Symbol(TypeBox.Kind)]: "String",
    type: "string",
  },
  path: "/evmPrivateEncrypted",
  value: undefined,
  message: "Expected required property",
  errors: [],
}
1 | /** The base Error type thrown for all TypeBox exceptions  */
2 | export class TypeBoxError extends Error {
3 |     constructor(message) {
4 |         super(message);
            ^
error: Unable to decode value as it does not match the expected schema

Don't fully understand where evmPrivateEncrypted should be placed.

How to reproduce:

  1. Run bun server
  2. Open http://localhost:3000/
  3. Put ubiquity-os-marketplace in the "Owner" field, text-conversation-rewards in the "Repo" field, 102 in the "Issue Id" field
  4. Disable cache and Open AI
  5. Click Generate

Also notice that the latest jest run is failing.

gentlementlegen commented 1 week ago

@rndquu The evm private key should come from the env. But I also added a check to pick it up from the configuration itself here. Updated the README as well.

Thanks for the QA and sorry for the trouble. I tried with a freshly cloned repo and seems to work fine when following the instructions now.

rndquu commented 1 week ago

@gentlementlegen This error is still present. Could you either add a default value for evmPrivateEncrypted in .ubiquity-os.config.yml either mention it in the .env.example?

Otherwise looks good.

Overall we need some kind of a "mini kernel" which would send predefined github payloads to plugins. Smth like (example for the /wallet command):

# run the plugin as a worker
yarn worker
# send github payload to the plugin
$ ubiquity-os send "issue_comment.created" --body "/wallet 0x01"

But since https://github.com/ubiquity-os/ubiquity-os-kernel/issues/171 is ready (I haven't checked how it works yet) probably the above approach is not really necessary.

gentlementlegen commented 1 week ago

@rndquu I will add the one we use for tests in the .dev.example then since it would be safe to use.

Now that we have the SDK, every plugin can run as a "server". This server is able to listen to network events. So I think what you describe can be solved by using .http files (or curl, or postman or any tool capable of doing network calls) that can have a payload that mimics GitHub one. We used this technique inside other plugins, like here: https://github.com/ubiquity-os-marketplace/command-query/blob/cd27f14a67b1eb090bc7f1e3ef597479f67640e3/tests/http/request.http.

gentlementlegen commented 1 week ago

Key added here: https://github.com/ubiquity-os-marketplace/text-conversation-rewards/pull/181/commits/b3a3a940d116be6bf4d2688b0db04ee86bb61635

Thanks for your patience and the review.