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

/import feature successor #507

Closed
tarasglek opened this issue Mar 16, 2024 · 3 comments · Fixed by #560
Closed

/import feature successor #507

tarasglek opened this issue Mar 16, 2024 · 3 comments · Fixed by #560
Assignees
Milestone

Comments

@tarasglek
Copy link
Owner

tarasglek commented Mar 16, 2024

I was thinking oh why the current import feature feels wrong.

  1. I can't change it easily. Proposal: /http command to run arbitrary HTTP requests from CloudFlare #473 as proposed is an overly fancy fix

  2. I don't like /commands cos they are hard to type on mobile and they cause issues like Chatcraft commands conflict with code errors #500

  3. Security aspect restricting /import to logged in users makes for terrible github login UX on mobile browsers/PWA

  4. fact that the command disappears after we run it

  5. I also dont like that we press ask gpt to do something that gpt has nothing to do with.

So I have have the simplest possible solution. Allow one to define POST commands via a yaml textbox in chatcraft options. Eg we would implement current solution by having a default value:

handler_url: /proxy
method: GET
match: \/import https?:\/\/\S+

this would match current behavior of sending commands that look like

  • /import https://www.example.com/file.pdf
  • /import https://www.google.com/file.png

So upon pressing enter:

  1. chatcraft will check if the message matches any of the patterns specified
  2. send request with entire message to url specified. /import?message=/import%20https://www.google.com/file.png

Response from that url endpoint should then be SSE streamed(can be a followup) back into next message with a clear indicator that it came from chatcraft itself. The endpoint could choose to provide an error message, such as asking for auth.

Since I want a behavior where I can paste urls in without any typing and I wanna use scrape2md, I would extend this with

handler_url: /proxy
method: GET
match: \/import https?:\/\/\S+
---
handler_url: https://taras-scrape2md.web.val.run/
match: https?:\/\/\S+

We could later consider auth variables like $GITHUB_AUTH_TOKEN to this.

handler_url: /proxy
method: POST
match: \/import https?:\/\/\S+
options:
  env:
    - name: GITHUB_AUTH_TOKEN
    - value: $GITHUB_AUTH_TOKEN

This seems easy to implement and could be very extensible. yaml should get validated and not let user save changes unless it matches some schema. This could also be done in a followup.

@tarasglek
Copy link
Owner Author

tarasglek commented Mar 16, 2024

Cool thing is that we could also allow these patterns to match ai responses...eg provide a custom-handler button to validate chatcraft Dockerfile output when following conditions match

handler_url: https://some/url/with-dockerfile/validator
match: "^```docker"
options:
  multiline: true
  model_output: true
  user_input: false

We could move all run-on-server stuff to this

@tarasglek
Copy link
Owner Author

Obviously one could build a complex ui over this, but yaml gets us going sooner

@tarasglek
Copy link
Owner Author

tarasglek commented Mar 16, 2024

I would like to get the following example working in first rev of this feature:

handler_url: /proxy
method: GET
match: "$\/import https?:\/\/\S+"
---
handler_url: https://taras-scrape2md.web.val.run/
match: "$https?:\/\/\S+"

We should eval regexps sequentially until one of them matches

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

Successfully merging a pull request may close this issue.

4 participants